WO2016086542A1 - 一种传输报文的方法及装置、计算机存储介质 - Google Patents

一种传输报文的方法及装置、计算机存储介质 Download PDF

Info

Publication number
WO2016086542A1
WO2016086542A1 PCT/CN2015/073661 CN2015073661W WO2016086542A1 WO 2016086542 A1 WO2016086542 A1 WO 2016086542A1 CN 2015073661 W CN2015073661 W CN 2015073661W WO 2016086542 A1 WO2016086542 A1 WO 2016086542A1
Authority
WO
WIPO (PCT)
Prior art keywords
token
current
tokens
message
available
Prior art date
Application number
PCT/CN2015/073661
Other languages
English (en)
French (fr)
Inventor
申河卿
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016086542A1 publication Critical patent/WO2016086542A1/zh

Links

Images

Definitions

  • the present invention relates to the field of network service quality, and in particular, to a method and device for transmitting a message, and a computer storage medium.
  • token buckets are usually used to limit the traffic of a certain connection to a certain network.
  • the packet is classified according to the matching rule set in advance. If the packet does not have the specified traffic characteristics, the packet is directly sent and does not need to be processed by the token bucket; if it is a packet that needs to be controlled by the traffic, It will enter the token bucket for processing. If there are enough tokens in the token bucket to send packets, the packets are allowed to pass and the packets can continue to be sent. If the token in the token bucket does not meet the sending condition of the packet, the packet is discarded. In this way, the traffic of a certain type of packet can be controlled.
  • the above method is limited. Under the same traffic, for packets with a smaller message length, the number of messages is larger, and the time interval is shorter. Therefore, the number of newly added tokens in the token bucket is less, which can be ignored. At this time, if the token available in the token bucket is insufficient to send the packet, the packet will be If the packet with the smaller length is discarded, the packet will be discarded. This will affect the packet limit. Speed accuracy.
  • embodiments of the present invention are expected to provide a method and apparatus for transmitting a message, and calculating The machine stores media to improve the speed limit accuracy of the message.
  • an embodiment of the present invention provides a method for transmitting a message, where the method includes: determining, after the arrival of the current message, a token within a time interval between a last count value of the clock and a current count value. The number of newly added tokens in the bucket, where the current value is the timestamp of the current packet, and the last count value is the timestamp of the last arrived packet; when the new token is added When the number of the tokens is less than the minimum length of the preset packet, the number of available tokens in the token bucket is determined according to the current value of the used token and the capacity of the token bucket; when the number of available tokens is greater than When the length of the current message is equal to the length of the current message, the current message is sent, the last count value is kept unchanged, and the current value of the used token is updated.
  • the method further includes: when the available When the number of tokens is smaller than the length of the current packet, the current message is discarded, and the last count value and the current value of the used token are kept unchanged.
  • determining the number of available tokens in the token bucket according to the current value of the used token and the capacity of the token bucket including: the capacity of the token bucket
  • the difference between the current values of the used tokens is determined as the number of available tokens.
  • the method further includes: when the number of the newly added tokens is greater than or equal to a minimum length of the preset packets, according to the used Determining, by the current value of the token, the capacity of the token bucket, and the number of the newly added tokens, the number of available tokens; when the number of the available tokens is greater than or equal to the length of the current packet Transmitting the current message and updating the last count value and the current value of the used token; when the number of available tokens is less than the length of the current packet, discarding the The current message is described, and the last count value and the current value of the used token are updated.
  • the method further includes: when the number of available tokens is greater than or equal to the length of the current message, marking the current message as a green message; when the number of available tokens is less than the number When the length of the secondary packet is the same, the current packet is marked as a red packet.
  • an embodiment of the present invention provides an apparatus for transmitting a message, where the apparatus includes: a new token determining unit, an available token determining unit, and a message processing unit; wherein the newly added token determining unit And configured to determine, after the arrival of the current message, the number of new tokens in the token bucket within a time interval between the last count value of the clock and the current count value, where the current value is the number The timestamp of the secondary packet, the last count value is a timestamp of the last received packet; the available token determining unit is configured to: when the number of the newly added token is less than the minimum length of the preset packet The number of available tokens in the token bucket is determined according to the current value of the used token and the capacity of the token bucket.
  • the message processing unit is further configured to determine, at the available token determining unit, the available token according to a current value of the used token and a capacity of the token bucket. After the quantity, when the number of available tokens is less than the length of the current message, the current message is discarded, and the last count value and the current value of the used token are kept unchanged. .
  • the available token determining unit is configured to determine a difference between a capacity of the token bucket and a current value of the used token as the number of the available tokens;
  • the message processing unit is configured to update the current value of the used token to the difference value.
  • the available token determining unit is further configured to: after the newly added token determining unit determines the number of the newly added tokens, when the number of the newly added tokens is greater than or equal to the When the minimum length of the packet is preset, the number of the available tokens is determined according to the current value of the used token, the capacity of the token bucket, and the number of the newly added tokens;
  • the message processing unit is further configured to: when the number of the available tokens is greater than or equal to the length of the current message, send the current message, and update the last count value and the used order The current value of the card; when the number of available tokens is less than the length of the current message, discarding the current time The message, and updating the last count value and the current value of the used token.
  • the message processing unit is further configured to: after the available token determining unit determines the number of available tokens, when the number of available tokens is greater than or equal to the current packet When the length of the available packet is smaller than the length of the current packet, the current packet is marked as a red packet.
  • an embodiment of the present invention further provides a computer storage medium, wherein computer executable instructions are stored, the computer executable instructions being used to execute the foregoing method.
  • the method and device for transmitting a message and the computer storage medium provided in the embodiment of the present invention determine the newly added token generated in the time interval between the time stamps of the two messages before and after the arrival of the current message. Quantity, then, when the number of new tokens is less than the minimum length of the preset packet, the number of new tokens is ignored, and the number of currently available tokens is determined based only on the current value of the used token and the capacity of the token bucket. Then, when the number of available tokens is greater than or equal to the length of the current message, the current message is sent, and the last count value of the clock is not updated, but the current value of the used token is still updated.
  • the time interval is accumulated and accumulated one by one, and then generated in the time interval.
  • the number of newly added tokens is also increasing, which avoids the number of available tokens in the token bucket being discarded, which improves the rate limit of packets.
  • FIG. 1 is a schematic flowchart of a method for transmitting a message according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of a method for a gateway to transmit a message according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an apparatus for transmitting a message according to an embodiment of the present invention.
  • the embodiment of the present invention provides a method for transmitting a message, where the method is applied to a device for transmitting a message, and the device may be a network side device supporting a QoS technology, for example, a gateway, a base station, and an evolved base station (eNB, evolved) Node B) and so on.
  • a device for transmitting a message may be a network side device supporting a QoS technology, for example, a gateway, a base station, and an evolved base station (eNB, evolved) Node B) and so on.
  • eNB evolved base station
  • FIG. 1 is a schematic flowchart of a method for transmitting a message according to an embodiment of the present invention. Referring to FIG. 1, the method includes:
  • a timestamp is generated, which is the current value of the system clock.
  • another timestamp is generated.
  • the timestamp updates the clocked value of the clock.
  • the current value of the clock is the second timestamp, and the last counted value is the first timestamp. Therefore, after the current packet arrives, the network side device can calculate the time interval between the last count value of the clock and the current count value, and calculate the number of new tokens in the token bucket during the time interval. .
  • the unit For example, suppose the clock frequency of the network-side device is A, the unit is megabytes, the agreed access rate is CIR, the unit is kbps, CBS is the capacity of the token bucket, the unit is Byte, and UsedTokens is the number of used tokens, NewTokens To increase the number of tokens, the unit is Byte.
  • the difference between the current count value of the clock and the last count value last_tick is tmp_tick.
  • the length of the current packet is PLen, and the unit is Byte.
  • S102 When the number of newly added tokens is less than the minimum length of the preset packet, determine the number of available tokens in the token bucket according to the current value of the used token and the capacity of the token bucket.
  • the network operator can preset the minimum length of a packet according to the actual transmission condition of the network packet and the requirement of the network traffic monitoring accuracy of different services, for example, 64 Byte, 128 Byte, and the like.
  • the number of newly added tokens is less than the minimum length of the preset packet, it indicates that the number of newly added tokens is insufficient to send a packet. Then, at this time, the newly added token is ignored, and only the used token is used.
  • the current value and the capacity of the token bucket to determine the number of available tokens, that is, the difference between the capacity of the token bucket and the current value of the used token, determined as the number of available tokens.
  • the number of available tokens determined by S102 needs to be compared with the length of the current packet. In comparison, when the number of available tokens is greater than or equal to the length of the current message, the current message is sent, and the last count value of the clock is kept unchanged, that is, the last count value is updated without using the current count value of the clock.
  • the current value of the used token is updated by the number of used tokens after deducting the length of the current message; and when the number of available tokens is less than the length of the current packet, the current message is discarded, the same Ground, keep the last count value unchanged, and since the current message does not consume the available token, the current value of the used token is also kept unchanged.
  • the current packet when the number of available tokens is greater than or equal to the length of the current packet, the current packet is marked as a green packet; when the number of available tokens is less than the length of the current packet, the current report is The text is marked as a red message.
  • the method further includes: adding the number of tokens.
  • the minimum length of the preset packet is greater than or equal to the minimum length of the preset packet
  • the number of available tokens is determined according to the current value of the used token, the capacity of the token bucket, and the number of newly added tokens; when the number of available tokens is greater than or equal to the current report
  • the length of the text is sent, and the current count value and the current value of the used token are updated.
  • the current packet is discarded and updated. The current count value and the current value of the used token.
  • the network side device can increase the capacity of the token bucket.
  • the difference between the current value of the used token and the current value of the token is determined as the number of available tokens. Then, when the number of available tokens is greater than or equal to the length of the current packet, the packet is sent. And update the last count value with the current count value of the clock, and update the current value of the used token by subtracting the number of new tokens from the current value of the used token plus the length of the current message.
  • the number of available tokens is less than the length of the current packet, discard the current packet and update the last count value with the current count value of the clock, and subtract the new token from the current value of the used token.
  • the quantity updates the current value of the used token.
  • the number of used tokens UsedTokens 2, the unit is Byte.
  • FIG. 2 is a schematic flowchart of a method for a gateway to transmit a message according to an embodiment of the present invention. Referring to FIG. 2, the method includes:
  • NewTokens 50Byte ⁇ 64Byte
  • S203 Mark the current packet as a green packet, and send the current packet.
  • the S203 and the S204 may be executed simultaneously or sequentially, and the present invention is not specifically limited.
  • an embodiment of the present invention provides an apparatus for transmitting a message, the apparatus being consistent with the transmission message apparatus in one or more of the above embodiments.
  • FIG. 3 is a schematic structural diagram of an apparatus for transmitting a message according to an embodiment of the present invention.
  • the apparatus includes: a new token determining unit 31, an available token determining unit 32, and a packet processing unit 33;
  • the new token determining unit 31 is configured to determine, after the arrival of the current message, the number of newly added tokens in the token bucket during the time interval between the last count value and the last count value, where The current value is the timestamp of the current packet, and the last count is the timestamp of the last received packet;
  • the available token determining unit 32 is configured to when the number of newly added tokens is less than the minimum length of the preset packet.
  • the number of available tokens in the token bucket is determined according to the current value of the used token and the capacity of the token bucket.
  • the packet processing unit 33 is configured to: when the number of available tokens is greater than or equal to the length of the current packet Send this message, keep the last count value unchanged, and update the current value of the used token.
  • the message processing unit 33 is further configured to, after the available token determining unit 32 determines the number of available tokens based on the current value of the used token and the capacity of the token bucket, when the token is available If the number is smaller than the length of the current packet, discard the current packet and keep the current count value and the current value of the used token unchanged.
  • the available token determination unit 32 is configured to determine the difference between the capacity of the token bucket and the current value of the used token as the number of available tokens.
  • the available token determining unit 32 is further configured to: after the newly added token determining unit determines the number of newly added tokens, when the number of newly added tokens is greater than or equal to the minimum length of the preset packet, The current value of the token, the capacity of the token bucket, and the number of new tokens have been used to determine the number of available tokens;
  • the message processing unit 33 is further configured to: when the number of available tokens is greater than or equal to the length of the current message, send the current message, and update the last count value and the current value of the used token; When the number of available tokens is less than the length of the current packet, the current packet is discarded and the last count value and the current value of the used token are updated.
  • the message processing unit 33 is further configured to: after the available token determining unit determines the number of available tokens, when the number of available tokens is greater than or equal to the length of the current packet, the packet is sent. Marked as a green packet; when the number of available tokens is less than the length of the current packet, the current packet is marked as a red packet.
  • the new token determining unit 31, the available token determining unit 32, and the message processing unit 33 can all be disposed on the physical interface of the device that transmits the message.
  • the embodiment of the present invention further provides a computer storage medium, wherein computer executable instructions are stored, the computer executable instructions being used to execute the method described in any one of the foregoing method embodiments.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention can take the form of a hardware embodiment, a software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) including computer usable program code.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明实施例公开了一种传输报文的方法,所述方法包括:在本次报文到达后,确定在时钟的上一次计数值与当前计数值之间的时间间隔内令牌桶中新增令牌的数量,其中,所述当前数值为所述本次报文的时间戳,所述上一次计数值为上一次到达的报文的时间戳;当所述新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量;当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,保持所述时钟上一次计数值不变,并更新所述已用令牌的当前值。本发明同时还公开了一种传输报文的装置、计算机存储介质。

