The method and apparatus of resource allocation in a kind of local area network
Technical field
The present invention relates to computer communication technology field, in particular to the method and dress of resource allocation in a kind of local area network
It sets.
Background technique
Local area network (Local Area Network, LAN) is in the geographic range of a part by various computers, outer
Portion's equipment and database etc. link up mutually the computer communication network of composition.It can pass through data communication network or exclusive data
Circuit is connected with the local area network in a distant place, database or processing center, constitutes a large-scale information processing system.Local
Net can be made of a main control end and multiple client, wherein main control end is connected with one, two or multiple client, and main
Internet resources can be distributed for each client of connection by controlling end, to support the transmission of various files.
Currently, the network bandwidth in local area network is typically all fixation, in this way, just defining the client that main control end can connect
Hold quantity.Such as: when setting client terminal quantity that main control end can connect as 20, then in the local area network, main control end can only be right
This 20 clients distribute resources, and still, some clients disconnect or liveness is not high, the client there is no need to
Resource or it is only necessary to less resources, at this point, the local area network still can only carry out resource allocations according to 20 clients,
And the quantity connecting with main control end cannot be changed to 19 or other smaller value, and then can not be according to the visitor after change quantity
Family end carries out resource allocation.As it can be seen that the client of this fixed quantity connects, the unreasonable of resource allocation will cause.
Summary of the invention
The present invention provides a kind of method and apparatus of resource allocation in local area network, to improve the reasonability of resource allocation.
The present invention provides a kind of method of resource allocation in local area network, local area network include a main control end and and at least one
Client, wherein main control end is connect with n client, and n is the integer more than or equal to 1, this method comprises:
According to the status information of control window corresponding with each client of connection, the active state of each client is determined
Grade;
According to the active state grade of each client, the quantity n of connection client is updated;
According to the updated quantity n, the client currently connected is adjusted, and to each client distribution adjusted
Corresponding resource.
In one embodiment of the invention, the active state grade for stating determining each client includes:
If the current control window is in activation selected state, it is determined that the corresponding current visitor of the current control window
The active state grade at family end is most to enliven grade, if the current control window is in un-activation selected state, it is determined that institute
The active state grade for stating the corresponding active client of current control window is inactive grade;Or,
If the current control window is in maximum rating, it is determined that the corresponding active client of the current control window
Active state grade be most enliven grade, if the current control window is in minimum state, it is determined that the current control
The active state grade of the corresponding active client of window is inactive grade.
In one embodiment of the invention, the quantity n for updating connection client includes:
According to the corresponding relationship of the active state grade of preservation and active state grade point, the determining work with each client
Jump the corresponding active state grade point of state grade;
The active state grade point of each client is compared with given threshold respectively, is updated and is connected according to comparison result
Meet the quantity n of client.
In one embodiment of the invention, the quantity n for updating connection client according to comparison result includes:
If the active state grade point of active client is greater than given threshold, the quantity n is added 1;
If the active state grade point of active client is less than given threshold, the quantity n is subtracted 1.
It is described according to the updated quantity n in one embodiment of the invention, before adjusting the client currently connected,
Further include:
Detect the connection status of the main control end;
If detecting when having newly-increased client to connect in the local area network with the main control end, the quantity n is added 1;
If detect that the first client disconnects the connection with the main control end in the client connecting with the main control end,
The quantity n is subtracted 1.
The present invention provides a kind of device of resource allocation in local area network, the local area network include a main control end and at least
One client, wherein main control end is connect with n client, and n is the integer more than or equal to 1, which includes:
Determination unit determines each visitor for the status information according to control window corresponding with each client of connection
The active state grade at family end;
Updating unit updates the quantity n of connection client for the active state grade according to each client;
Allocation unit is adjusted, for adjusting the client currently connected according to the updated quantity n, and to adjustment
Each client afterwards distributes corresponding resource.
In one embodiment of the invention, the determination unit is chosen if being in activation specifically for the current control window
State, it is determined that the current active state grade for controlling the corresponding active client of window is most to enliven grade, if described
Current control window be in un-activation selected state, it is determined that it is described it is current control the corresponding active client of window enliven shape
State grade is inactive grade;Or, if the current control window is in maximum rating, it is determined that the current control window pair
The active state grade for the active client answered is most to enliven grade, if the current control window is in minimum state, really
The fixed current active state grade for controlling the corresponding active client of window is inactive grade.
In one embodiment of the invention, the updating unit includes:
First module, for the corresponding relationship according to the active state grade of preservation and active state grade point, determine with
The corresponding active state grade point of the active state grade of each client;
Second module, for the active state grade point of each client to be compared with given threshold respectively, according to
Comparison result updates the quantity n of connection client.
In one embodiment of the invention, second module, if the active state grade point specifically for active client is big
When given threshold, the quantity n is added 1, it, will be described if the active state grade point of active client is less than given threshold
Quantity n subtracts 1.
In one embodiment of the invention, the device further include: detection updating unit, for detecting the connection shape of the main control end
The quantity n is added 1, if detecting if detecting when having newly-increased client to connect in the local area network with the main control end by state
When the first client disconnects the connection with the main control end in the client connecting with the main control end, the quantity n is subtracted 1.
Some beneficial effects of the embodiment of the present invention may include:
According to the active state grade for each client being connect with main control end, adjusts main control end and currently connect client
Quantity, and corresponding resource is distributed for each client adjusted, in this way, main control end is no longer the client with fixed number
Connection, but when the client of connection is relatively enlivened, the client number of connection is increased, when the client of connection is inactive
When, then the client number of connection is reduced, in this way, main control end can be that client distributes network money according to different connection quantity
Source can utilize Internet resources to large extent, do not easily cause the idle of Internet resources, be reasonably assigned with resource.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification
It obtains it is clear that understand through the implementation of the invention.The objectives and other advantages of the invention can be by written explanation
Specifically noted structure is achieved and obtained in book, claims and attached drawing.
Below by drawings and examples, technical scheme of the present invention will be described in further detail.
Detailed description of the invention
Attached drawing is used to provide further understanding of the present invention, and constitutes part of specification, with reality of the invention
It applies example to be used to explain the present invention together, not be construed as limiting the invention.In the accompanying drawings:
Fig. 1 is the flow chart of resource allocation in local area network in the embodiment of the present invention one;
Fig. 2 is the flow chart of resource allocation in local area network in the embodiment of the present invention two;
Fig. 3 is the flow chart of resource allocation in local area network in the embodiment of the present invention three;
Fig. 4 is the structure chart of the device of resource allocation in local area network in the embodiment of the present invention four.
Specific embodiment
Hereinafter, preferred embodiments of the present invention will be described with reference to the accompanying drawings, it should be understood that preferred reality described herein
Apply example only for the purpose of illustrating and explaining the present invention and is not intended to limit the present invention.
Embodiment one, includes main control end in local area network, and one, two or more clients.Wherein, have n client with
Main control end connection, can carry out the transmission of file.The connection quantity n of main control end and client is the integer more than or equal to 1.This implementation
In example, the process of resource allocation is as shown in Figure 1 in local area network, comprising:
Step 101: according to the status information of control window corresponding with each client, determining enlivening for each client
State grade.
There is multiple client in local area network, wherein n client is connect with main control end, in this way, can generally show in main control end
Show control window corresponding with each client of connection, can be believed according to the state of control window corresponding with each client
Breath, determines the active state grade of each client.Wherein, status information includes: state of activation information or size state information.
And the active state grade of client can also correspond to multiple ranks, and such as: the active state ranking score of client
Grade Dui Ying not enlivened, secondary enliven grade and inactive grade;Alternatively, the active state grade of client respectively corresponds work
Jump grade 1 enlivens grade 2, enlivens grade 3, enlivens class 4 ..., wherein it is more bigger more active to enliven grade.
In this way, can be according to the determining active client corresponding with current control window of state of activation of current control window
Active state grade.Such as: if currently control window is in activation selected state, it is determined that current control window is corresponding current
The active state grade of client is most to enliven grade, if currently control window is in un-activation selected state, it is determined that current
The active state grade for controlling the corresponding active client of window is inactive grade.
It certainly, can also be according to the determining active client corresponding with current control window of size state of current control window
Active state grade.Such as: if currently control window is in maximum rating, it is determined that current to control the corresponding current visitor of window
The active state grade at family end is most to enliven grade, and the current window that controls is in minimum state, it is determined that current control window pair
The active state grade for the active client answered is inactive grade.Alternatively, if currently control window is in maximum rating, really
The active state grade of the corresponding active client of control window is to enliven class 5 before settled;If currently control window is in secondary
Big state, it is determined that the current active state grade for controlling the corresponding active client of window is to enliven class 4;Successively successively decrease,
If currently control window is in minimum state, it is determined that currently the active state grade of the corresponding active client of control window is
Enliven grade 1.
Step 102: according to the active state grade of each client, updating the quantity n of connection client.
The corresponding relationship of active state grade Yu active state grade point is preset, in this way, when each visitor has been determined
It, can be corresponding with the active state grade of each client according to the determination of the corresponding relationship of preservation after the active state grade at family end
Active state grade point.Such as: the active state grade of preservation and the corresponding relationship of active state grade point are as shown in table 1:
Active state grade |
Active state grade point |
Enliven grade 1 |
0 |
Enliven grade 2 |
1 |
Enliven grade 3 |
2 |
Enliven class 4 |
3 |
…… |
…… |
Table 1
Alternatively, the active state grade saved and the corresponding relationship of active state grade point are as shown in table 1:
Active state grade |
Active state grade point |
Most enliven grade |
5 |
It is secondary to enliven grade |
3 |
Inactive grade |
1 |
Table 2
And the active state grade of each client is not exactly the same, corresponding active state grade point also incomplete phase
Together, the active state grade point of each client is compared with given threshold respectively, connection visitor is updated according to comparison result
The quantity n at family end.
When discovery has, client is more active, when active state grade point is greater than given threshold, can connect main control end
The quantity n of client increases, and finds to have that client is inactive, can be by master when active state grade point is less than given threshold
The quantity n for controlling end connection client is reduced.Specifically can include: if the active state grade point of active client is greater than given threshold
When, quantity n is added 1;If the active state grade point of active client is less than given threshold, quantity n is subtracted 1.
With table 1, for threshold value=2, if the active state grade point of active client is 3,3 to be greater than threshold value 2, then by quantity
N adds 1;The active state grade point of active client is 0,0 less than threshold value 2, then subtracts 1 for quantity n.According to this by each client
Active state grade point is compared with given threshold respectively, obtains updated quantity n.
Step 103: according to updated quantity n, adjusting the client currently connected, and give each client adjusted
Distribute corresponding resource.
When discovery has the active state grade point of client to be greater than given threshold, main control end can be connected to the number of client
When measuring n to increase, and finding to have the active state grade point of client to be less than given threshold, main control end can be connected to the number of client
It measures n to reduce, in that way it is possible to which some clients are not connect with main control end, alternatively, needing to increase newly has client to connect with main control end
, thus, according to updated quantity n, the client currently connected is adjusted, and corresponding to each client distribution adjusted
Resource.
In the embodiment of the present invention, main control end connects client according to the active state grade of each client to update
Quantity n, and corresponding client is adjusted, corresponding resource is distributed to each client adjusted.Main control end is no longer and consolidates
Determine the client connection of number, but when the client of connection is relatively enlivened, the client number of connection is increased, connection is worked as
Client it is inactive when, then the client number of connection is reduced, in this way, main control end can be visitor according to different connection quantity
Internet resources are distributed at family end, can utilize Internet resources to large extent, do not easily cause the idle of Internet resources, are reasonably assigned with
Resource.
Certainly, in one embodiment of the invention, if there is client to be actively disconnected the connection with main control end, or there is newly-increased visitor
Family end is actively connected to main control end, in this way, the quantity n of main control end connection client can have update, therefore, according to updated
Quantity n, before adjusting the client that currently connects, further includes: the connection status of main control end is detected, if detecting in local area network has
When newly-increased client is connect with main control end, quantity n is added 1, if detecting the first client in the client connecting with main control end
When disconnecting the connection with main control end, quantity n is subtracted 1.
Embodiment two in the present embodiment, there is multiple client in local area network, wherein main control end currently with 10 clients
Connection, such as: in the local area network constituted in class, the main control end of teacher's manipulation is connected with the client that 10 students manipulate.
Referring to fig. 2, the process of resource allocation includes: in local area network in the present embodiment
Step 201: according to the state of activation of control window corresponding with each client, determining enlivening for each client
State grade.
Control window corresponding with each client of connection is shown in main control end, as teacher or other manipulators
When choosing one or more control windows, selected control window is just activated, and in activation selected state, generally emerges
In the forefront at interface.And other remaining control windows are not activated then, are in un-activation selected state.
At this point, if currently control window is in activation selected state, it is determined that the currently corresponding existing customer of control window
The active state grade at end is most to enliven grade;If currently control window is in un-activation selected state, it is determined that current control
The active state grade of the corresponding active client of window is inactive grade.
Step 202: according to the active state grade of each client, updating the quantity n of connection client.
In above-mentioned steps, it has been determined that the active state grade of each client, selected control window are corresponding
Client is in and most enlivens grade, and the corresponding client of other not selected control windows is in inactive grade.In this way,
It can be according to the active state grade of preservation and the corresponding relationship of active state grade point, the determining active state with each client
Then the corresponding active state grade point of grade carries out the active state grade point of each client with given threshold respectively
Compare, the quantity n of connection client is updated according to comparison result.
The corresponding relationship of preservation is as shown in table 2, threshold value 2, in this way, when control window is selected, at corresponding client
In most enlivening grade, corresponding active state grade point is 5, is greater than threshold value 2, at this point, quantity n is added 1, if n=10, more
N after new is 11.When control window is not selected, corresponding client is in inactive grade, corresponding active state etc.
Grade value is 1, is less than threshold value 2, at this point, subtracting 1 for quantity n, if n=10, updated n is 9.According to this by the work of each client
Jump state grade value is compared with given threshold respectively, obtains updated quantity n.
Step 203: according to updated quantity n, adjusting the client currently connected, and give each client adjusted
Distribute corresponding resource.
After quantity n updates, presumable client is not connect with main control end, alternatively, needing to increase newly has client and master control
End is connected to, thus, according to updated quantity n, the client currently connected is adjusted, and to each client adjusted point
With corresponding resource.
It can be seen that, if selected control window is more, corresponding more client is active, then main control end energy in this implementation
The client of connection is more, and not selected control window is more, and corresponding more client is inactive, then main control end can
It is not connect with these sluggish clients, thus, enable the client of connection to be assigned to more Internet resources, without
So that Internet resources are idle, Internet resources are reasonably distributed, Internet usage efficiency is improved.
Embodiment three in the present embodiment, there is multiple client in local area network, wherein main control end currently with 20 clients
Connection, such as: in the local area network constituted in class, the main control end of teacher's manipulation is connected with the client that 20 students manipulate.
Referring to Fig. 3, the process of resource allocation includes: in local area network in the present embodiment
Step 301: determining to control window pair with current according to the size state of control window corresponding with each client
The active state grade for the active client answered.
Control window corresponding with each client, the incomplete phase few greatly of each control window are shown in main control end
Together.Such as: teacher or other manipulators widen a control window, so that the control window is greater than other all controls
Window processed, alternatively, teacher or other manipulators minimize a control window, then the control window is all less than other
Control window.
As it can be seen that the control window shown in main control end is of different sizes, some control windows are big, and some control windows
It is small, in this way, determining active client corresponding with current control window enlivens shape according to the size state of current control window
State grade.Specifically can include: if currently control window is in maximum rating, it is determined that current to control the corresponding existing customer of window
The active state grade at end is most to enliven grade;If currently control window is in minimum state, it is determined that current control window pair
The active state grade for the active client answered is inactive grade.Certainly, others control window can be determined as secondary active
Grade.Alternatively, each control window is ranked up according to size, the corresponding client of maximum control window is enlivened into shape
State grade is determined as enlivening grade M, the active state grade of the secondary big corresponding client of control window is determined as active etc.
Grade M-1, and so on, it is determined as the active state grade of the corresponding client of the smallest control window to enliven grade 1.This
In, M is the integer less than or equal to 20.
Step 302: according to the active state grade of each client, updating the quantity n of connection client.
Equally, it has been determined that the active state grade of each client, the corresponding client of maximum control window are in
Most enliven grade, the corresponding client of secondary big control window, which is in, time enlivens grade, and so on, minimum control window is corresponding
Client is in inactive grade, and corresponding active state grade point is also different.It equally, can be according to the active state etc. of preservation
The corresponding relationship of grade and active state grade point determines active state grade corresponding with the active state grade of each client
Value, then, the active state grade point of each client is compared with given threshold respectively, is updated and is connected according to comparison result
Meet the quantity n of client.
The corresponding relationship of preservation is as shown in table 1, threshold value 5, in this way, the corresponding client of maximum control window is in most living
Jump grade, and corresponding active state grade point is 18, is greater than threshold value 5, at this point, quantity n is added 1, if n=10, after updating
N be 11.The corresponding client of control window that size is in centre is in centre and enlivens grade, corresponding active state etc.
Grade value is 4, is less than threshold value 5, at this point, subtracting 1 for quantity n, if n=10, updated n is 9.According to this by the work of each client
Jump state grade value is compared with given threshold respectively, obtains updated quantity n.
Step 303: according to updated quantity n, adjusting the client currently connected, and give each client adjusted
Distribute corresponding resource.
After quantity n updates, presumable client is not connect with main control end, alternatively, needing to increase newly has client and master control
End is connected to, thus, according to updated quantity n, the client currently connected is adjusted, and to each client adjusted point
With corresponding resource.
As it can be seen that the larger corresponding client of control window is more active, and smaller control window in this implementation
Corresponding client is more inactive, and corresponding more client is inactive, then main control end can not be with these sluggish visitors
The connection of family end, thus, enable the client of connection to be assigned to more Internet resources, without making Internet resources idle,
Internet resources are reasonably distributed, Internet usage efficiency is improved.
Example IV can construct resource allocation in a kind of local area network according to the process of resource allocation in above-mentioned local area network
Device, local area network include a main control end and at least one client, wherein main control end is connect with n client, and n is big
In the integer for being equal to 1, as shown in figure 4, the device includes: to comprise determining that unit 410, updating unit 420 and adjustment allocation unit
430, wherein
Determination unit 410 is connect with updating unit 420, for according to control window corresponding with each client of connection
Status information, determine the active state grade of each client.
Updating unit 420 is connect, for according to each client respectively with determination unit 410 and adjustment allocation unit 430
Active state grade, update connection client quantity n.
Allocation unit 430 is adjusted, is connect with updating unit 420, for adjusting current connection according to updated quantity n
Client, and distribute corresponding resource to each client adjusted.
In one embodiment of the invention, determination unit 410, if being specifically used for current control window is in activation selected state,
The active state grade for then determining the corresponding active client of current control window is most to enliven grade, if currently at control window
In un-activation selected state, it is determined that the current active state grade for controlling the corresponding active client of window is inactive etc.
Grade;Or, if currently control window is in maximum rating, it is determined that the current active state for controlling the corresponding active client of window
Grade is most to enliven grade, if currently control window is in minimum state, it is determined that current to control the corresponding existing customer of window
The active state grade at end is inactive grade.
In one embodiment of the invention, updating unit 420 includes:
First module, for the corresponding relationship according to the active state grade of preservation and active state grade point, determine with
The corresponding active state grade point of the active state grade of each client.
Second module, for the active state grade point of each client to be compared with given threshold respectively, according to
Comparison result updates the quantity n of connection client.
In one embodiment of the invention, the second module, if specifically for active client active state grade point be greater than set
When determining threshold value, quantity n is added 1, if the active state grade point of active client is less than given threshold, quantity n is subtracted 1.
In one embodiment of the invention, device should further include: detection updating unit, for detecting the connection status of main control end,
If detecting in local area network when thering is newly-increased client to connect with main control end, quantity n is added 1, is connect if detecting with main control end
When the first client disconnects the connection with main control end in client, quantity n is subtracted 1.
The device of resource allocation can be applied in the main control end of local area network in local area network in the embodiment of the present invention.
As it can be seen that in the embodiment of the present invention in local area network the device of resource allocation according to each client being connect with main control end
Active state grade, adjustment main control end currently connects the quantity of client, and corresponding for each client distribution adjusted
Resource, in this way, main control end is connect with the client of fixed number, but when the client of connection is relatively enlivened,
The client number of connection is increased, when the client of connection is inactive, is then reduced the client number of connection, in this way,
Main control end can be that client distributes Internet resources according to different connection quantity, can utilize Internet resources to large extent, be not easy
The idle of Internet resources is caused, resource is reasonably assigned with.
It should be understood by those skilled in the art that, the embodiment of the present invention can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the present invention
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the present invention, which can be used in one or more,
The shape for the computer program product implemented in usable storage medium (including but not limited to magnetic disk storage and optical memory etc.)
Formula.
The present invention be referring to according to the method for the embodiment of the present invention, the process of equipment (system) and computer program product
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Obviously, various changes and modifications can be made to the invention without departing from essence of the invention by those skilled in the art
Mind and range.In this way, if these modifications and changes of the present invention belongs to the range of the claims in the present invention and its equivalent technologies
Within, then the present invention is also intended to include these modifications and variations.