Invention content
One purpose of the embodiment of the present invention is to provide a kind of network speed limit method, device and server, can make each application
Balanced tenancy bandwidth is accessed, optimization accesses quality.
In a first aspect, an embodiment of the present invention provides a kind of network speed limit method, the method is applied to server, described
Server is connect with other at least one server communications, the server as portal server, the method includes:
Receive the request message that client is sent;
Obtain the communication path information of the request message and the first speed limit threshold value and the second speed limit threshold value;
It is established and connected according to the communication path information and Next Hop Server, be described according to the first speed limit threshold value
Portal server sets speed limit threshold value, so that the data uploading rate by the portal server is less than the first speed limit threshold
Value;
The second speed limit threshold value is added in into the request message, and the request message is sent to next-hop service
Device.
Second aspect, the embodiment of the present invention additionally provide a kind of network speed limit method, and the method for limiting speed is applied to service
Device, the server are connect with other at least one server communications, and the server is as output port server, the method packet
It includes:
Receive the request message of other servers transmission;
The request message is parsed, obtains the second speed limit threshold value;
Speed limit threshold value is set for the output port server according to the second speed limit threshold value, so that by the output port server
Data downloading speed be less than the second speed limit threshold value.
The third aspect, the embodiment of the present invention additionally provide a kind of network speed limit device, and described device is applied to server, institute
It states server to connect with other at least one server communications, the server includes as portal server, described device:
First receiving module, for receiving the request message of client transmission;
Acquisition module, for obtaining the communication path information of the request message and the first speed limit threshold value and the second limit
Fast threshold value;
First setup module connects for being established according to the communication path information and Next Hop Server, according to described
First speed limit threshold value sets speed limit threshold value for the portal server, so that the data uploading rate by the portal server is small
In the first speed limit threshold value;
Sending module for the second speed limit threshold value to be added in the request message, and the request message is sent
To Next Hop Server.
Fourth aspect, the embodiment of the present invention additionally provide a kind of network speed limit device, and the speed-limiting device is applied to service
Device, the server are connect with other at least one server communications, and the server is as output port server, described device packet
It includes:
Second receiving module, for receiving the request message of other servers transmission;
Parsing module for parsing the request message, obtains the second speed limit threshold value;
Second setup module, for setting speed limit threshold value for the output port server according to the second speed limit threshold value, with
Make to be less than the second speed limit threshold value by the data downloading speed of the output port server.
5th aspect, the embodiment of the present invention additionally provide a kind of server, including:
At least one processor;And
The memory being connect at least one processor communication;Wherein,
The memory is stored with the instruction that can be performed by least one processor, and described instruction is by described at least one
A processor performs, so that at least one processor is able to carry out above-mentioned method.
Method for limiting speed provided in an embodiment of the present invention, device and server pass through and obtain the first speed limit threshold value and the second limit
Fast threshold value, and speed limit threshold value is set for portal server according to the first speed limit threshold value, to limit uplink traffic bandwidth.And by
Two speed limit threshold values add in request message and are sent to Next Hop Server, so that output port server can be obtained by analysis request message
Second speed limit threshold value, and speed limit threshold value is set for output port server according to the second speed limit threshold value, to limit downlink traffic bandwidth.From
And enable each application access balanced tenancy bandwidth, improve access quality.
Specific embodiment
Purpose, technical scheme and advantage to make the embodiment of the present invention are clearer, below in conjunction with the embodiment of the present invention
In attached drawing, the technical solution in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
Part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
All other embodiments obtained without creative efforts shall fall within the protection scope of the present invention.
Network speed limit method and device provided by the invention are suitable for application scenarios shown in FIG. 1, including at least two clothes
Business device 20, at least two servers 20 are communicatively connected to each other, any one server 20 at least two servers 20 and control
Device 10 processed communicates to connect.In at least two servers 20, what is connect with client communication is known as portal server, is serviced with source station
Device communication connection is known as output port server.If there is the server 20 of three or more, then other servers 20 are as intermediate
Server is responsible for the forwarding data packets between portal server and output port server.Wherein, appoint for different data transmissions
Business, each server 20 is possibly as any one of portal server, intermediate server and output port server role.
For controller 10 for being managed between transmission path of the data packet each server 20, controller 10 can be advance
Communication path is obtained, and the communication path is sent to corresponding portal server.Portal server is according to the communication lines
Request of data message is sent to source station server by diameter by intermediate server and output port server.Controller 10 is additionally operable to send
To portal server, portal server is portal server according to the first speed limit threshold value for first speed limit threshold value and the second speed limit threshold value
Speed limit threshold value is set, to limit data uploading rate (i.e. uplink traffic bandwidth).Portal server also seals the second speed limit threshold value
It is attached in request message, and request message is sent to output port server by intermediate server.Output port server analysis request
Message obtains the second speed limit threshold value, and sets speed limit threshold value for output port server according to the second speed limit threshold value, to limit under data
Carry rate (i.e. downlink traffic bandwidth).So as to enable each application access balanced tenancy bandwidth, access quality is improved.
Network speed limit method provided in an embodiment of the present invention can be performed, such as Fig. 2 by any server 20 shown in Fig. 1
It is shown, it is the flow chart of one embodiment of the method for limiting speed, when the server 20 is as portal server, the limit
Fast method includes:
101:Receive the request message that client is sent.
102:Obtain the communication path information of the request message and the first speed limit threshold value and the second speed limit threshold value.
It in practical applications, can be by controller 10 by communication path information, the first speed limit threshold value and the second speed limit threshold value
Portal server is sent to, controller 10 can be obtained beforehand through such as Routing Algorithm and be taken by the portal server to source station
The preferred path of business device, is then sent to corresponding portal server by the communication path information of the preferred path.It is logical according to this
Believe routing information, the address information of such as Next Hop Server and the ground of port information and remaining jump server can be obtained
Location information and port information etc..Wherein, address information such as IP (agreement interconnected between network, Internet Protocol)
Address, port information such as port numbers.
103:It is established and connected according to the communication path information and Next Hop Server, be according to the first speed limit threshold value
The portal server sets speed limit threshold value, so that the data uploading rate by the portal server is less than first speed limit
Threshold value.
In practical applications, communication construction shown in Fig. 3 can be used between two servers (in the figure portal server and to go out
Intermediate server is omitted between mouthful server), fe-sk represents front end socket in Fig. 3, and be-sk represents rear end socket, wherein
The front end socket of portal server is responsible for and client communication, rear end socket are responsible for communicating with Next Hop Server, outlet
The front end socket of server is responsible for being responsible for and source station server communication with upper hop server communication, rear end socket.
Wherein, portal server and Next Hop Server are established and connected, can believed according to the address of Next Hop Server
Breath and port information create rear end socket, and rear end socket and Next Hop Server are established and connected.For it is described enter it is oral
Business device setting speed limit threshold value can be set by the rear end socket for portal server or front end socket and rear end socket
Speed limit threshold values is put to realize.By taking linux system as an example, portal server, each intermediate server and output port server are opened
After portal server receives the first speed limit threshold value, speed limit is set according to the first speed limit threshold value for rear end socket for Fair Queue
Threshold value.In practical application, setsockopt () function pair rear end socket setting speed limit threshold value can be called.
When the data uploading rate (uplink traffic bandwidth) of client reaches the first speed limit threshold value set, enter oral
The rear end socket (socket to communicate with Next Hop Server) of business device can be sent according to the speed limit threshold value set
Rate-shaping, i.e., to data transmission rate speed limit, so as to limit the uploading rate of the client network connection.
104:The second speed limit threshold value is added in into the request message, and the request message is sent to next-hop clothes
Business device.
Before second speed limit threshold value is added in the request message, first the second speed limit threshold value can be assisted based on global path
View (Global Routing Protocol, GRP) is packaged, and GRP is based on binary stream, and GRP is carried out to communication path information
Encapsulation, can effectively shorten data segment, length, improve the utilization rate of network bandwidth.
Fig. 4 shows a kind of form of GRP forms, and GRP forms include head+data portion, and head portion includes 8 bytes
Version number (Version), 2 byte information types (MsgType), 2 byte data stream length (Datalen), data portion includes
The variable data flow of byte (Data Stream).The specific form of data portion please refers to Fig. 5, including option cell and multiple
Address location, each address location can be used for placing the address information of a server 20, and the second speed limit threshold value can place
In option cell.The specific form of option cell please refers to Fig. 6, including 4 byte path ID, 4 byte times stamp, 4 byte meetings
Talk about ID, 4 byte-thresholds.Wherein, the value of the second speed limit threshold value is placed in 4 byte-threshold sections.
The embodiment of the present invention by obtaining the first speed limit threshold value and the second speed limit threshold value, and according to the first speed limit threshold value be into
Mouth server setting speed limit threshold value, to limit uplink traffic bandwidth.And the second speed limit threshold value addition request message is sent to
Next Hop Server, so that output port server can obtain the second speed limit threshold value, and according to the second speed limit by analysis request message
Threshold value sets speed limit threshold value for output port server, to limit downlink traffic bandwidth.So as to enable each application access balanced tenancy band
Width improves access quality.
It should be noted that serial number in the embodiment of the present invention only to facilitate understand, does not limit the elder generation of each step
Sequence afterwards.
The embodiment of the present invention additionally provides a kind of network speed limit method, can be performed by any server 20 shown in Fig. 1,
As shown in fig. 7, the flow chart of one embodiment for the method for limiting speed, when the server is as output port server, institute
The method of stating includes:
201:Receive the request message of other servers transmission.
202:The request message is parsed, obtains the second speed limit threshold value.
Wherein, intermediate server is not handled the second speed limit threshold value in request message, when output port server receives
During to portal server or the request message of intermediate server transmission, parse the request message and obtain the second speed limit threshold value.
203:According to the second speed limit threshold value for the output port server set speed limit threshold value so that by this go out it is oral
The data downloading speed of business device is less than the second speed limit threshold value.
Communication construction between two servers please refers to Fig. 3, sets speed limit threshold value that can pass through for the output port server
Front end socket or front end socket and rear end socket for output port server set speed limit threshold values to realize.With Linux
For system, after output port server receives the second speed limit threshold value, speed limit is set for front end socket according to the second speed limit threshold value
Threshold value.In practical application, setsockopt () function pair front end socket setting speed limit threshold value can be called.
When the data downloading speed (i.e. downlink traffic bandwidth) of client reaches the second speed limit threshold value set, outlet
The front end socket (i.e. with the socket of upper hop server communication) of server can carry out sending speed according to the threshold value set
Rate shaping, i.e., rate speed limit data sent, so as to limit the downloading rate of the client network connection.
The embodiment of the present invention is by receiving the request message that other servers are sent and obtaining from request message the
Two speed limit threshold values, and speed limit threshold value is set for output port server according to the second speed limit threshold value, to limit downlink traffic bandwidth.When entering
Mouthful server and output port server limit uplink traffic bandwidth with after downlink traffic bandwidth, portal server and going out oral respectively
Business device between multistage network connection bandwidth be obtained for speed limit, bursts of traffic will not be caused, so as to avoid causing shake and
The unstability of acceleration.It is it should be noted that above-mentioned primary to being operated when being arranged on and creating socket for speed limit threshold values.
It should be noted that serial number in the embodiment of the present invention only to facilitate understand, does not limit the elder generation of each step
Sequence afterwards.
Correspondingly, the embodiment of the present invention additionally provides a kind of network speed limit device, the speed-limiting device is for shown in FIG. 1
Any server 20, the server is as portal server, as shown in figure 8, described device 300 includes:
First receiving module 301, for receiving the request message of client transmission.
Acquisition module 302, for obtaining the communication path information of the request message and the first speed limit threshold value and second
Speed limit threshold value.
First setup module 303 connects for being established according to the communication path information and Next Hop Server, according to institute
It states the first speed limit threshold value and speed limit threshold value is set for the portal server, so that the data uploading rate by the portal server
Less than the first speed limit threshold value.
Sending module 304 for the second speed limit threshold value to be added in the request message, and the request message is sent out
Give Next Hop Server.
The embodiment of the present invention by obtaining the first speed limit threshold value and the second speed limit threshold value, and according to the first speed limit threshold value be into
Mouth server setting speed limit threshold value, to limit uplink traffic bandwidth.And the second speed limit threshold value addition request message is sent to
Next Hop Server, so that output port server can obtain the second speed limit threshold value, and according to the second speed limit by analysis request message
Threshold value sets speed limit threshold value for output port server, to limit downlink traffic bandwidth.So as to enable each application access balanced tenancy band
Width improves access quality.
Optionally, in the other embodiment of described device, Fig. 9 is please referred to, device 300 further includes:
First opening module 305, for opening Fair Queue
First setup module 303, is specifically used for:
Rear end socket is created according to the address information of Next Hop Server and port information, and by the rear end socket
It establishes and connects with Next Hop Server, speed limit threshold value is set for the rear end socket according to the first speed limit threshold value.
Optionally, in the other embodiment of described device, the second speed limit threshold value is positioned over described ask with GRP forms
It asks in message, the GRP forms are based on binary stream, and the GRP forms include head and data portion, the data portion subpackage
Option cell and address location are included, the second speed limit threshold values is positioned in the option cell.
It should be noted that above-mentioned speed-limiting device can perform the method for limiting speed that the embodiment of the present invention is provided, has execution
The corresponding function module of method and advantageous effect.The technical detail of detailed description not in speed-limiting device embodiment, reference can be made to this
The method for limiting speed that inventive embodiments are provided.
Correspondingly, the embodiment of the present invention additionally provides a kind of network speed limit device, the speed-limiting device is for shown in FIG. 1
Any server 20, when the server is used for output port server, as shown in Figure 10, described device 400 includes:
Second receiving module 401, for receiving the request message of other servers transmission;
Parsing module 402 for parsing the request message, obtains the second speed limit threshold value;
Second setup module 403, for setting speed limit threshold value for the output port server according to the second speed limit threshold value,
So that the data downloading speed by the output port server is less than the second speed limit threshold value.
The embodiment of the present invention is by receiving the request message that other servers are sent and obtaining from request message the
Two speed limit threshold values, and speed limit threshold value is set for output port server according to the second speed limit threshold value, to limit downlink traffic bandwidth.When entering
Mouthful server and output port server limit uplink traffic bandwidth with after downlink traffic bandwidth, portal server and going out oral respectively
Business device between multistage network connection bandwidth be obtained for speed limit, bursts of traffic will not be caused, so as to avoid causing shake and
The unstability of acceleration.
Optionally, in the other embodiment of described device, Figure 11 is please referred to, device 400 further includes:
Second opening module 404, for opening Fair Queue;
Second setup module 403 is specifically used for:
Speed limit threshold value is set according to front end socket of the second speed limit threshold value for the output port server.
It should be noted that above-mentioned speed-limiting device can perform the method for limiting speed that the embodiment of the present invention is provided, has execution
The corresponding function module of method and advantageous effect.The technical detail of detailed description not in speed-limiting device embodiment, reference can be made to this
The method for limiting speed that inventive embodiments are provided.
Figure 12 is the hardware architecture diagram of server 20 provided in an embodiment of the present invention, as shown in figure 12, the server
20 include:
One or more processors 21 and memory 22, in Figure 12 by taking a processor 21 as an example.
Processor 21 can be connected with memory 22 by bus or other modes, to be connected as by bus in Figure 12
Example.
Memory 22 is used as a kind of non-volatile computer readable storage medium storing program for executing, available for storing non-volatile software journey
Sequence, non-volatile computer executable program and module, as the corresponding program instruction of method for limiting speed in the embodiment of the present invention/
Module (for example, attached second receiving module 401 shown in Fig. 10,402 and second setup module 403 of parsing module).Processor 21
Non-volatile software program, instruction and the module being stored in by operation in memory 22, so that execute server is various
The method for limiting speed of above method embodiment is realized in application of function and data processing.
Memory 22 can include storing program area and storage data field, wherein, storing program area can storage program area,
At least one required application program of function;Storage data field can be stored uses created data according to speed-limiting device
Deng.In addition, memory 22 can include high-speed random access memory, nonvolatile memory can also be included, for example, at least
One disk memory, flush memory device or other non-volatile solid state memory parts.In some embodiments, memory 22
It is optional including relative to the remotely located memory of processor 21, these remote memories can pass through network connection to speed limit and fill
It puts.The example of above-mentioned network includes but not limited to internet, intranet, LAN, mobile radio communication and combinations thereof.
One or more of modules are stored in the memory 22, when by one or more of processors 21
During execution, the method for limiting speed in above-mentioned any means embodiment is performed, for example, performing the method and step in Fig. 2 described above
Method and step 201 in 101-104, Fig. 7 is to step 203;Realize the module 301- in module 301-304, Fig. 9 in Fig. 8
305th, the function of the module 401-404 in Figure 10 in module 401-403, Figure 11.
The said goods can perform the method that the embodiment of the present invention is provided, and has the corresponding function module of execution method and has
Beneficial effect.The not technical detail of detailed description in the present embodiment, reference can be made to the method that the embodiment of the present invention is provided.
An embodiment of the present invention provides a kind of non-volatile computer readable storage medium storing program for executing, the computer-readable storage mediums
Matter is stored with computer executable instructions, which is executed by one or more processors, such as in Figure 12
A processor 21, may be such that said one or multiple processors can perform speed limit side in above-mentioned any means embodiment
Method, for example, performing method and step 201 in the method and step 101-104, Fig. 7 in Fig. 2 described above to step 203;It realizes
Module 401-404's in module 301-305, Figure 10 in module 301-304, Fig. 9 in Fig. 8 in module 401-403, Figure 11
Function.
The apparatus embodiments described above are merely exemplary, wherein the unit illustrated as separating component can
To be or may not be physically separate, the component shown as unit may or may not be physics list
Member, you can be located at a place or can also be distributed in multiple network element.It can be selected according to the actual needs
In some or all of module realize the purpose of this embodiment scheme.
Through the above description of the embodiments, those of ordinary skill in the art can be understood that each embodiment
The mode of general hardware platform can be added to realize by software, naturally it is also possible to pass through hardware.Those of ordinary skill in the art can
With understand all or part of flow realized in above-described embodiment method be can be instructed by computer program it is relevant hard
Part is completed, and the program can be stored in a computer read/write memory medium, the program is when being executed, it may include as above
State the flow of the embodiment of each method.Wherein, the storage medium can be magnetic disc, CD, read-only memory (Read-
Only Memory, ROM) or random access memory (Random Access Memory, RAM) etc..
Finally it should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;At this
It under the thinking of invention, can also be combined between the technical characteristic in above example or different embodiment, step can be with
It is realized with random order, and there are many other variations of different aspect present invention as described above, for simplicity, they do not have
Have and provided in details;Although the present invention is described in detail referring to the foregoing embodiments, the ordinary skill people of this field
Member should understand that:It can still modify to the technical solution recorded in foregoing embodiments or to which part skill
Art feature carries out equivalent replacement;And these modifications or replacement, each reality of the present invention that it does not separate the essence of the corresponding technical solution
Apply the range of a technical solution.