Description

一种传输报文的方法及装置、计算机存储介质 技术领域
本发明涉及网络服务质量领域,尤其涉及一种传输报文的方法及装置、计算机存储介质。
背景技术
随着IP网络上新应用的不断出现,服务质量(QoS,Quality of Service)提供的流量监管(Traffic Policing)中,通常采用令牌桶来限制进入某一网络的某一连接的流量。首先,根据预先设置的匹配规则来对报文进行分类,如果是没有规定流量特性的报文,就直接继续发送,并不需要经过令牌桶的处理;如果是需要进行流量控制的报文,则会进入令牌桶中进行处理。如果令牌桶中有足够的令牌可以用来发送报文,则允许报文通过,报文可以被继续发送下去。如果令牌桶中的令牌不满足报文的发送条件,则报文被丢弃。这样,就可以对某类报文的流量进行控制。
但是,对于寄存器只有32位的设备来说,上述方法就受到了限制,在同样的流量下面,对于报文长度较小的报文,报文的个数就比较多,其时间间隔就短,使得在该时间将内令牌桶中的新增的令牌数量较少,几乎可以不计,那么,此时,如果令牌桶中可用令牌不足以发送该报文的话,该报文就会被丢弃,下一个长度较小的报文也会遭遇同样的情况,依此类推,如果连续发送的都是长度较小的报文,就会导致报文一直被丢弃,影响对于报文的限速精度。
发明内容
有鉴于此,本发明实施例期望提供一种传输报文的方法及装置、计算 机存储介质,以提高对报文的限速精度。
为达到上述目的,本发明的技术方案是这样实现的:
第一方面,本发明实施例提供一种传输报文的方法,所述方法包括:在本次报文到达后,确定在时钟的上一次计数值与当前计数值之间的时间间隔内令牌桶中新增令牌的数量,其中,所述当前数值为所述本次报文的时间戳,所述上一次计数值为上一次到达的报文的时间戳;当所述新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量;当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,保持所述上一次计数值不变,并更新所述已用令牌的当前值。
一具体实施例中,在所述根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量之后,所述方法还包括:当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并保持所述上一次计数值和所述已用令牌的当前值不变。
一具体实施例中,所述根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量,包括:将所述令牌桶的容量与所述已用令牌的当前值之间的差值,确定为所述可用令牌的数量。
一具体实施例中,在所述确定新增令牌的数量之后,所述方法还包括:当所述新增令牌的数量大于等于所述预设报文最小长度时,根据所述已用令牌的当前值、所述令牌桶的容量以及所述新增令牌的数量,确定所述可用令牌的数量;当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值;当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值。
一具体实施例中,在所述确定所述令牌桶中可用令牌的数量之后,所 述方法还包括:当所述可用令牌的数量大于等于所述本次报文的长度时,将所述本次报文标记成绿色报文;当所述可用令牌的数量小于所述本次报文的长度时,将所述本次报文标记为红色报文。
第二方面,本发明实施例提供一种传输报文的装置,所述装置包括:新增令牌确定单元、可用令牌确定单元以及报文处理单元;其中,所述新增令牌确定单元,配置为在本次报文到达后,确定在时钟的上一次计数值与当前计数值之间的时间间隔内令牌桶中新增令牌的数量,其中,所述当前数值为所述本次报文的时间戳,所述上一次计数值为上一次到达的报文的时间戳;所述可用令牌确定单元,配置为当所述新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量。
一具体实施例中,所述报文处理单元,还配置为在所述可用令牌确定单元根据所述已用令牌的当前值和所述令牌桶的容量,确定所述可用令牌的数量之后,当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并保持所述上一次计数值和所述已用令牌的当前值不变。
一具体实施例中,所述可用令牌确定单元配置为将所述令牌桶的容量与所述已用令牌的当前值之间的差值,确定为所述可用令牌的数量;相应地,所述报文处理单元,配置为将所述已用令牌的当前值更新为所述差值。
一具体实施例中,所述可用令牌确定单元,还配置为在所述新增令牌确定单元确定所述新增令牌的数量之后,当所述新增令牌的数量大于等于所述预设报文最小长度时,根据所述已用令牌的当前值、所述令牌桶的容量以及所述新增令牌的数量,确定所述可用令牌的数量;相应地,所述报文处理单元,还配置为当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值;当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次 报文,并更新所述上一次计数值和所述已用令牌的当前值。
一具体实施例中,所述报文处理单元,还配置为在所述可用令牌确定单元确定所述可用令牌的数量之后,当所述可用令牌的数量大于等于所述本次报文的长度时,将所述本次报文标记成绿色报文;当所述可用令牌的数量小于所述本次报文的长度时,将所述本次报文标记为红色报文。
第三方面,本发明实施例还提供一种计算机存储介质,其中存储有计算机可执行指令,所述计算机可执行指令用于执行上述的方法。
本发明实施例中所提供的传输报文的方法及装置、计算机存储介质,在本次报文到达后,确定出前后两次报文时间戳之间的时间间隔内生成的新增令牌的数量,然后,在新增令牌的数量小于预设报文最小长度时,忽略新增令牌的数量,仅根据已用令牌的当前值以及令牌桶的容量确定当前可用令牌的数量,然后,在可用令牌数量大于等于本次报文长度时,发送本次报文,同时,不更新时钟的上一次计数值,但是仍更新已用令牌的当前值。如此,当到达令牌桶的一直是报文长度较小的报文时,由于时钟上一次计数值一直不变,使得上述时间间隔一点一点累计变长,那么,在该时间间隔内生成的新增令牌的数量也在不断增长,避免了由于令牌桶中可用令牌数量不足导致报文一致被丢弃,提高对报文的限速精度。
附图说明
图1为本发明实施例中的传输报文的方法流程示意图;
图2为本发明实施例中的网关进行传输报文的方法流程示意图;
图3为本发明实施例中的传输报文的装置结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。
本发明实施例提供一种传输报文的方法,该方法应用于一传输报文的装置中,该装置可以为支持QoS技术的网络侧设备,比如,网关、基站、演进型基站(eNB,evolved Node B)等。
图1为本发明实施例中的传输报文的方法流程示意图,参照图1所示,该方法包括:
S101:在本次报文到达后,确定在时钟的上一次计数值与当前计数值之间的时间间隔内令牌桶中新增令牌的数量,其中,当前数值为本次报文的时间戳,上一次计数值为上一次到达的报文的时间戳;
具体来说,当报文到达网络侧设备的物理端口时,会生成一时间戳,该时间戳即为系统时钟的当前值,当下一个报文到达物理端口时,会生成另一个时间戳,使用该时间戳更新时钟的计时值,此时,时钟的当前值就为第二个时间戳,上一次计数值则为第一个时间戳。所以,在本次报文到达后,网络侧设备可以计算出时钟的上一次计数值和当前计数值之间的时间间隔,进而计算出在该时间间隔内令牌桶中新增令牌的数量。
举例来说,假设网络侧设备的时钟频率为A,单位为兆,约定访问速率为CIR,单位为kbps,CBS为令牌桶的容量,单位为Byte,UsedTokens为已用令牌的数量,NewTokens为新增令牌的数量,单位为Byte,时钟的当前计数值cur_tick与上一次计数值last_tick之差为tmp_tick,本次报文的长度为PLen,单位为Byte。
那么,本次报文到达后,网络侧设备获取时钟的上一次计数值last_tick以及当前计数值cur_tick,然后,计算本次报文和上次报文之间的时间间隔T=tmp_tick/(A×106),接下来,确定新增令牌的数量New Tokens=CIR×103×T÷8。
S102:当新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和令牌桶的容量,确定令牌桶中可用令牌的数量;
具体来说,网络运营商可以根据网络报文实际的传输情况以及不同业务的对网络流量监控精度的需求,预先设置一报文最小长度,比如,64Byte、128Byte等。当新增令牌的数量小于上述预设报文最小长度时,就说明新增令牌的数量不足以发送一个报文,那么,此时,就忽略新增令牌,仅通过已用令牌的当前值和令牌桶的容量,来确定可用令牌的数量,即将令牌桶的容量与已用令牌的当前值之间的差值,确定为可用令牌的数量。
比如,确定NewTokens=CIR×103×T÷8≥64Byte时,可用令牌的数量AvailableTokens=CBS-UsedTokens。
S103:当可用令牌的数量大于等于本次报文的长度时,发送本次报文,保持上一次计数值不变,并更新已用令牌的当前值。
具体来说,因为之后当可用令牌的数量大于等于报文的长度时,报文才能够被发送,所以,就需要将通过S102确定出来的可用令牌的数量与本次报文的长度进行比较,当可用令牌的数量大于等于本次报文的长度时,发送本次报文,并保持时钟的上一次计数值不变,也就是说不使用时钟的当前计数值更新上一次计数值,但同时使用扣除本次报文长度后的已用令牌的数量更新已用令牌的当前值;而当可用令牌的数量小于本次报文的长度时,丢弃本次报文,同样地,保持上一次计数值不变,并且由于本次报文没有消耗可用令牌,此时也保持已用令牌的当前值不变。
例如,确定AvailableTokens是否大于等于本次报文的长度为PLen,若AvailableTokens≥PLen,此时,Last_Tick=Last_Tick,UsedToken=UsedToken+PLen;若AvailableTokens<PLen,此时,Last_Tick=Last_Tick,UsedToken=UsedToken。
可选地,当可用令牌的数量大于等于本次报文的长度时,将本次报文标记成绿色报文;当可用令牌的数量小于本次报文的长度时,将本次报文标记为红色报文。
在另一实施例中,通过S101确定新增令牌的数量之后,新增令牌的数量还可以大于等于预设报文最小长度,此时,上述方法还包括:当新增令牌的数量大于等于预设报文最小长度时,根据已用令牌的当前值、令牌桶的容量以及新增令牌的数量,确定可用令牌的数量;当可用令牌的数量大于等于本次报文的长度时,发送本次报文,并更新上一次计数值和已用令牌的当前值;当可用令牌的数量小于本次报文的长度时,丢弃本次报文,并更新上一次计数值和已用令牌的当前值。
具体来说,新增令牌的数量大于等于预设报文最小长度时,说明仅使用新增令牌就足以发送一个最小长度的报文,那么,网络侧设备就可以将令牌桶的容量与已用令牌的当前值之差再加上新增令牌的数量确定为可用令牌的数量,然后,当可用令牌的数量大于等于本次报文的长度时,发送本次报文,并使用时钟的当前计数值更新上一次计数值,同时,使用已用令牌的当前值减去新增令牌的数量再加上本次报文的长度来更新已用令牌的当前值;当可用令牌的数量小于本次报文的长度时,丢弃本次报文,并使用时钟的当前计数值更新上一次计数值,使用已用令牌的当前值减去新增令牌的数量来更新已用令牌的当前值。
比如,确定NewTokens=CIR×103×T÷8<64Byte时,可用令牌的数量AvailableTokens=CBS-UsedTokens+NewTokens,然后,当AvailableTokens≥PLen时,Last_Tick=cur_tick,Usedtoken=Usedtoken+PLen-NewTokens;当AvailableTokens<PLen时,Last_Tick=cur_tick,Usedtoken=Usedtoken–NewTokens。
下面以具体实例对上述一个或者多个实施例中所述的传输报文的过程进行说明。
假设,网络侧设备为网关,网关的时钟频率为A=5,单位为兆,约定访问速率为CIR=106,单位为kbps,令牌桶的容量为CBS=10,单位为Byte; 在本次报文到达前,已用令牌的数量UsedTokens=2,单位为Byte,本次到达时,时钟的当前计数值cur_tick=3,上一次计数值last_tick=1,本次报文的长度为PLen=5,单位为Byte。
图2为本发明实施例中的网关进行传输报文的方法流程示意图,参照图2所示,该方法包括:
S201:在本次报文到达后,确定出新增令牌NewTokens=50Byte;
此时,NewTokens=50Byte≤64Byte;
S202:确定可用令牌AvailableTokens=CBS-UsedTokens=8Byte;
此时,AvailableTokens≥PLen;
S203:将本次报文标记为绿色报文,并发送本次报文;
S204:保持last_tick=1,并更新UsedTokens=UsedTokens+PLen=7Byte。
在实际应用中,S203和S204可以同时执行,也可以先后执行,本发明不做具体限定。
至此,完成了传输报文的流程。
由上述可知,当到达令牌桶的一直是报文长度较小的报文时,由于时钟上一次计数值一直保持不变,使得上述时间间隔一点一点累计增长,相应地,在该时间间隔内生成的新增令牌的数量也在不断增长,这样就避免了由于令牌桶中可用令牌数量不足导致报文一致被丢弃,提高对报文的限速精度。
基于同一发明构思,本发明实施例提供一种传输报文的装置,该装置与上述一个或者多个实施例中的传输报文装置一致。
图3为本发明实施例中的传输报文的装置结构示意图,参照图3所示,该装置包括:新增令牌确定单元31、可用令牌确定单元32以及报文处理单元33;其中,新增令牌确定单元31,配置为在本次报文到达后,确定在上一次计数值与上一次计数值的时间间隔内令牌桶中新增令牌的数量,其中, 当前数值为本次报文的时间戳,上一次计数值为上一次到达的报文的时间戳;可用令牌确定单元32,配置为当新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和令牌桶的容量,确定令牌桶中可用令牌的数量;报文处理单元33,配置为当可用令牌的数量大于等于本次报文的长度时,发送本次报文,保持上一次计数值不变,并更新已用令牌的当前值。
一具体实施例中,报文处理单元33,还配置为在可用令牌确定单元32根据已用令牌的当前值和令牌桶的容量,确定可用令牌的数量之后,当可用令牌的数量小于本次报文的长度时,丢弃本次报文,并保持上一次计数值和已用令牌的当前值不变。
一具体实施例中,可用令牌确定单元32,配置为将令牌桶的容量与已用令牌的当前值之间的差值,确定为可用令牌的数量。
一具体实施例中,可用令牌确定单元32,还配置为在新增令牌确定单元确定新增令牌的数量之后,当新增令牌的数量大于等于预设报文最小长度时,根据已用令牌的当前值、令牌桶的容量以及新增令牌的数量,确定可用令牌的数量;
相应地,报文处理单元33,还配置为当可用令牌的数量大于等于本次报文的长度时,发送本次报文,并更新上一次计数值和已用令牌的当前值;当可用令牌的数量小于本次报文的长度时,丢弃本次报文,并更新上一次计数值和已用令牌的当前值。
一具体实施例中,报文处理单元33,还配置为在可用令牌确定单元确定可用令牌的数量之后,当可用令牌的数量大于等于本次报文的长度时,将本次报文标记成绿色报文;当可用令牌的数量小于本次报文的长度时,将本次报文标记为红色报文。
上述新增令牌确定单元31、可用令牌确定单元32以及报文处理单元33均可以设置在传输报文的装置的物理接口上。
本发明实施例还提供一种计算机存储介质,其中存储有计算机可执行指令,所述计算机可执行指令用于执行上述任一方法实施例所述的方法。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
以上所述仅为本发明的较佳实施例,并非用于限定本发明的保护范围。

Claims (11)

  1. 一种传输报文的方法,其中,所述方法包括:
    在本次报文到达后,确定在时钟的上一次计数值与当前计数值之间的时间间隔内令牌桶中新增令牌的数量,其中,所述当前数值为所述本次报文的时间戳,所述上一次计数值为上一次到达的报文的时间戳;
    当所述新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量;
    当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,保持所述上一次计数值不变,并更新所述已用令牌的当前值。
  2. 根据权利要求1所述的方法,其中,在所述根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量之后,所述方法还包括:
    当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并保持所述上一次计数值和所述已用令牌的当前值不变。
  3. 根据权利要求1或2所述的方法,其中,所述根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量,包括:
    将所述令牌桶的容量与所述已用令牌的当前值之间的差值,确定为所述可用令牌的数量。
  4. 根据权利要求1所述的方法,其中,在所述确定新增令牌的数量之后,所述方法还包括:
    当所述新增令牌的数量大于等于所述预设报文最小长度时,根据所述已用令牌的当前值、所述令牌桶的容量以及所述新增令牌的数量,确定所述可用令牌的数量;
    当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值;
    当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值。
  5. 根据权利要求1或4所述的方法,其中,在所述确定所述令牌桶中可用令牌的数量之后,所述方法还包括:
    当所述可用令牌的数量大于等于所述本次报文的长度时,将所述本次报文标记成绿色报文;
    当所述可用令牌的数量小于所述本次报文的长度时,将所述本次报文标记为红色报文。
  6. 一种传输报文的装置,其中,所述装置包括:新增令牌确定单元、可用令牌确定单元以及报文处理单元;其中,
    所述新增令牌确定单元,配置为在本次报文到达后,确定在时钟的上一次计数值与当前计数值之间的时间间隔内令牌桶中新增令牌的数量,其中,所述当前数值为所述本次报文的时间戳,所述上一次计数值为上一次到达的报文的时间戳;
    所述可用令牌确定单元,配置为当所述新增令牌的数量小于预设报文最小长度时,根据已用令牌的当前值和所述令牌桶的容量,确定所述令牌桶中可用令牌的数量。
  7. 根据权利要求6所述的装置,其中,所述报文处理单元,还配置为在所述可用令牌确定单元根据所述已用令牌的当前值和所述令牌桶的容量,确定所述可用令牌的数量之后,当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并保持所述上一次计数值和所述已用令牌的当前值不变。
  8. 根据权利要求6或7所述的装置,其中,所述可用令牌确定单元配置为将所述令牌桶的容量与所述已用令牌的当前值之间的差值,确定为所述可用令牌的数量;
    相应地,所述报文处理单元,配置为将所述已用令牌的当前值更新为所述差值。
  9. 根据权利要求6所述的装置,其中,所述可用令牌确定单元,还配置为在所述新增令牌确定单元确定所述新增令牌的数量之后,当所述新增令牌的数量大于等于所述预设报文最小长度时,根据所述已用令牌的当前值、所述令牌桶的容量以及所述新增令牌的数量,确定所述可用令牌的数量;
    相应地,所述报文处理单元,还配置为当所述可用令牌的数量大于等于所述本次报文的长度时,发送所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值;当所述可用令牌的数量小于所述本次报文的长度时,丢弃所述本次报文,并更新所述上一次计数值和所述已用令牌的当前值。
  10. 根据权利要求6或9所述的装置,其中,所述报文处理单元,还配置为在所述可用令牌确定单元确定所述可用令牌的数量之后,当所述可用令牌的数量大于等于所述本次报文的长度时,将所述本次报文标记成绿色报文;当所述可用令牌的数量小于所述本次报文的长度时,将所述本次报文标记为红色报文。
  11. 一种计算机存储介质,其中存储有计算机可执行指令,所述计算机可执行指令用于执行所述权利要求1至5任一项所述的方法。
PCT/CN2015/073661 2014-12-05 2015-03-04 一种传输报文的方法及装置、计算机存储介质 WO2016086542A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410734875.4A CN105656800A (zh) 2014-12-05 2014-12-05 一种传输报文的方法及装置
CN201410734875.4 2014-12-05

Publications (1)

Publication Number Publication Date
WO2016086542A1 true WO2016086542A1 (zh) 2016-06-09

Family

ID=56090895

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/073661 WO2016086542A1 (zh) 2014-12-05 2015-03-04 一种传输报文的方法及装置、计算机存储介质

Country Status (2)

Country Link
CN (1) CN105656800A (zh)
WO (1) WO2016086542A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107465630A (zh) * 2017-08-30 2017-12-12 郑州云海信息技术有限公司 一种带宽流量监管方法及系统
CN114095444A (zh) * 2020-07-15 2022-02-25 中移物联网有限公司 限流方法、装置及电子设备

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106656849B (zh) * 2016-11-01 2019-09-06 杭州迪普科技股份有限公司 报文限速方法及装置
CN106980687B (zh) * 2017-03-31 2020-05-22 北京奇艺世纪科技有限公司 一种资源下载系统、方法及爬虫下载系统
WO2020142867A1 (zh) * 2019-01-07 2020-07-16 华为技术有限公司 一种流量整形方法及相关设备
CN110912834A (zh) * 2019-12-09 2020-03-24 昆高新芯微电子(江苏)有限公司 一种基于令牌桶算法的流量控制方法
CN113765819A (zh) * 2020-09-01 2021-12-07 北京沃东天骏信息技术有限公司 资源访问方法、装置、电子设备及存储介质
CN114024923A (zh) * 2021-10-30 2022-02-08 江苏信而泰智能装备有限公司 一种多线程报文捕获方法、电子设备及计算机存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050083845A1 (en) * 2003-10-21 2005-04-21 Comcast Cable Communications, Inc. Method and packet-level device for traffic regulation in a data network
CN1787483A (zh) * 2004-12-10 2006-06-14 华为技术有限公司 一种流量控制方法
CN101753423A (zh) * 2008-12-12 2010-06-23 华为技术有限公司 一种流量的管理方法和装置
US20140112147A1 (en) * 2012-10-19 2014-04-24 Broadcom Corporation Refresh mechanism for a token bucket

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101841461B (zh) * 2010-02-11 2012-05-30 北京星网锐捷网络技术有限公司 一种控制令牌桶更新的方法和装置
CN102082693B (zh) * 2011-02-15 2015-05-20 中兴通讯股份有限公司 网络流量监管方法及装置
CN102710514B (zh) * 2012-05-25 2015-01-21 华为技术有限公司 一种报文流量控制方法及系统
US20130339736A1 (en) * 2012-06-19 2013-12-19 Alex Nayshtut Periodic platform based web session re-validation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050083845A1 (en) * 2003-10-21 2005-04-21 Comcast Cable Communications, Inc. Method and packet-level device for traffic regulation in a data network
CN1787483A (zh) * 2004-12-10 2006-06-14 华为技术有限公司 一种流量控制方法
CN101753423A (zh) * 2008-12-12 2010-06-23 华为技术有限公司 一种流量的管理方法和装置
US20140112147A1 (en) * 2012-10-19 2014-04-24 Broadcom Corporation Refresh mechanism for a token bucket

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107465630A (zh) * 2017-08-30 2017-12-12 郑州云海信息技术有限公司 一种带宽流量监管方法及系统
CN107465630B (zh) * 2017-08-30 2021-08-31 郑州云海信息技术有限公司 一种带宽流量监管方法及系统
CN114095444A (zh) * 2020-07-15 2022-02-25 中移物联网有限公司 限流方法、装置及电子设备
CN114095444B (zh) * 2020-07-15 2023-11-10 中移物联网有限公司 限流方法、装置及电子设备

Also Published As

Publication number Publication date
CN105656800A (zh) 2016-06-08

Similar Documents

Publication Publication Date Title
WO2016086542A1 (zh) 一种传输报文的方法及装置、计算机存储介质
WO2018210117A1 (zh) 一种拥塞控制方法、网络设备及其网络接口控制器
US11522803B2 (en) Method and apparatus for handling packet delay budget division and quality of service monitoring in a communication system
WO2015149488A1 (zh) 一种令牌桶限速方法、装置及计算机存储介质
JP2016526323A5 (zh)
JP2006157923A (ja) パケット・ネットワーク上の利用可能な帯域幅を推定する方法および装置
US9331925B2 (en) Multiple test site bandwidth limit measurement
WO2012109911A1 (zh) 网络流量监管方法及装置
EP2451099A3 (en) Method and system for optical network smart timer management via delay measurement betweens spans
CN107454276A (zh) 一种用户终端设备及其数据转发方法、及通信系统
EP3398296B1 (en) Performance measurement in a packet-switched communication network
WO2017032133A1 (zh) 一种丢包率检测方法及装置
US20150236955A1 (en) Congestion Notification in a Network
EP3210343B1 (en) Method and system for non-tagged based latency calculation
US20160337212A1 (en) Uplink Performance Management
WO2017161967A1 (zh) 包每秒流量监管方法、装置和计算机存储介质
CN111436030A (zh) 数据用量上报的方法、装置及系统
US11121938B2 (en) Performance measurement in a packet-switched communication network
EP3560152B1 (en) Determining the bandwidth of a communication link
JP2016208445A (ja) 無線通信システム、サーバ、基地局
US10050856B2 (en) Communication device, network available bandwidth estimation method in communication device, and storage medium on which network available bandwidth estimation program has been recorded
US11165671B2 (en) Performance measurement in a packet-switched communication network
CN111510394A (zh) 一种报文调度方法、相关设备及计算机存储介质
JP2017523693A (ja) パケットロス検出のための方法、装置、およびシステム
CN109660452B (zh) 一种垃圾邮件源检测方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15865489

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15865489

Country of ref document: EP

Kind code of ref document: A1