HK1220827B - A method of using bit vectors to allow expansion and collapse of header layers within packets for enabling flexible modifications and an apparatus thereof - Google Patents
A method of using bit vectors to allow expansion and collapse of header layers within packets for enabling flexible modifications and an apparatus thereofInfo
- Publication number
- HK1220827B HK1220827B HK16108884.4A HK16108884A HK1220827B HK 1220827 B HK1220827 B HK 1220827B HK 16108884 A HK16108884 A HK 16108884A HK 1220827 B HK1220827 B HK 1220827B
- Authority
- HK
- Hong Kong
- Prior art keywords
- protocol header
- bit vector
- protocol
- packet
- layer
- Prior art date
Links
Description
技术领域Technical Field
本发明涉及分组报头修改。更具体地,本发明涉及一种使用位矢量来允许分组内的报头层的扩展和塌缩用于实现灵活修改的方法及其装置。The present invention relates to packet header modification, and more particularly to a method and apparatus for using a bit vector to allow expansion and collapse of a header layer within a packet for flexible modification.
背景技术Background Art
网络分组经由因特网使用的协议、比如传输控制协议/网际协议/以太网协议(TCP/IP/以太网)承载数据。典型交换机能够在向目的地或者向另一交换机发送出分组之前修改传入的分组的各种字段。出于各种原因而修改传入的分组,比如分组将被转发到何处、目的地支持的协议、分组的优先级、协议报头的传入格式等。由于网络协议正在演变,协议报头的一个或者多个字段可以是可任选的,这使交换机的硬件变复杂,因为在协议报头内的给定的字段可能不总是处于固定的偏移。Network packets carry data via protocols used by the Internet, such as Transmission Control Protocol/Internet Protocol/Ethernet (TCP/IP/Ethernet). A typical switch can modify various fields of an incoming packet before sending the packet out to its destination or to another switch. Incoming packets may be modified for a variety of reasons, such as where the packet will be forwarded, the protocols supported by the destination, the packet's priority, the format of the incoming protocol header, and so on. Because network protocols are constantly evolving, one or more fields in the protocol header may be optional, which complicates switch hardware because a given field within the protocol header may not always be at a fixed offset.
在分组的修改期间,现有技术的交换机线性地处理分组中的每个协议层。这样的处理会产生与网络有关的性能问题,包括时延,这可能使实现方式过度提供处理资源。During modification of a packet, prior art switches process each protocol layer in the packet linearly. Such processing can produce performance issues related to the network, including latency, which may cause implementations to over-provision processing resources.
发明内容Summary of the Invention
用于修改分组报头的装置的实施例涉及使用位矢量来允许分组内的协议报头的扩展和塌缩用于实现灵活修改。重写引擎将每个协议报头扩展成通用格式并且应用各种命令来修改经一般化的协议报头。重写引擎针对经一般化的协议报头维护位矢量,其中在位矢量中的每个位表示经一般化的协议报头的字节。在位矢量中被标注为0的位对应于无效字节,而在位矢量中被标注为1的位对应于有效字节。重写引擎使用位矢量来去除在已经对经一般化的协议报头操作所有命令之后的所有无效字节以由此形成新协议报头。An embodiment of an apparatus for modifying packet headers involves using a bit vector to allow expansion and collapse of protocol headers within a packet for flexible modification. A rewrite engine expands each protocol header into a universal format and applies various commands to modify the generalized protocol header. The rewrite engine maintains a bit vector for the generalized protocol header, where each bit in the bit vector represents a byte of the generalized protocol header. Bits marked as 0 in the bit vector correspond to invalid bytes, while bits marked as 1 in the bit vector correspond to valid bytes. The rewrite engine uses the bit vector to remove all invalid bytes after all commands have been applied to the generalized protocol header to thereby form a new protocol header.
在一个方面中,提供一种重写引擎的方法。该方法包括针对经一般化的协议报头维护位矢量。经一般化的协议报头是被扩展成通用格式的分组的协议报头。通用格式包括协议的所有可能字段。无论协议报头对应于协议的哪个变体,字段中的每个字段都具有相同偏移。位矢量包括针对经一般化的协议报头的每个字节的每字节的位。In one aspect, a method for a rewrite engine is provided. The method includes maintaining a bit vector for a generalized protocol header. The generalized protocol header is a protocol header for a packet expanded into a general format. The general format includes all possible fields of the protocol. Regardless of which variant the protocol header corresponds to, each of the fields has the same offset. The bit vector includes a bit per byte for each byte of the generalized protocol header.
该方法也包括基于对至少一个经一般化的协议报头的修改来更新位矢量。在一些实施例中,修改使用来自在网络交换机的存储器中存储的通用命令集合的至少一个命令来修改至少一个经一般化的协议报头。The method also includes updating the bit vector based on the modification to the at least one generalized protocol header.In some embodiments, the modification modifies the at least one generalized protocol header using at least one command from a set of general commands stored in a memory of the network switch.
该方法也包括使用经更新的位矢量来压缩至少一个经一般化的协议报头。在一些实施例中,在使用经更新的位矢量之前,对位矢量和经更新的位矢量执行XOR操作以确定多少位被改变,这允许重写引擎考虑被删除和添加的字节。The method also includes compressing at least one generalized protocol header using the updated bit vector. In some embodiments, before using the updated bit vector, an XOR operation is performed on the bit vector and the updated bit vector to determine how many bits have been changed, which allows the rewrite engine to take into account deleted and added bytes.
在另一方面中,提供一种网络交换机的方法。该方法包括在网络交换机的传入端口处接收分组并且根据用于分组的每个协议报头的通用格式来使该协议报头一般化。检测从分组的协议报头的缺失字段。基于检测,通过包括缺失字段来将协议报头扩展成通用格式。In another aspect, a method for a network switch is provided. The method includes receiving a packet at an incoming port of the network switch and generalizing each protocol header of the packet according to a common format for the protocol header. Missing fields are detected from the protocol header of the packet. Based on the detection, the protocol header is expanded to the common format by including the missing fields.
该方法也包括针对每个经一般化的协议报头维护位矢量。位矢量包括针对无效字段而被标注为0的位和针对有效字段而被标注为1的位The method also includes maintaining a bit vector for each generalized protocol header. The bit vector includes bits marked as 0 for invalid fields and bits marked as 1 for valid fields.
该方法也包括:修改经一般化的协议报头中的至少一个经一般化的协议报头,由此更新位矢量。在一些实施例中,修改使用来自在网络交换机的存储器中存储的通用命令集合的至少一个命令来修改至少一个经一般化的协议报头。在一些实施例中,对至少一个经一般化的协议报头的修改是基于网络交换机的传出端口的出口端口类型。The method also includes modifying at least one of the generalized protocol headers, thereby updating the bit vector. In some embodiments, the modification uses at least one command from a set of generalized commands stored in a memory of the network switch to modify the at least one generalized protocol header. In some embodiments, the modification of the at least one generalized protocol header is based on an egress port type of an egress port of the network switch.
该方法也包括使经更新的位矢量塌缩。在一些实施例中,通过移位经更新的位矢量以去除在经更新的位矢量中被标注为0的每个位来使经更新的位矢量塌缩。The method also includes collapsing the updated bit vector.In some embodiments, the updated bit vector is collapsed by shifting the updated bit vector to remove each bit marked as 0 in the updated bit vector.
该方法也包括基于经塌缩的位矢量形成紧凑协议报头。经由网络交换机的传出端口发射至少具有紧凑协议报头的分组。在一些实施例中,在发射分组之前,对针对执行的所有操作而添加或者删除的字节的数目进行计数。The method also includes forming a compact protocol header based on the collapsed bit vector. The packet having at least the compact protocol header is transmitted via an egress port of the network switch. In some embodiments, before transmitting the packet, the number of bytes added or deleted for all operations performed is counted.
在又一方面中,提供一种网络交换机。网络交换机包括:输入端口,用于接收分组;以及存储器,存储通用命令集合。通用命令集合被用于报头修改,而不管传入报头如何。在一些实施例中,通用命令集合包括删除命令、复制命令和移动命令。In yet another aspect, a network switch is provided. The network switch includes an input port for receiving packets and a memory for storing a universal command set. The universal command set is used for header modification regardless of the incoming header. In some embodiments, the universal command set includes a delete command, a copy command, and a move command.
网络交换机也包括重写引擎。重写引擎使用位矢量以允许分组的协议报头的扩展和塌缩,由此通过使用通用命令集合来实现分组的灵活修改。The network switch also includes a rewrite engine. The rewrite engine uses bit vectors to allow expansion and collapse of a packet's protocol header, thereby enabling flexible modification of the packet using a common command set.
在一些实施例中,协议报头中的每个协议报头根据对应协议特有的由软件定义的映射中的一个映射被一般化。在一些实施例中,由软件定义的映射被存储在存储器中。In some embodiments, each of the protocol headers is generalized according to one of the software-defined mappings specific to the corresponding protocol. In some embodiments, the software-defined mapping is stored in a memory.
每个经一般化的协议报头包括位矢量,位矢量具有针对无效字段而被标注为0的位和针对有效字段而被标注为1的位。在一些实施例中,重写引擎在经一般化的协议报头被修改之后更新位矢量。在一些实施例中,重写引擎去除在经更新的位矢量中被标注为0的每个位以使经更新的位矢量塌缩。新报头基于经塌缩的位矢量而形成。Each generalized protocol header includes a bit vector having bits marked as 0 for invalid fields and bits marked as 1 for valid fields. In some embodiments, the rewrite engine updates the bit vector after the generalized protocol header is modified. In some embodiments, the rewrite engine removes each bit marked as 0 in the updated bit vector to collapse the updated bit vector. A new header is formed based on the collapsed bit vector.
在一些实施例中,网络交换机也包括用于发射具有新报头的分组的传出端口。In some embodiments, the network switch also includes an egress port for transmitting the packet with the new header.
在又一方面中,提供一种网络交换机。网络交换机包括用于接收分组的输入端口,其中分组包括正文和协议报头。网络交换机也包括用于发射经修改的分组的输出端口。网络交换机也包括用于存储协议的通用格式的由软件定义的映射的集合和通用修改命令集合的存储器。通常,通用修改命令集合被用于报头修改,而不管传入报头如何。In yet another aspect, a network switch is provided. The network switch includes an input port for receiving packets, wherein the packets include a body and a protocol header. The network switch also includes an output port for transmitting modified packets. The network switch also includes a memory for storing a set of software-defined mappings of common formats for protocols and a set of common modification commands. Typically, the common modification command set is used for header modification regardless of the incoming header.
网络交换机也包括重写引擎。重写引擎基于来自由软件定义的映射的集合的由软件定义的映射,将协议栈的每个协议报头转换成通用格式,并且针对每个经转换的协议报头维护位矢量。位矢量包括针对经转换的协议报头的每个字节的每字节的位。位矢量包括针对经转换的协议报头的无效字段而被标注为0的位和针对经转换的协议报头的有效字段而被标注为1的位。重写引擎使用通用修改命令集合来修改每个经转换的协议报头,更新在位矢量之后的每个位矢量,使每个经更新的位矢量塌缩以由此形成新协议栈,并且向新协议栈附着正文以经由输出端口发射。The network switch also includes a rewrite engine. The rewrite engine converts each protocol header of the protocol stack into a common format based on a software-defined mapping from a set of software-defined mappings, and maintains a bit vector for each converted protocol header. The bit vector includes a bit for each byte of the converted protocol header. The bit vector includes bits marked as 0 for invalid fields of the converted protocol header and bits marked as 1 for valid fields of the converted protocol header. The rewrite engine modifies each converted protocol header using a common modification command set, updates each bit vector following the bit vector, collapses each updated bit vector to thereby form a new protocol stack, and attaches a body to the new protocol stack for transmission via an output port.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
前文将从如附图中所示本发明的示例实施例的以下更具体描述中变清楚,在附图中,相似标号贯穿不同视图指代相同部分。附图未必按比例、代之以着重于图示本发明的实施例。The foregoing will be apparent from the following more particular description of example embodiments of the invention, as illustrated in the accompanying drawings, in which like reference numerals refer to the same parts throughout the different views. The drawings are not necessarily to scale, emphasis instead being placed upon illustrating embodiments of the invention.
图1图示分组的示例协议层组合。FIG. 1 illustrates an example protocol layer combination for a packet.
图2图示根据本发明的一些实施例的本地协议表的示例结构。FIG2 illustrates an example structure of a local protocol table according to some embodiments of the present invention.
图3图示根据本发明的一些实施例的网络交换机的示例方法。FIG3 illustrates an example method of a network switch according to some embodiments of the present invention.
图4图示根据本发明的一些实施例的网络交换机的另一示例方法。FIG4 illustrates another example method of a network switch according to some embodiments of the present invention.
图5图示根据本发明的一些实施例的将传入的分组的层进行报头扩展成通用格式的图。5 illustrates a diagram of header expansion of layers of an incoming packet into a common format according to some embodiments of the present invention.
图6A-6B图示根据本发明的一些实施例的协议报头的示例一般化。6A-6B illustrate example generalizations of protocol headers according to some embodiments of the present invention.
图7A-7C图示根据本发明的一些实施例的协议报头的另一示例一般化。7A-7C illustrate another example generalization of a protocol header according to some embodiments of the present invention.
图8A-8C图示根据本发明的一些实施例的协议报头的又一示例一般化。8A-8C illustrate yet another example generalization of a protocol header according to some embodiments of the present invention.
图9A-9F图示根据本发明的一些实施例的协议报头的示例修改。9A-9F illustrate example modifications of a protocol header according to some embodiments of the present invention.
图10A-10E图示根据本发明的一些实施例的协议报头的另一示例修改。10A-10E illustrate another example modification of a protocol header according to some embodiments of the present invention.
图11图示根据本发明的一些实施例的重写引擎的方法。FIG. 11 illustrates a method of rewriting an engine according to some embodiments of the present invention.
图12图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 12 illustrates yet another method of a network switch according to some embodiments of the present invention.
图13图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 13 illustrates yet another method of a network switch according to some embodiments of the present invention.
图14图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 14 illustrates yet another method of a network switch according to some embodiments of the present invention.
图15图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 15 illustrates yet another method of a network switch according to some embodiments of the present invention.
图16图示根据本发明的一些实施例的重写引擎的另一方法。FIG16 illustrates another method of rewriting an engine according to some embodiments of the present invention.
图17图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 17 illustrates yet another method of a network switch according to some embodiments of the present invention.
图18图示根据本发明的一些实施例的重写引擎的又一方法。FIG. 18 illustrates yet another method of rewriting an engine according to some embodiments of the present invention.
图19图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 19 illustrates yet another method of a network switch according to some embodiments of the present invention.
图20图示根据本发明的一些实施例的层结构的示例图。FIG20 illustrates an example diagram of a layer structure according to some embodiments of the present invention.
图21图示根据本发明的一些实施例的重写引擎交换机的又一方法。FIG. 21 illustrates yet another method of rewriting an engine switch according to some embodiments of the present invention.
图22图示根据本发明的一些实施例的网络交换机的又一方法。FIG. 22 illustrates yet another method of a network switch according to some embodiments of the present invention.
具体实施方式DETAILED DESCRIPTION
在以下描述中,出于说明的目的而阐述许多细节。然而,本领域普通技术人员将认识到,可以在不使用这些具体细节的情况下实施本发明。因此,本发明并不旨在于限于所示实施例,而是将被赋予与这里描述的原理和特征一致的最广范围。In the following description, many details are set forth for illustrative purposes. However, one skilled in the art will recognize that the present invention can be practiced without these specific details. Therefore, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features described herein.
引言introduction
网络设备、比如网络交换机能够切换/路由网络流量。网络交换机包括用于接收和发送分组的至少一个输入/传入端口和至少一个输出/传出端口。在一些实施例中,网络交换机也包括解析器和重写器。解析器可以包括用于标识网络分组的内容的一个或者多个解析器引擎,并且重写器可以包括用于在分组从网络交换机被发送出之前修改它们的一个或者多个重写引擎。解析器引擎和重写引擎是灵活的并且在可编程基础上操作。A network device, such as a network switch, is capable of switching/routing network traffic. The network switch includes at least one input/incoming port and at least one output/outgoing port for receiving and sending packets. In some embodiments, the network switch also includes a parser and a rewriter. The parser may include one or more parser engines for identifying the content of network packets, and the rewriter may include one or more rewrite engines for modifying packets before they are sent out of the network switch. The parser engine and the rewrite engine are flexible and operate on a programmable basis.
网络交换机也包括用于存储网络交换机使用的数据的存储器。例如存储器存储通用命令集合。简言之,通用命令通常被用来修改协议报头。对于另一示例,存储器也存储协议的通用格式的由软件定义的映射。简言之,根据对应协议特有的由软件定义的映射中的一个映射表示每个协议报头。如将变得清楚的那样,这些映射可以被用在协议的不同变体上以及用在包括新协议的不同协议上。对于又一示例,存储器也存储协议表。简言之,协议表包括被编程到协议表中的每个协议层组合的每个协议层的层信息。对于又一示例,存储器也存储计数器和统计量。The network switch also includes a memory for storing data used by the network switch. For example, the memory stores a set of common commands. In short, the common commands are generally used to modify protocol headers. In another example, the memory also stores software-defined mappings of the common formats of the protocols. In short, each protocol header is represented according to one of the software-defined mappings specific to the corresponding protocol. As will become clear, these mappings can be used for different variants of the protocol and for different protocols, including new protocols. In yet another example, the memory also stores a protocol table. In short, the protocol table includes layer information for each protocol layer for each protocol layer combination programmed into the protocol table. In yet another example, the memory also stores counters and statistics.
在以太网中,分组包括多个协议层。每个协议层承载不同信息。公知层的一些示例是:In Ethernet, packets consist of multiple protocol layers. Each protocol layer carries different information. Some examples of well-known layers are:
·以太网Ethernet
·PBB以太网PBB Ethernet
·ARPARP
·IPV4IPv4
·IPV6IPv6
·MPLSMPLS
·FCOEFCOE
·TCPTCP
·UDPUDP
·ICMPICMP
·IGMPIGMP
·GREGRE
·ICMPv6ICMPv6
·VxLANVxLAN
·TRILLTRILL
·CNM·CNM
在理论上,协议层可以按照任何顺序出现。然而,这些层的仅一些公知组合出现。这些层的有效组合的一些示例是:In theory, the protocol layers can appear in any order. However, only some well-known combinations of these layers appear. Some examples of valid combinations of these layers are:
·以太网Ethernet
·以太网、ARPEthernet, ARP
·以太网、CNMEthernet, CNM
·以太网、FCoEEthernet, FCoE
·以太网、IPV4Ethernet, IPv4
·以太网、IPV4、ICMPEthernet, IPv4, ICMP
·以太网、IPV4、IGMPEthernet, IPv4, IGMP
唯一分组标识符Unique group identifier
在一些实施例中,网络交换机支持17个协议和八个协议层。因此有817个可能协议层组合。图1图示分组的示例协议层组合。例如分组可以包括三协议层组合比如以太网、IPv4和ICMP。对于另一示例,分组可以包括七协议层组合比如以太网、IPv4、UDP、VxLAN、以太网和ARP。In some embodiments, the network switch supports 17 protocols and eight protocol layers. Therefore, there are 817 possible protocol layer combinations. Figure 1 illustrates example protocol layer combinations for a packet. For example, a packet may include a three-protocol layer combination such as Ethernet, IPv4, and ICMP. For another example, a packet may include a seven-protocol layer combination such as Ethernet, IPv4, UDP, VxLAN, Ethernet, and ARP.
虽然有817个可能协议层组合,但是这些层中的仅一些公知组合出现。所有已知协议层组合被唯一地标识和翻译成称为分组标识符(PktID)的唯一编号。在网络交换机的存储器中存储的协议表被编程为包括每个已知协议层组合的每层的层信息。在实践中,本地协议表包括少于256个协议层组合。在一些实施例中,这一本地表包括212个已知协议层组合。本地表被编程为包括或多或少协议层组合。Although there are 817 possible protocol layer combinations, only some known combinations of these layers occur. All known protocol layer combinations are uniquely identified and translated into a unique number called a packet identifier (PktID). The protocol table stored in the memory of the network switch is programmed to include layer information for each layer of each known protocol layer combination. In practice, the local protocol table includes fewer than 256 protocol layer combinations. In some embodiments, this local table includes 212 known protocol layer combinations. The local table can be programmed to include more or fewer protocol layer combinations.
图2图示根据本发明的一些实施例的本地协议表200的示例结构。在本地表200中的使用PktID索引的每个协议层组合包括用于该协议层组合的每个协议层的信息,该信息被示出为层0信息、层1信息和层N信息。通过对PktID进行索引,可以访问或者获取用于分组的所有N层的信息。FIG2 illustrates an example structure of a local protocol table 200 according to some embodiments of the present invention. Each protocol layer combination indexed by a PktID in the local table 200 includes information for each protocol layer of the protocol layer combination, which is shown as layer 0 information, layer 1 information, and layer N information. By indexing the PktID, information for all N layers of a packet can be accessed or obtained.
用于每个协议层的信息至少包括以下信息:层类型、层数据偏移和杂项信息。然而,更多信息可以被存储在本地表200中。简言之,层类型是指协议层的关联协议(例如IP/TCP/UDP/以太网),层数据偏移提供协议层中的层数据的开始位置,并且杂项信息包括比如校验和和长度数据之类的数据。The information for each protocol layer includes at least the following information: layer type, layer data offset, and miscellaneous information. However, more information may be stored in the local table 200. In short, the layer type refers to the protocol associated with the protocol layer (e.g., IP/TCP/UDP/Ethernet), the layer data offset provides the starting position of the layer data in the protocol layer, and the miscellaneous information includes data such as checksum and length data.
通常,解析器引擎能够标识在网络交换机处接收的传入的分组的PktID。重写引擎使用PktID作为至协议表的关键字,该协议表向重写引擎提供为了使用于修改的分组的每个协议层一般化而需要的所有信息。换而言之,重写引擎使用PktID从协议表访问或者获取用于分组中的协议层中的每个协议层的信息,而不是从解析器引擎接收解析结果。Typically, the parser engine is able to identify the PktID of an incoming packet received at a network switch. The rewrite engine uses the PktID as a key to a protocol table, which provides the rewrite engine with all the information it needs to generalize each protocol layer of the packet for modification. In other words, the rewrite engine uses the PktID to access or obtain information for each of the protocol layers in the packet from the protocol table, rather than receiving parsing results from the parser engine.
层类型。层类型和对分组的一个或者多个字段的哈希的唯一组合向重写引擎提供用于每个协议层的“通用格式”。在一些实施例中,这一唯一组合指定在存储器中存储的协议的通用格式的由软件定义的映射中的一个映射。通用格式由重写引擎用来扩展协议层并且使用软件命令来修改协议层。这一信息也向重写引擎告知每个协议层在分组内何处开始。Layer Type. A unique combination of the layer type and a hash of one or more fields of the packet provides the rewrite engine with a "universal format" for each protocol layer. In some embodiments, this unique combination specifies one of the software-defined mappings of the protocol's universal format stored in memory. The universal format is used by the rewrite engine to extend and modify protocol layers using software commands. This information also tells the rewrite engine where each protocol layer begins within the packet.
层数据偏移。重写引擎使用数据修改传入报头层。这一数据可以在分组中任何处被扩展。由于层大小可以变化,所以向重写引擎在修改期间需要使用的数据的偏移可以变化,这限制对重写引擎可以从何处拾取什么数据的硬件灵活性。Layer Data Offset. The rewrite engine uses data to modify the incoming header layer. This data can be extended anywhere in the packet. Because layer sizes can vary, the offset to the data the rewrite engine needs to use during modification can vary, limiting the hardware flexibility of where and what data the rewrite engine can pick up.
以分层方式布置来自传入的分组报头的提取的数据。布置提取的数据结构,使得层数据结构的开始偏移每PktID是唯一的。每层的层数据偏移用来标识用于修改的提取的数据的位置。由于通过分组的PktID标识在分组内的层的结构和来自层的提取的数据的位置,所以软件和硬件使用相同唯一标识符来管理提取的数据,这简化重写引擎中的命令。The extracted data from the incoming packet header is arranged in a layered fashion. The extracted data structure is arranged so that the starting offset of the layer data structure is unique per PktID. The layer data offset for each layer is used to identify the location of the extracted data for modification. Since the structure of the layers within the packet and the location of the extracted data from the layers are identified by the packet's PktID, software and hardware use the same unique identifier to manage the extracted data, simplifying commands in the rewrite engine.
杂项信息。比如校验和和长度数据之类的信息向重写引擎告知对于关联协议层的特殊处置要求,比如校验和重新计算以及报头长度更新。Miscellaneous information. Information such as checksum and length data informs the rewrite engine of special handling requirements for the associated protocol layer, such as checksum recalculation and header length update.
分组一般化方案允许软件定义通用命令的小集合,该集合完全地基于给定的协议层并且独立于在这一协议层之前或者之后的层。分组一般化方案也提供硬件灵活性以使自身针对协议改变和添加而不会过时。The packet generalization scheme allows software to define a small set of common commands that are completely based on a given protocol layer and independent of layers before or after it. The packet generalization scheme also provides hardware flexibility to future-proof itself against protocol changes and additions.
图3图示根据本发明的一些实施例的网络交换机的示例方法300。网络交换机通常包括解析器引擎和重写引擎。Figure 3 illustrates an example method 300 for a network switch according to some embodiments of the present invention.A network switch typically includes a parser engine and a rewrite engine.
在步骤305,解析器引擎检查传入的分组以标识分组的PktID。在一些实施例中,解析器引擎向重写引擎传递PktID,而不是向重写引擎传递分组的解析的数据。The parser engine examines the incoming packet to identify the packet's PktID at step 305. In some embodiments, the parser engine passes the PktID to the rewrite engine instead of passing the parsed data of the packet to the rewrite engine.
在步骤310,重写引擎参考协议表,该协议表定义网络交换机接收的分组的不同分组结构。重写引擎使用PktID作为至协议表的关键字,以提取修改所必需的用于分组的每个协议层的信息。The rewrite engine references a protocol table that defines different packet structures for packets received by the network switch at step 310. The rewrite engine uses the PktID as a key to the protocol table to extract information for each protocol layer of the packet necessary for modification.
在步骤315,重写引擎基于在协议表中存储的数据修改分组。通常,重写引擎在修改分组之前扩展分组的每个协议层。协议层扩展和修改在别处讨论。In step 315, the rewrite engine modifies the packet based on the data stored in the protocol table. Typically, the rewrite engine extends each protocol layer of the packet before modifying the packet. Protocol layer extension and modification are discussed elsewhere.
图4图示根据本发明的一些实施例的网络交换机的另一示例方法400。网络交换机通常包括存储器和至少一个传入端口。Figure 4 illustrates another example method 400 for a network switch according to some embodiments of the present invention.A network switch typically includes memory and at least one incoming port.
在步骤405,在存储器中存储协议表。协议表定义分组的不同分组结构。分组结构中的每个分组结构由PktID进行索引。分组结构中的每个分组结构表示协议层组合并且包括协议层组合的每个协议层的层信息。协议表可以被更新以添加表示新协议的新分组结构。协议表也可以被更新以响应于协议的改变来修改分组结构。At step 405, a protocol table is stored in memory. The protocol table defines different packet structures for packets. Each packet structure in the packet structure is indexed by a PktID. Each packet structure in the packet structure represents a protocol layer combination and includes layer information for each protocol layer in the protocol layer combination. The protocol table can be updated to add new packet structures representing new protocols. The protocol table can also be updated to modify the packet structure in response to protocol changes.
在步骤410,在传入端口处接收分组。At step 410, a packet is received at an incoming port.
在步骤415,标识分组的PktID。在一些实施例中,解析器引擎标识分组的PktID。At step 415, the PktID of the packet is identified. In some embodiments, the parser engine identifies the PktID of the packet.
在步骤420,访问用于分组的每个协议层的信息。通常,信息位于协议表中。在一些实施例中,信息被用来根据用于对应协议的通用格式使分组的协议报头一般化。通用格式在存储器中由软件定义。In step 420, information for each protocol layer of the packet is accessed. Typically, the information is located in a protocol table. In some embodiments, the information is used to generalize the protocol header of the packet according to a common format for the corresponding protocol. The common format is defined by software in memory.
如别处说明的那样,经一般化的协议报头可以通过将至少一个命令应用于经一般化的协议报头来修改。在一些实施例中,通过使用信息确定用来修改经一般化的协议报头的数据的位置,由此修改经一般化的协议报头。网络交换机的重写引擎通常使协议报头一般化并且修改经一般化的协议报头。As described elsewhere, the generalized protocol header can be modified by applying at least one command to the generalized protocol header. In some embodiments, the generalized protocol header is modified by using information to determine the location of data used to modify the generalized protocol header. The rewrite engine of the network switch typically generalizes the protocol header and modifies the generalized protocol header.
通用格式General format
如以上简要地说明的那样,重写引擎以对应协议特有的通用格式表示分组的每个协议报头,以实现分组的可编程修改,从而产生在修改分组报头时的硬件和软件灵活性。As briefly explained above, the rewrite engine represents each protocol header of a packet in a generic format specific to the corresponding protocol to enable programmable modification of the packet, resulting in hardware and software flexibility in modifying the packet headers.
图5图示根据本发明的一些实施例的将传入的分组的层进行报头扩展成通用格式的图500。在图5中,传入的分组包括八个协议层。每个协议层具有用于相应协议的报头。更多或者更少协议层如以上指示的那样是可能的。重写引擎能够如图5中所示从协议报头中的任何协议报头检测缺失字段并且将每个协议报头扩展成它的通用格式。规范层是指已经扩展成它的通用格式的协议层。简言之,每个规范层包括位矢量,该位矢量具有对于无效字段标注为0的位和对于有效字段标注为1的位。FIG5 illustrates a diagram 500 of header expansion of layers of an incoming packet into a common format according to some embodiments of the present invention. In FIG5 , the incoming packet includes eight protocol layers. Each protocol layer has a header for a corresponding protocol. More or fewer protocol layers are possible as indicated above. The rewrite engine is able to detect missing fields from any of the protocol headers as shown in FIG5 and expand each protocol header into its common format. A canonical layer refers to a protocol layer that has been expanded into its common format. In short, each canonical layer includes a bit vector having bits marked as 0 for invalid fields and bits marked as 1 for valid fields.
图6A-8C图示根据本发明的一些实施例的重写引擎如何对以太网协议工作的示例。图6A-8C中所示示例证明,重写引擎能够对比如以太网协议之类的协议的不同变体工作。每个示例举例说明以太网协议的传入报头及其对应通用格式。虽然未讨论其它协议,但是注意重写引擎对其它协议相似地工作。Figures 6A-8C illustrate examples of how the rewrite engine operates for the Ethernet protocol according to some embodiments of the present invention. The examples shown in Figures 6A-8C demonstrate that the rewrite engine can operate for different variants of a protocol such as the Ethernet protocol. Each example illustrates an incoming header for the Ethernet protocol and its corresponding general format. Although other protocols are not discussed, it is noted that the rewrite engine operates similarly for other protocols.
图6A图示传入的分组的示例以太网分组报头的格式600。以太网分组报头600是22字节并且包括五个字段:源地址(SA)字段、目的地地址(DA)字段、服务VLAN标记字段、客户VLAN标记字段和以太类型字段。SA字段和DA字段各自为6字节。服务VLAN标记字段和客户VLAN标记字段各自为4字节。以太类型字段为2字节。具有以太网分组报头600的分组是以太网分组的最大变体并且具有最大大小22字节。FIG6A illustrates the format 600 of an example Ethernet packet header for an incoming packet. Ethernet packet header 600 is 22 bytes and includes five fields: a source address (SA) field, a destination address (DA) field, a service VLAN tag field, a customer VLAN tag field, and an EtherType field. The SA and DA fields are each 6 bytes. The service VLAN tag field and the customer VLAN tag field are each 4 bytes. The EtherType field is 2 bytes. A packet with Ethernet packet header 600 is the largest variant of an Ethernet packet and has a maximum size of 22 bytes.
重写引擎处理以太网分组报头600并且确定没有任何字段从以太网分组报头600缺失。以太网分组报头600的通用格式因此与以太网分组报头600的通用格式相同,因为以太网分组报头600包含所有可能字段。图6B图示表示图6A的以太网分组报头600的位矢量605。位矢量605的每个位对应于以太网分组报头600的22字节的一个字节。位矢量605包含所有1,因为以太网分组报头600的所有字段由于字段在以太网分组报头600中存在而都为有效或者具有值。因而,以太网分组报头600由通用格式{22'b111111_111111_1111_1111_11}表示。The rewrite engine processes Ethernet packet header 600 and determines that no fields are missing from Ethernet packet header 600. The general format of Ethernet packet header 600 is therefore the same as the general format of Ethernet packet header 600, as Ethernet packet header 600 contains all possible fields. FIG6B illustrates a bit vector 605 representing the Ethernet packet header 600 of FIG6A. Each bit of bit vector 605 corresponds to one byte of the 22 bytes of Ethernet packet header 600. Bit vector 605 contains all 1s, as all fields of Ethernet packet header 600 are valid or have values due to their presence in Ethernet packet header 600. Thus, Ethernet packet header 600 is represented by the general format {22'b111111_111111_1111_1111_11}.
图7A图示传入的分组的另一示例以太网分组报头的格式700。以太网分组报头700为18字节并且仅包括四个字段:SA字段、DA字段、客户VLAN标记字段和以太类型字段。以太网分组报头700缺失服务VLAN标记字段。具有以太网分组报头700的分组是以太网分组的另一变体。FIG7A illustrates another example Ethernet packet header format 700 for an incoming packet. Ethernet packet header 700 is 18 bytes and includes only four fields: an SA field, a DA field, a Customer VLAN tag field, and an EtherType field. Ethernet packet header 700 lacks a Service VLAN tag field. A packet with Ethernet packet header 700 is another variant of an Ethernet packet.
重写引擎处理以太网分组报头700,并且确定服务VLAN标记字段从以太网分组报头700缺失,并且通过在以太网分组报头700的通用格式的适当位置处包括缺失的服务VLAN标记字段来将以太网分组报头700扩展成它的最大大小22字节。图7B图示扩展的以太网分组报头的通用格式700’。扩展的以太网分组报头700’包括以太网协议的包括缺失的服务VLAN标记字段的所有可能字段。在扩展的以太网分组报头700’中的有效字段是SA字段、DA字段、客户VLAN标记字段和以太类型字段,因为它们在以太网分组报头700中存在。在扩展的以太网分组报头700’中的无效字段是服务VLAN标记字段,因为它在以太网分组报头700中不存在、而是被添加在扩展的以太网分组报头700’中。The rewrite engine processes the Ethernet packet header 700 and determines that the Service VLAN Tag field is missing from the Ethernet packet header 700. The rewrite engine then extends the Ethernet packet header 700 to its maximum size of 22 bytes by including the missing Service VLAN Tag field at the appropriate location in the general format of the Ethernet packet header 700. FIG7B illustrates the general format 700′ of the extended Ethernet packet header. The extended Ethernet packet header 700′ includes all possible fields of the Ethernet protocol, including the missing Service VLAN Tag field. Valid fields in the extended Ethernet packet header 700′ are the SA field, the DA field, the Customer VLAN Tag field, and the EtherType field, as they exist in the Ethernet packet header 700. The invalid field in the extended Ethernet packet header 700′ is the Service VLAN Tag field, as it does not exist in the Ethernet packet header 700 but is added to the extended Ethernet packet header 700′.
图7C图示表示图7B的扩展的以太网分组报头700’的位矢量705。位矢量705的每个位对应于扩展的以太网分组报头700’的22字节中的一个字节。位矢量705包含用于所有有效字段的1,这些字段是SA字段、DA字段、客户VLAN标记字段和以太类型字段。位矢量705包含用于所有无效字段的0,这些字段仅为服务VLAN标记字段。因而,以太网分组报头700由通用格式{22'b111111_111111_0000_1111_11}表示。FIG7C illustrates a bit vector 705 representing the extended Ethernet packet header 700′ of FIG7B . Each bit of bit vector 705 corresponds to one of the 22 bytes of the extended Ethernet packet header 700′. Bit vector 705 contains 1s for all valid fields, which are the SA field, DA field, customer VLAN tag field, and Ethertype field. Bit vector 705 contains 0s for all invalid fields, which is only the service VLAN tag field. Thus, Ethernet packet header 700 is represented by the general format {22′b111111_111111_0000_1111_11}.
图8A图示传入的分组的另一示例以太网分组报头的格式800。以太网分组报头800为14字节并且仅包括三个字段:SA字段、DA字段和以太类型字段。以太网分组报头800缺失服务VLAN标记字段和客户VLAN标记字段。具有以太网分组报头800的分组是以太网分组的最小变体。FIG8A illustrates another example Ethernet packet header format 800 for an incoming packet. Ethernet packet header 800 is 14 bytes and includes only three fields: an SA field, a DA field, and an Ethertype field. Ethernet packet header 800 lacks a Service VLAN Tag field and a Customer VLAN Tag field. A packet with Ethernet packet header 800 is a minimal variant of an Ethernet packet.
重写引擎处理以太网报头800,并且确定服务VLAN标记字段和客户VLAN标记字段从以太网分组报头800缺失,并且通过在以太网分组报头800的通用格式的适当位置处包括缺失的服务VLAN标记字段和缺失的客户VLAN标记字段来将以太网分组报头800扩展成它的最大大小22字节。图8B图示扩展的以太网分组报头的通用格式800’。扩展的以太网分组报头800’包括以太网协议的包括缺失的服务VLAN标记字段和缺失的客户VLAN标记字段的所有可能字段。在扩展的以太网分组报头800’中的有效字段是SA字段、DA字段和以太类型字段,因为它们在以太网分组报头800中存在。在扩展的以太网分组报头800’中的无效字段是服务VLAN标记字段和客户VLAN标记字段,因为它们在以太网分组报头800中不存在、而是被添加在扩展的以太网分组报头800’中。The rewrite engine processes Ethernet header 800 and determines that the service VLAN tag field and the customer VLAN tag field are missing from Ethernet packet header 800. It then extends Ethernet packet header 800 to its maximum size of 22 bytes by including the missing service VLAN tag field and the missing customer VLAN tag field at appropriate locations in the general format of Ethernet packet header 800. FIG8B illustrates the general format 800′ of the extended Ethernet packet header. Extended Ethernet packet header 800′ includes all possible fields of the Ethernet protocol, including the missing service VLAN tag field and the missing customer VLAN tag field. Valid fields in extended Ethernet packet header 800′ are the SA field, the DA field, and the Ethertype field, as they exist in Ethernet packet header 800. Invalid fields in extended Ethernet packet header 800′ are the service VLAN tag field and the customer VLAN tag field, as they do not exist in Ethernet packet header 800 but are added to the extended Ethernet packet header 800′.
图8C图示表示图8B的扩展的以太网分组报头800’的位矢量805。位矢量805的每个位对应于扩展的以太网分组报头800’的22字节中的一个字节。位矢量805包含用于所有有效字段的1,这些字段是SA字段、DA字段和以太类型字段。位矢量805包含用于所有无效字段的0,这些字段是服务VLAN标记字段和客户VLAN标记字段。因而,以太网分组报头800由通用格式{22'b111111_111111_0000_0000_11}表示。FIG8C illustrates a bit vector 805 of the extended Ethernet packet header 800′ of FIG8B . Each bit of bit vector 805 corresponds to one of the 22 bytes of the extended Ethernet packet header 800′. Bit vector 805 contains 1s for all valid fields, which are the SA field, the DA field, and the Ethertype field. Bit vector 805 contains 0s for all invalid fields, which are the Service VLAN Tag field and the Customer VLAN Tag field. Thus, Ethernet packet header 800 is represented by the general format {22′b111111_111111_0000_0000_11}.
如图6A-8C中所示,无论传入以太网报头的变化如何,一旦执行将以太网报头扩展成通用格式,字段偏移与最大大小的以太网报头(例如图6A的以太网分组报头600)相同。报头扩展有利地无论传入以太网报头如何都允许相同软件命令集合工作,因为以太网报头被扩展成最大大小的以太网报头。这样,例如修改以太类型字段的命令将无论接收到哪个以太网报头都总是指向相同偏移。As shown in Figures 6A-8C, regardless of variations in the incoming Ethernet header, once the Ethernet header expansion to a common format is performed, the field offsets remain the same as for a maximum-sized Ethernet header (e.g., Ethernet packet header 600 of Figure 6A). Header expansion advantageously allows the same set of software commands to operate regardless of the incoming Ethernet header because the Ethernet header is expanded to the maximum-sized Ethernet header. Thus, a command to modify the EtherType field, for example, will always point to the same offset regardless of which Ethernet header is received.
报头的通用格式产生在修改分组报头方面的硬件和软件灵活性。硬件能够修改分组报头,而不管字段在分组报头内驻留于何处。硬件可以通过软件被编程以支持新协议。软件在用于各种报头协议的硬件表中对通用格式进行编程。The common format of the header creates hardware and software flexibility in modifying the packet header. The hardware can modify the packet header regardless of where the fields reside within the packet header. The hardware can be programmed by software to support new protocols. The software programs the common format in the hardware tables for the various header protocols.
假设1(传入的分组是单标记的以太网分组,传出的分组是无标记的以太网分组):假设网络交换机的输入以太网端口正在接收具有客户VLAN标记的分组,并且分组需要无标记地被转发到输出以太网端口。图9A图示在这一传入以太网端口处接收的分组的示例以太网分组报头的格式900。对于在这一传入以太网端口处接收的分组,软件将以太网报头的通用格式编程为{22'b111111_111111_0000_1111_11}。重写引擎接收报头协议层并且向存储器进行索引,该存储器向硬件告知用于这一报头协议的通用格式是{22'b111111_111111_0000_1111_11}。在这一情况下,硬件预期前12个连续字节(各自标注为1)和将被移位四个字节的接下来六个字节(各自标注为1)。与位矢量中标注为0的四个位对应的四个字节无效。Assumption 1 (Incoming Packet is a Single-Tagged Ethernet Packet, Outgoing Packet is an Untagged Ethernet Packet): Assume that an input Ethernet port of a network switch is receiving packets with a customer VLAN tag, and the packets need to be forwarded untagged to an output Ethernet port. FIG9A illustrates the format 900 of an example Ethernet packet header for a packet received at this incoming Ethernet port. For a packet received at this incoming Ethernet port, the software programs the general format of the Ethernet header as {22'b111111_111111_0000_1111_11}. The rewrite engine receives the header protocol layer and indexes into memory, which tells the hardware that the general format for this header protocol is {22'b111111_111111_0000_1111_11}. In this case, the hardware expects the first 12 consecutive bytes (each labeled 1) and the next six bytes (each labeled 1) to be shifted by four bytes. The four bytes corresponding to the four bits labeled 0 in the bit vector are invalid.
基于通用格式{22'b111111_111111_0000_1111_11},重写引擎将传入报头协议层扩展成图9B中所示的扩展的报头905并且维护针对经扩展的报头层905的每个字节的每字节的位。在图9C中示出用于经扩展的报头905的对应位矢量910。位矢量910向硬件告知哪些字节有效而哪些无效。Based on the general format {22'b111111_111111_0000_1111_11}, the rewrite engine extends the incoming header protocol layer into the extended header 905 shown in FIG9B and maintains a per-byte bit for each byte of the extended header layer 905. The corresponding bit vector 910 for the extended header 905 is shown in FIG9C. The bit vector 910 tells the hardware which bytes are valid and which are invalid.
基于转发判决,在这一假设1中,需要无标记地转发分组。硬件基于传出以太网端口的出口端口类型向命令表进行索引,该命令表告知硬件删除客户VLAN标记。客户VLAN标记总是在固定的偏移、即16处开始。由于命令被应用于通用格式,所以用于删除客户VLAN标记的命令是“从位置16开始删除(客户VLAN标记的)4个字节”。硬件简单地标注这四个字节为无效并且删除它们。图9D图示在通用格式中的无标记的以太网报头915。图9E图示用于无标记的以太网报头915的位矢量920。在去除所有无效字节之后,硬件形成图9F中所示的新报头925。经由传出以太网端口发送出具有新报头925的分组。Based on the forwarding decision, in this assumption 1, the packet needs to be forwarded untagged. The hardware indexes into a command table based on the egress port type of the outgoing Ethernet port, which tells the hardware to remove the customer VLAN tag. The customer VLAN tag always starts at a fixed offset, namely 16. Since the commands are applied to the general format, the command to remove the customer VLAN tag is "delete 4 bytes (of the customer VLAN tag) starting at position 16." The hardware simply marks these four bytes as invalid and deletes them. Figure 9D illustrates the untagged Ethernet header 915 in the general format. Figure 9E illustrates the bit vector 920 for the untagged Ethernet header 915. After removing all invalid bytes, the hardware forms the new header 925 shown in Figure 9F. The packet with the new header 925 is sent out via the outgoing Ethernet port.
假设2(传入的分组是双标记的以太网分组,传出的分组是无标记的以太网分组):假设网络交换机的输入以太网端口接收具有服务VLAN标记和客户VLAN标记的分组,并且分组需要无标记地被转发到输出以太网端口。图10A图示在这一传入以太网端口处接收的分组的示例以太网分组报头的格式1000。对于在这一传入以太网端口处接收的分组,软件将以太网报头的通用格式编程为{22'b111111_111111_1111_1111_11}。重写引擎接收报头协议层并且向存储器进行索引,该存储器向硬件告知用于这一报头协议的通用格式是{22'b111111_111111_1111_1111_11}。在这一情况下,硬件预期所有22个连续字节(各自标注为1)Assumption 2 (Incoming Packet is a Double-Tagged Ethernet Packet, Outgoing Packet is an Untagged Ethernet Packet): Assume that an input Ethernet port of a network switch receives a packet with a service VLAN tag and a customer VLAN tag, and the packet needs to be forwarded untagged to an output Ethernet port. FIG10A illustrates the format 1000 of an example Ethernet packet header for a packet received at this incoming Ethernet port. For a packet received at this incoming Ethernet port, the software programs the general format of the Ethernet header as {22'b111111_111111_1111_1111_11}. The rewrite engine receives the header protocol layer and indexes into memory, which tells the hardware that the general format for this header protocol is {22'b111111_11111_1111_1111_11}. In this case, the hardware expects all 22 consecutive bytes (each labeled 1) to be 1.
基于通用格式{22'b111111_111111_1111_1111_11},重写引擎无需扩展传入报头协议层,因为报头协议已经处于它的最大大小。在图10B中示出用于报头1000的对应位矢量1005。位矢量1005向硬件告知哪些字节有效而哪些无效。Based on the general format {22'b111111_111111_1111_1111_11}, the rewrite engine does not need to expand the incoming header protocol layer because the header protocol is already at its maximum size. The corresponding bit vector 1005 for the header 1000 is shown in Figure 10B. The bit vector 1005 tells the hardware which bytes are valid and which are invalid.
基于转发判决,在这一假设2中,需要无标记地转发分组。硬件基于传出以太网端口的出口端口类型向命令表进行索引,该命令表告知硬件删除客户VLAN标记和服务VLAN标记。客户VLAN标记总是在固定的偏移、即16处开始。相似地,服务VLAN标记总是在固定的偏移、即12处开始。由于命令被应用于通用格式,所以用于删除客户VLAN标记的命令是“从位置16开始删除(客户VLAN标记的)4个字节”,而用于删除服务VLAN标记的命令是“从位置12开始删除(服务VLAN标记的)4个字节”。硬件简单地标注这八个字节为无效并且删除它们。图10C图示通用格式中的无标记的以太网报头1010。图10D图示用于无标记的以太网报头1010的位矢量1015。在去除所有无效字节之后,硬件形成图10E中所示的新报头1020。经由传出以太网端口发送出具有新报头1020的分组。Based on the forwarding decision, in this assumption 2, the packet needs to be forwarded untagged. The hardware indexes into a command table based on the egress port type of the outgoing Ethernet port, which tells the hardware to remove the customer VLAN tag and the service VLAN tag. The customer VLAN tag always starts at a fixed offset, namely 16. Similarly, the service VLAN tag always starts at a fixed offset, namely 12. Since the commands are applied to the universal format, the command to remove the customer VLAN tag is "delete 4 bytes (of the customer VLAN tag) starting at position 16," while the command to remove the service VLAN tag is "delete 4 bytes (of the service VLAN tag) starting at position 12." The hardware simply marks these eight bytes as invalid and deletes them. Figure 10C illustrates the untagged Ethernet header 1010 in the universal format. Figure 10D illustrates the bit vector 1015 for the untagged Ethernet header 1010. After removing all invalid bytes, the hardware forms the new header 1020 shown in Figure 10E. The packet with the new header 1020 is sent out via the outgoing Ethernet port.
假设3(传入的分组是无标记、单标记或者双标记的以太网分组,传出的分组是双标记的以太网分组):假设网络交换机的输入以太网端口正在接收无标记、具有服务VLAN标记、客户VLAN标记或者两个标记的分组,并且分组需要被作为双标记、但是具有新标记而转发到输出以太网端口。如果传入的分组是双标记的,则软件将以太网报头的通用格式编程为{22'b111111_111111_1111_1111_11}。如果传入的分组是无标记的,则软件将以太网报头的通用格式编程为{22'b111111_111111_0000_0000_11}。如果传入的分组是单标记的,则软件将以太网报头的通用格式编程为{22'b111111_111111_0000_1111_11}。Assumption 3 (Incoming packet is an untagged, single-tagged, or double-tagged Ethernet packet, outgoing packet is a double-tagged Ethernet packet): Assume that an input Ethernet port of a network switch is receiving a packet that is untagged, has a service VLAN tag, a customer VLAN tag, or both tags, and the packet needs to be forwarded to an output Ethernet port as a double-tagged packet, but with a new tag. If the incoming packet is double-tagged, the software programs the Ethernet header in the general format of {22'b111111_111111_1111_1111_11}. If the incoming packet is untagged, the software programs the Ethernet header in the general format of {22'b111111_111111_0000_0000_11}. If the incoming packet is single-tagged, the software programs the Ethernet header in the general format of {22'b111111_111111_0000_1111_11}.
基于转发判决,在这一假设3中,需要双标记地转发分组。硬件基于传出以太网端口的出口端口类型向命令表进行索引,该命令表告知硬件替换客户VLAN标记和服务VLAN标记。客户VLAN标记总是在固定的偏移、即16处开始。相似地,服务VLAN标记总是在固定的偏移、即12处开始。对于这些情况中的每个情况,命令相同。由于命令被应用于通用格式,所以命令是“从层数据.位置X向开始位置=12复制4个字节(用于服务VLAN标记)”和“从层数据.位置Y向开始位置=16复制4个字节(用于客户VLAN标记)”,其中从层数据.位置X和层数据.位置Y指定的位置复制内容。Based on the forwarding decision, in this assumption 3, the packet needs to be forwarded with a double tag. The hardware indexes into a command table based on the egress port type of the outgoing Ethernet port, which tells the hardware to replace the customer VLAN tag and the service VLAN tag. The customer VLAN tag always starts at a fixed offset, namely 16. Similarly, the service VLAN tag always starts at a fixed offset, namely 12. For each of these cases, the commands are the same. Since the commands are applied to the common format, the commands are "copy 4 bytes from layerdata.positionX to start position=12 (for service VLAN tag)" and "copy 4 bytes from layerdata.positionY to start position=16 (for customer VLAN tag)", where the content is copied from the locations specified by layerdata.positionX and layerdata.positionY.
如在假设1-3中证明的那样,重写引擎在硬件上被简化并且保持存储器中的软件命令集合为小。因而,为了保持命令而需要的硬件存储器浅。As demonstrated in assumptions 1-3, the rewrite engine is simplified in hardware and keeps the set of software commands in memory small. Thus, the hardware memory required to hold the commands is shallow.
图11图示根据本发明的一些实施例的重写引擎的方法1100。在步骤1105,重写引擎从传入的分组的协议报头检测缺失字段。Figure 11 illustrates a method 1100 of a rewrite engine according to some embodiments of the present invention. At step 1105, the rewrite engine detects missing fields from the protocol header of an incoming packet.
在步骤1110,基于检测,重写引擎将协议报头扩展成用于对应协议的通用格式。通用格式包括协议的所有字段。字段中的每个字段无论协议报头对应于协议的哪个变体都具有相同偏移。重写引擎针对经扩展的协议报头维护位矢量,其中位矢量包括针对经扩展的协议报头的每个字节的每字节的位。重写引擎对于每个有效字段的每个字节标注位为可用,其中每个有效字段是在传入的分组的协议报头中存在的字段。重写引擎对于每个无效字段的每个字节标注位为无效,其中每个无效字段是在传入的分组的协议报头中不存在的字段。At step 1110, based on the detection, the rewrite engine expands the protocol header into a common format for the corresponding protocol. The common format includes all fields of the protocol. Each field in the field has the same offset regardless of which variant of the protocol the protocol header corresponds to. The rewrite engine maintains a bit vector for the expanded protocol header, where the bit vector includes a bit per byte for each byte of the expanded protocol header. The rewrite engine marks a bit as available for each byte of each valid field, where each valid field is a field that exists in the protocol header of the incoming packet. The rewrite engine marks a bit as invalid for each byte of each invalid field, where each invalid field is a field that does not exist in the protocol header of the incoming packet.
在一些实施例中,对于传入的分组的每个协议层执行步骤1105和1110。In some embodiments, steps 1105 and 1110 are performed for each protocol layer of the incoming packet.
图12图示根据本发明的一些实施例的网络交换机的又一方法1200。在一些实施例中,网络交换机允许协议的通用格式的由软件定义的映射并且在网络交换机的存储器中存储由软件定义的映射。网络交换机包括用于使协议报头一般化的重写引擎。在步骤1205,在网络交换机的传入端口处接收分组。FIG12 illustrates another method 1200 for a network switch according to some embodiments of the present invention. In some embodiments, the network switch allows software-defined mapping of common formats for protocols and stores the software-defined mapping in memory of the network switch. The network switch includes a rewrite engine for generalizing protocol headers. In step 1205, a packet is received at an incoming port of the network switch.
在步骤1210,根据用于对应协议的通用格式来使分组的协议报头一般化。如以上说明的那样,硬件根据在网络交换机的存储器中存储的映射中的一个映射来扩展协议报头。用于经扩展的协议报头的位矢量向硬件告知哪些字节有效而哪些字节无效。At step 1210, the protocol header of the packet is generalized according to a common format for the corresponding protocol. As described above, the hardware extends the protocol header according to one of the mappings stored in the memory of the network switch. The bit vector for the extended protocol header tells the hardware which bytes are valid and which are invalid.
在步骤1215,通过将至少一个命令应用于经一般化的协议报头来修改经一般化的协议报头。如以上说明的那样,硬件基于传出以太网端口的出口端口类型向命令表进行索引,以确定用于向协议报头应用的至少一个命令。The generalized protocol header is modified by applying at least one command to the generalized protocol header at step 1215. As explained above, the hardware indexes into the command table based on the egress port type of the outgoing Ethernet port to determine at least one command to apply to the protocol header.
在步骤1220,去除经修改的协议报头的所有无效字节以形成新报头。At step 1220, all invalid bytes of the modified protocol header are removed to form a new header.
在步骤1225,经由网络交换机的传出端口发送出具有新报头的分组。At step 1225, the packet with the new header is sent out via the egress port of the network switch.
图13图示根据本发明的一些实施例的网络交换机的又一方法1300。在步骤1305,网络交换机被配置为包括协议的通用格式的由软件定义的映射。在网络交换机的存储器中存储由软件定义的映射。Figure 13 illustrates another method 1300 of a network switch according to some embodiments of the present invention. At step 1305, the network switch is configured to include a software-defined mapping of a common format for a protocol. The software-defined mapping is stored in a memory of the network switch.
在步骤1310,在网络交换机的传入端口处接收分组。At step 1310, a packet is received at an incoming port of a network switch.
在步骤1315,基于由软件定义的映射中的一个映射使分组的协议报头一般化。At step 1315, the protocol header of the packet is generalized based on one of the mappings defined by the software.
在步骤1320,针对经一般化的协议报头维护位矢量。位矢量包括针对经一般化的协议报头的每个字节的每字节的位。A bit vector is maintained for the generalized protocol header at step 1320. The bit vector includes a bit per byte for each byte of the generalized protocol header.
经一般化的协议报头的优化的表示Optimized representation of generalized protocol headers
每个传入层可以包含任何数目的字节,比如64字节或者128字节或者甚至更大数目的字节。在以上示例中,扩展的以太网报头具有22字节。在位矢量中表示协议层的所有字节不是高效的,因为为最坏情况的协议的分配是存储器密集的。在现代片上系统(SOC)设计中,嵌入式存储器的面积和功率预算通常主导整个芯片预算。作为结果,高效地利用有限的存储器资源是关键的。Each incoming layer can contain any number of bytes, such as 64 bytes or 128 bytes or even a larger number of bytes. In the above example, the extended Ethernet header has 22 bytes. Representing all bytes of the protocol layer in a bit vector is not efficient because the allocation for the worst-case protocol is memory intensive. In modern system-on-chip (SOC) designs, the area and power budget of embedded memory often dominates the overall chip budget. As a result, efficiently utilizing limited memory resources is critical.
如果多数协议具有少数“空洞”或者无效字节,则用连续字节的计数器和表示非连续字节的更小位矢量表示通用格式报头是成本更低的。在一些实施例中,这一更小位矢量的大小通常是固定的,但是大小是可编程的。可以基于协议的统计量调整大小,这些统计量确定为了表示协议而必须存储的非连续字节的最大数目。If most protocols have a few "holes" or invalid bytes, it is more cost-effective to represent the universal format header with a counter of consecutive bytes and a smaller bit vector representing the non-consecutive bytes. In some embodiments, the size of this smaller bit vector is generally fixed, but the size can be programmable. The size can be adjusted based on protocol statistics that determine the maximum number of non-consecutive bytes that must be stored to represent the protocol.
在一些实施例中,在使用包括两个字段的数据结构的优化方式中表示分组的每个通用格式报头:连续_字节字段和位矢量字段。连续_字节字段表示从协议层的开始起的连续有效字节的数目。位矢量字段是协议层的每字节的位表示。位矢量字段示出“空洞”或者无效字节。位矢量字段如果不能容纳所有协议则能够容纳多数协议。因此,优化的表示可以由{连续_字节,位矢量}表示。该数据结构独立于协议报头的大小。In some embodiments, each generic format header of a packet is represented in an optimized manner using a data structure comprising two fields: a continuation_bytes field and a bit vector field. The continuation_bytes field indicates the number of consecutive valid bytes from the beginning of the protocol layer. The bit vector field is a bit representation of each byte of the protocol layer. The bit vector field indicates "holes" or invalid bytes. The bit vector field can accommodate most protocols, if not all. Therefore, the optimized representation can be represented by {continuation_bytes, bit vector}. This data structure is independent of the size of the protocol header.
例如图6B的位矢量605的紧凑表示是{22,00000000_0000_000},这表示从图6A的以太网分组报头600的开始起的22个连续字节。位矢量字段包含全0,因为没有无效字节。For example, a compact representation of the bit vector 605 of Figure 6B is {22,00000000_0000_000}, which represents 22 consecutive bytes from the beginning of the Ethernet packet header 600 of Figure 6A. The bit vector field contains all zeros because there are no invalid bytes.
对于另一示例,图7C的位矢量705的紧凑表示是{12,00001111_1100_000},这表示从图7B的扩展的以太网分组报头300’的开始起的12个连续字节、继而为四个无效字节、然后六个有效字节。For another example, the compact representation of the bit vector 705 of FIG. 7C is {12,00001111_1100_000}, which represents 12 consecutive bytes from the beginning of the extended Ethernet packet header 300' of FIG. 7B, followed by four invalid bytes, and then six valid bytes.
对于又一示例,图8C的位矢量805的紧凑表示是{12,00000000_1100_0000),这表示从图8B的扩展的以太网分组报头800’的开始起的12个连续字节、继而为八个无效字节、然后两个有效字节。For yet another example, the compact representation of the bit vector 805 of FIG. 8C is {12, 000000000_1100_0000), which represents 12 consecutive bytes from the beginning of the extended Ethernet packet header 800′ of FIG. 8B , followed by eight invalid bytes, and then two valid bytes.
图14图示根据本发明的一些实施例的网络交换机的又一方法1400。在步骤1405,获得经扩展的协议报头。如以上讨论的那样,经扩展的协议报头是根据用于对应协议的通用格式而被一般化的传入的分组的协议报头。通常,重写引擎通过从协议报头检测缺失字段并且基于检测根据通用格式扩展协议报头来使协议报头一般化。通用格式包括协议的所有可能字段,其中无论协议报头对应于协议的哪个变体,字段中的每个字段都具有相同偏移。FIG14 illustrates another method 1400 for a network switch according to some embodiments of the present invention. At step 1405, an extended protocol header is obtained. As discussed above, an extended protocol header is a protocol header of an incoming packet that has been generalized according to a common format for a corresponding protocol. Typically, a rewrite engine generalizes a protocol header by detecting missing fields from the protocol header and, based on the detection, extending the protocol header according to the common format. The common format includes all possible fields of the protocol, with each field having the same offset regardless of the protocol variant to which the protocol header corresponds.
在步骤1410,维护经扩展的协议报头的表示。该表示是包括连续_字节字段和位矢量字段的数据结构。A representation of the extended protocol header is maintained at step 1410. The representation is a data structure including a continuation_byte field and a bit vector field.
在步骤1415,将连续_字节字段设置成从经扩展的协议报头的开始起的连续有效字节的数目。At step 1415, the Continue_Bytes field is set to the number of consecutive valid bytes from the start of the extended protocol header.
在步骤1420,针对在连续有效字节之后的每个无效字段的每个字节,将位矢量字段的位标注为不可用。每个无效字段是在传入的分组的协议报头中不存在的字段。At step 1420, for each byte of each invalid field following consecutive valid bytes, a bit of the bit vector field is marked as unavailable. Each invalid field is a field that is not present in the protocol header of the incoming packet.
在步骤1425,针对在连续有效字节之后的每个有效字段的每个字节,将位矢量字段的位标注为可用。每个有效字段是在传入的分组的协议报头中存在的字段。At step 1425, for each byte of each valid field following the consecutive valid bytes, a bit of the bit vector field is marked as available. Each valid field is a field present in the protocol header of the incoming packet.
图15图示根据本发明的一些实施例的网络交换机的又一方法1500。在步骤1505,在网络交换机的传入端口处接收分组。Figure 15 illustrates yet another method 1500 of a network switch according to some embodiments of the present invention.At step 1505, a packet is received at an incoming port of the network switch.
在步骤1510,根据用于对应协议的通用格式使分组的协议报头一般化。通常,重写引擎被配置为使协议报头一般化。At step 1510, the protocol headers of the packets are generalized according to a common format for the corresponding protocol. Typically, the rewrite engine is configured to generalize the protocol headers.
在步骤1515,在独立于协议报头的大小的数据结构中表示经一般化的协议报头。在一些实施例中,数据结构包括连续_字节字段和位矢量字段,其中连续_字节字段表示从协议报头的开始起的连续有效字节的数目,而位矢量字段是协议报头的每字节的位表示。The generalized protocol header is represented in a data structure that is independent of the size of the protocol header at step 1515. In some embodiments, the data structure includes a continuation_bytes field and a bit vector field, wherein the continuation_bytes field indicates the number of consecutive valid bytes from the beginning of the protocol header, and the bit vector field is a bit representation of each byte of the protocol header.
这一数据结构有助于使用于各种协议层的表示一般化并且去除对协议报头层的大小的依赖性。位矢量的紧凑表示有利地减少硬件成本。This data structure helps to generalize the representation for various protocol layers and removes the dependency on the size of the protocol header layer.The compact representation of the bit vectors advantageously reduces hardware costs.
用于报头修改的通用命令General commands for header modification
修改使用向扩展的协议报头应用的通用命令的集合。所有命令因此通用,因为这些命令独立于传入报头(例如大小和协议)。The modification uses a set of common commands that are applied to the extended protocol header. All commands are therefore common since they are independent of the incoming header (eg size and protocol).
表1列举重写引擎用于协议报头修改的通用命令。通用命令的这一小集合被用于报头修改,无论传入的分组报头(例如大小、协议)如何,因为在修改之前分组报头被一般化。通常,通用命令表现为软件编程的微代码。Table 1 lists the generic commands used by the rewrite engine for protocol header modification. This small set of generic commands is used for header modification regardless of the incoming packet header (e.g., size, protocol) because the packet header is normalized before modification. Typically, the generic commands are expressed as microcode for software programming.
表1Table 1
DELETE命令通过使在当前经一般化的协议层内的从Start定位开始的Size个字节无效来删除这些字节。标注表示那些字节的位矢量的位为0。The DELETE command deletes Size bytes starting at the Start position within the current generalized protocol layer by invalidating those bytes, marking the bits of the bit vector representing those bytes as 0.
COPY命令从Source的SourceOffset向当前经一般化的报头层的DestinationOffset复制Size个字节的数据。COPY命令根据数据的有效性在Source中是否有效来使得对应目的地字节有效或者无效。将表示无效字节的位矢量的位标注为0。将表示有效字节的位矢量的位标注为1。COPY命令也可以使用Bitmask用于位掩码操作。COPY命令也可以使用copyConstantBitMask和copyConstantData。如果copyConstantBitMask在位位置处包含“1”,则在对应定位处将来自copyConstantData中的对应定位的字节复制到当前经一般化的报头层中。在一些实施例中,在表中存储常数数据。在一些实施例中,常数数据是由软件定义的。The COPY command copies Size bytes of data from the SourceOffset of the Source to the DestinationOffset of the current generalized header layer. The COPY command makes the corresponding destination byte valid or invalid depending on whether the validity of the data is valid in the Source. The bits of the bit vector representing invalid bytes are marked as 0. The bits of the bit vector representing valid bytes are marked as 1. The COPY command can also use Bitmask for bit mask operations. The COPY command can also use copyConstantBitMask and copyConstantData. If copyConstantBitMask contains "1" at the bit position, the corresponding positioned bytes from copyConstantData are copied to the current generalized header layer at the corresponding position. In some embodiments, constant data is stored in a table. In some embodiments, constant data is defined by software.
MOVE命令将当前经一般化的协议层内的Size个字节从StartOffset移动到DestinationOffset。MOVE命令根据数据的有效性在Source中是否有效来使对应目的地字节有效或者无效,并且使源字节无效。将表示无效字节的位矢量的位标注为0。将表示有效字节的位矢量的位标注为1。The MOVE command moves Size bytes within the current generalized protocol layer from StartOffset to DestinationOffset. The MOVE command validates or invalidates the corresponding destination bytes, depending on whether the data is valid in Source, and invalidates the source bytes. Bits in the bit vector representing invalid bytes are marked as 0. Bits in the bit vector representing valid bytes are marked as 1.
通过使用至少一个计数器,针对执行的所有操作,对添加或者删除的字节的数目进行计数。至少一个计数器是硬件计数器。备选地,至少一个计数器是软件计数器。至少一个计数器出于统计目的和出于其它原因而保持跟踪计数。在一些实施例中,重写引擎对两个位矢量执行XOR操作——原有的位矢量和修改的位矢量——以向硬件告知多少位改变,这用于考虑删除或者添加的字节的数目。The number of bytes added or deleted is counted for all operations performed using at least one counter. The at least one counter is a hardware counter. Alternatively, the at least one counter is a software counter. The at least one counter keeps track of the count for statistical purposes and for other reasons. In some embodiments, the rewrite engine performs an XOR operation on two bit vectors—the original bit vector and the modified bit vector—to inform the hardware of how many bits have changed, which is used to account for the number of bytes deleted or added.
图16图示根据本发明的一些实施例的重写引擎的另一方法1600。重写引擎是网络交换机的部分并且在分组从网络交换机被发送出之前修改它们。在步骤1605,根据用于分组的每个协议报头的通用格式使该协议报头一般化。通用格式包括协议的所有可能字段。这样,无论协议报头对应于协议的哪个变体,字段中的每个字段都具有相同偏移。每个经一般化的协议报头包括位矢量。位矢量包括针对经一般化的协议报头的每个字节的每字节的位。位矢量包括对于无效字段而被标注为0的位和对于有效字段而被标注为1的位。这里,无效字段是在接收的分组的协议报头中不存在的字段,而有效字段是在接收的分组的协议报头中存在的字段。Figure 16 illustrates another method 1600 of a rewrite engine according to some embodiments of the present invention. The rewrite engine is part of a network switch and modifies packets before they are sent out of the network switch. In step 1605, the protocol header is generalized according to a common format for each protocol header of the packet. The common format includes all possible fields of the protocol. In this way, no matter which variant of the protocol the protocol header corresponds to, each field has the same offset. Each generalized protocol header includes a bit vector. The bit vector includes a bit for each byte of the generalized protocol header. The bit vector includes bits marked as 0 for invalid fields and bits marked as 1 for valid fields. Here, an invalid field is a field that does not exist in the protocol header of the received packet, and a valid field is a field that exists in the protocol header of the received packet.
在步骤1610,使用来自在网络交换机的存储器中存储的通用命令集合的至少一个命令以修改至少一个经一般化的协议报头。对至少一个经一般化的协议报头的修改是基于网络交换机的传出端口的出口端口类型。对至少一个经一般化的协议报头的修改造成位矢量被更新。At step 1610, at least one command from a set of general commands stored in a memory of the network switch is used to modify at least one generalized protocol header. The modification of the at least one generalized protocol header is based on an egress port type of an egress port of the network switch. The modification of the at least one generalized protocol header causes a bit vector to be updated.
由于不管传入的分组报头如何,通用命令集合都被用于报头修改,所以通用命令集合可以被用来修改协议的第一变体的分组报头和修改协议的第二变体的分组报头。相似地,通用命令集合可以被用来修改第一协议的分组报头和修改第二协议的分组报头。Since the common command set is used for header modification regardless of the incoming packet header, the common command set can be used to modify the packet header of the first variant of the protocol and to modify the packet header of the second variant of the protocol. Similarly, the common command set can be used to modify the packet header of the first protocol and to modify the packet header of the second protocol.
图17图示根据本发明的一些实施例的网络交换机的又一方法1700。在步骤1705,在网络交换机的存储器中维护通用命令集合。Figure 17 illustrates yet another method 1700 of a network switch according to some embodiments of the present invention. At step 1705, a common command set is maintained in a memory of the network switch.
在步骤1710,在网络交换机的传入端口处接收分组。At step 1710, a packet is received at an incoming port of a network switch.
在步骤1715,根据用于分组的每个协议报头的通用格式使该协议报头一般化。检测从分组的协议报头的缺失字段。基于检测,通过包括缺失字段来将协议报头扩展成通用格式。每个经一般化的协议报头包括位矢量,该位矢量具有对于无效字段被标注为0的位和对于有效字段被标注为1的位。这里,无效字段是在接收的分组的协议报头中不存在的字段,而有效字段是在接收的分组的协议报头中存在的字段。At step 1715, each protocol header of the packet is generalized according to a common format for the protocol header. Missing fields from the protocol header of the packet are detected. Based on the detection, the protocol header is expanded to the common format by including the missing fields. Each generalized protocol header includes a bit vector having bits marked as 0 for invalid fields and bits marked as 1 for valid fields. Here, an invalid field is a field that is not present in the protocol header of the received packet, and a valid field is a field that is present in the protocol header of the received packet.
在步骤1720,通过向经一般化的协议报头中的至少一个经一般化的协议报头应用来自通用命令集合的至少一个命令,来修改经一般化的协议报头,由此更新位矢量。At step 1720, the generalized protocol headers are modified by applying at least one command from the common command set to at least one of the generalized protocol headers, thereby updating the bit vector.
在步骤1725,基于更新的位矢量,形成新协议报头。At step 1725, a new protocol header is formed based on the updated bit vector.
在步骤1730,经由网络交换机的传出端口发射具有新协议报头的分组。在一些实施例中,在发射具有新协议报头的分组之前,针对执行的所有操作,对添加或者删除的字节的数目进行计数。The packet with the new protocol header is transmitted via the egress port of the network switch at step 1730. In some embodiments, before transmitting the packet with the new protocol header, the number of bytes added or deleted is counted for all operations performed.
使用位矢量来使经修改的协议报头塌缩Using bit vectors to collapse modified protocol headers
重写引擎不仅使用用于每个协议报头的位矢量来允许修改基于通用格式的协议报头的扩展,重写引擎也使用位矢量来允许将协议报头从通用格式塌缩成“规则”报头。通常,在位矢量中的每个位表示经一般化的协议报头的字节。在位矢量中被标注为0的位对应于无效字节,而在位矢量中被标注为1的位对应于有效字节。重写引擎使用位矢量来去除在已经对经一般化的协议报头操作所有命令之后的所有无效字节,以由此形成新协议报头。重写引擎因此使用位矢量来允许分组的协议报头的扩展和塌缩,由此通过使用通用命令集合而实现分组的灵活修改。The rewrite engine not only uses the bit vector for each protocol header to allow modification of the extension of the protocol header based on the general format, but also uses the bit vector to allow the protocol header to be collapsed from the general format into a "regular" header. In general, each bit in the bit vector represents a byte of the generalized protocol header. Bits marked as 0 in the bit vector correspond to invalid bytes, while bits marked as 1 in the bit vector correspond to valid bytes. The rewrite engine uses the bit vector to remove all invalid bytes after all commands have been operated on the generalized protocol header to thereby form a new protocol header. The rewrite engine therefore uses the bit vector to allow the expansion and collapse of the protocol header of the packet, thereby achieving flexible modification of the packet by using a general set of commands.
例如回顾假设1,图9E的位矢量920表示在已经向图9B的经一般化的协议报头905应用删除命令之后的图9D的修改的协议报头915。在这一假设1中,删除客户VLAN标记,由此使客户VLAN标记的四个字节无效。这样,将位矢量920中的与客户VLAN标记对应的位标注为0。在已经操作所有命令、即在假设1中的删除命令之后,重写引擎使用位矢量920来去除所有无效字节,由此使位矢量920塌缩。基于塌缩的位矢量形成新协议报头。图9F图示在去除所有无效字节之后的新协议报头925。经由传出以太网端口发送出具有新报头925的在假设1中的分组。For example, referring back to Hypothesis 1, bit vector 920 of FIG. 9E represents the modified protocol header 915 of FIG. 9D after a delete command has been applied to the generalized protocol header 905 of FIG. 9B . In this Hypothesis 1, the customer VLAN tag is deleted, thereby invalidating four bytes of the customer VLAN tag. Thus, the bits corresponding to the customer VLAN tag in bit vector 920 are marked as 0. After all commands have been executed, namely the delete command in Hypothesis 1, the rewrite engine uses bit vector 920 to remove all invalid bytes, thereby collapsing bit vector 920. A new protocol header is formed based on the collapsed bit vector. FIG. 9F illustrates the new protocol header 925 after all invalid bytes have been removed. The packet in Hypothesis 1 with the new header 925 is transmitted via the outgoing Ethernet port.
对于另一示例,回顾假设2,图10D的位矢量1015表示在已经向图10A的协议报头1000应用删除命令之后的图10C的修改的协议报头1010。在这一假设2中,删除服务VLAN标记和客户VLAN标记,由此使服务VLAN标记的四个字节和客户VLAN标记的四个字节无效。这样,将位矢量1015中的与服务VLAN标记和客户VLAN标记对应的位标注为0。在已经操作所有命令、即在假设2中的两个删除命令之后,重写引擎使用位矢量1015来去除所有无效字节,由此使位矢量1015塌缩。基于塌缩的位矢量形成新协议报头。图10E图示在去除所有无效字节之后的新协议报头1020。经由传出以太网端口发送出具有新报头1020的在假设2中的分组。For another example, referring back to Hypothesis 2, bit vector 1015 of FIG. 10D represents the modified protocol header 1010 of FIG. 10C after a delete command has been applied to protocol header 1000 of FIG. 10A . In this Hypothesis 2, the service VLAN tag and the customer VLAN tag are deleted, thereby invalidating four bytes of the service VLAN tag and four bytes of the customer VLAN tag. Thus, the bits corresponding to the service VLAN tag and the customer VLAN tag in bit vector 1015 are marked as 0. After all commands have been executed, namely the two delete commands in Hypothesis 2, the rewrite engine uses bit vector 1015 to remove all invalid bytes, thereby collapsing bit vector 1015. A new protocol header is formed based on the collapsed bit vector. FIG. 10E illustrates the new protocol header 1020 after all invalid bytes have been removed. The packet in Hypothesis 2 with the new header 1020 is transmitted via the outgoing Ethernet port.
图18图示根据本发明的一些实施例的重写引擎的又一方法1800。重写引擎是网络交换机的部分并且在分组从网络交换机被发送出之前修改它们。在步骤1805,针对每个经一般化的协议报头维护位矢量。经一般化的协议报头是扩展成通用格式的分组的协议报头。通用格式包括协议的所有可能字段。无论协议报头对应于协议的哪个变体,字段中的每个字段都具有相同偏移。位矢量包括针对经一般化的协议报头的每个字节的每字节的位。FIG18 illustrates another method 1800 of a rewrite engine according to some embodiments of the present invention. The rewrite engine is part of a network switch and modifies packets before they are sent out of the network switch. At step 1805, a bit vector is maintained for each generalized protocol header. A generalized protocol header is a protocol header for a packet expanded into a general format. The general format includes all possible fields of the protocol. Regardless of which variant the protocol header corresponds to, each field has the same offset. The bit vector includes a bit per byte for each byte of the generalized protocol header.
在步骤1810,基于对至少一个经一般化的协议报头的修改来更新位矢量。该修改使用来自在网络交换机的存储器中存储的通用命令集合的至少一个命令来修改至少一个经一般化的协议报头。At step 1810, a bit vector is updated based on a modification to at least one generalized protocol header.The modification modifies the at least one generalized protocol header using at least one command from a set of general commands stored in a memory of the network switch.
在步骤1815,使用经更新的位矢量来压缩至少一个经一般化的协议报头。在一些实施例中,在步骤1815之前,对位矢量和更新的位矢量执行XOR操作以确定多少位改变,这允许重写引擎考虑删除和添加的字节。At least one generalized protocol header is compressed using the updated bit vector at step 1815. In some embodiments, prior to step 1815, an XOR operation is performed on the bit vector and the updated bit vector to determine how many bits changed, which allows the rewrite engine to account for deleted and added bytes.
图19图示根据本发明的一些实施例的网络交换机的又一方法1900。在步骤1905,在网络交换机的传入端口处接收分组。Figure 19 illustrates yet another method 1900 of a network switch according to some embodiments of the present invention.At step 1905, a packet is received at an incoming port of the network switch.
在步骤1910,根据用于分组的每个协议报头的通用格式使该协议报头一般化。检测从分组的协议报头的缺失字段。基于检测,通过包括缺失字段来将协议报头扩展成通用格式。At step 1910, the protocol header is generalized according to a common format for each protocol header of the packet. Missing fields are detected from the protocol header of the packet. Based on the detection, the protocol header is extended to the common format by including the missing fields.
在步骤1915,针对每个经一般化的协议报头维护位矢量。位矢量包括对于无效字段而标注为0的位和对于有效字段而标注为1的位。A bit vector is maintained for each generalized protocol header at step 1915. The bit vector includes bits marked as 0 for invalid fields and bits marked as 1 for valid fields.
在步骤1920,修改经一般化的协议报头中的至少一个经一般化的协议报头,由此更新位矢量。该修改使用来自在网络交换机的存储器中存储的通用命令集合的至少一个命令以修改至少一个经一般化的协议报头。对至少一个经一般化的协议报头的修改是基于网络交换机的传出端口的出口端口类型。At step 1920, at least one of the generalized protocol headers is modified, thereby updating the bit vector. The modification uses at least one command from a set of generalized commands stored in a memory of the network switch to modify the at least one generalized protocol header. The modification of the at least one generalized protocol header is based on an egress port type of an egress port of the network switch.
在步骤1925,通过移位经更新的位矢量来去除在经更新的位矢量中的标注为0的每个位,由此使经更新的位矢量塌缩。At step 1925 , the updated bit vector is collapsed by shifting the updated bit vector to remove each bit marked as 0 in the updated bit vector.
在步骤1930,基于塌缩的位矢量形成紧凑协议报头。经由网络交换机的传出端口发射至少具有紧凑协议报头的分组。在一些实施例中,在发射分组之前,对针对执行的所有操作而添加或者删除的字节数目进行计数。At step 1930, a compact protocol header is formed based on the collapsed bit vector. The packet with at least the compact protocol header is transmitted via an egress port of the network switch. In some embodiments, before transmitting the packet, the number of bytes added or deleted for all operations performed is counted.
指针结构Pointer structure
指针结构可以被用来提取在用于经一般化的传入的分组内的不同协议层并且在协议层的修改之后重建分组。指针结构包括N+1个层指针和分组的所有报头的总大小。通常,指针结构初始地用如下数据来更新,该数据由解析器引擎提供以供重写引擎用来将分组拆分成各个层并且随后智能地将它们拼接回到一起。在分组被拆分成各个层之后,重写引擎使协议报头一般化、修改经一般化的协议报头并且通过去除所有无效字段来压缩经一般化的协议报头。层指针在每个层被修改之后由重写引擎更新。这些更新的层指针被用来在从网络交换机发送出分组之前将不同协议层拼接回到一起。The pointer structure can be used to extract the different protocol layers within the generalized incoming packet and reconstruct the packet after the modification of the protocol layers. The pointer structure includes N+1 layer pointers and the total size of all headers of the packet. Typically, the pointer structure is initially updated with the following data, which is provided by the parser engine for the rewrite engine to use to split the packet into various layers and then intelligently splice them back together. After the packet is split into various layers, the rewrite engine generalizes the protocol header, modifies the generalized protocol header, and compresses the generalized protocol header by removing all invalid fields. The layer pointers are updated by the rewrite engine after each layer is modified. These updated layer pointers are used to splice the different protocol layers back together before sending the packet out of the network switch.
图20图示根据本发明的一些实施例的层结构的示例图2000。假设传入的分组包括以下协议层:专有报头、以太网、IPv4、UDP、VxLAN和以太网。也假设网络交换机的解析器引擎能够解析上至八层而重写引擎仅能修改前N个、比如N=4个协议层(因为软件要求和/或硬件能力)。在一些实施例中,解析器引擎向重写引擎提供数据,诸如分组的每个协议报头的开始位置。FIG20 illustrates an example diagram 2000 of a layer structure according to some embodiments of the present invention. Assume that an incoming packet includes the following protocol layers: proprietary header, Ethernet, IPv4, UDP, VxLAN, and Ethernet. Also assume that the parser engine of the network switch is capable of parsing up to eight layers while the rewrite engine can only modify the first N, say N=4, protocol layers (due to software requirements and/or hardware capabilities). In some embodiments, the parser engine provides data to the rewrite engine, such as the starting position of each protocol header of the packet.
由于重写引擎能够修改分组的前四个协议层,所以重写引擎仅使用来自解析器引擎的相关数据、即关于如下前四个协议层的数据:专有报头、以太网、IPv4和UDP。使用这一数据,初始化用于分组的指针结构:设置为0的层指针0,这是在分组内的用于专有报头的起始位置(即层0),设置为16的层指针1,这是在分组内的用于以太网报头的起始位置(即层1),设置成36的层指针2,这是在分组内的用于IPv4报头的起始位置(即层2),设置成48的层指针3,这是在分组内的用于UDP报头的起始位置(即层3),以及设置成56的层指针4,这是用于重写引擎不修改的报头的剩余部分的起始位置。在一些实施例中,重写引擎计算报头的大小并且将报头大小(即所有报头的总大小)设置成223。Since the rewrite engine is able to modify the first four protocol layers of a packet, the rewrite engine only uses the relevant data from the parser engine, namely data about the first four protocol layers as follows: proprietary header, Ethernet, IPv4 and UDP. Using this data, the pointer structure for the packet is initialized: layer pointer 0 is set to 0, which is the starting position within the packet for the proprietary header (i.e., layer 0), layer pointer 1 is set to 16, which is the starting position within the packet for the Ethernet header (i.e., layer 1), layer pointer 2 is set to 36, which is the starting position within the packet for the IPv4 header (i.e., layer 2), layer pointer 3 is set to 48, which is the starting position within the packet for the UDP header (i.e., layer 3), and layer pointer 4 is set to 56, which is the starting position for the remainder of the header that the rewrite engine does not modify. In some embodiments, the rewrite engine calculates the size of the header and sets the header size (i.e., the total size of all headers) to 223.
通过使用层指针,重写引擎如以上讨论的那样一般化前四个协议层(即专用报头、以太网、IPv4、UDP)以供修改。在修改之后,重写引擎通过去除所有无效字节来压缩修改的协议报头。通常,在修改协议报头之后更新层指针。By using the layer pointer, the rewrite engine generalizes the first four protocol layers (i.e., private header, Ethernet, IPv4, UDP) as discussed above for modification. After modification, the rewrite engine compresses the modified protocol header by removing all invalid bytes. Typically, the layer pointer is updated after modifying the protocol header.
层指针形成尾指针。尾指针与报头大小一起与报头的正文关联,该正文是报头的未修改的并且向前输送的用于随后拼接的部分。在执行所有修改并且压缩修改的协议报头之后,修改的层指针用来将修改的报头与报头的正文拼接回到一起。The layer pointer forms the tail pointer. The tail pointer, along with the header size, is associated with the body of the header, which is the portion of the header that is unmodified and forwarded for subsequent splicing. After all modifications have been performed and the modified protocol header has been compressed, the modified layer pointer is used to splice the modified header back together with the body of the header.
重写引擎可以限于重写引擎可以修改的层数。在一些实施例中,重写引擎也可以限于重写引擎可以将任何给定的协议层扩展成多少。在这样的实施例中,重写引擎通过将两个相邻层指针相减来提取协议层的大小。如果层大小超过重写引擎的硬件能力,则重写引擎简单地使用先前的层指针并且智能地形成正文。The rewrite engine can be limited to the number of layers it can modify. In some embodiments, the rewrite engine can also be limited to how much it can expand any given protocol layer. In such an embodiment, the rewrite engine extracts the size of a protocol layer by subtracting two adjacent layer pointers. If the layer size exceeds the rewrite engine's hardware capabilities, the rewrite engine simply uses the previous layer pointer and intelligently forms the body.
假设协议层不能被扩展多于40字节,但是关联协议的最大变体是64字节。在一些实施例中,重写引擎将报头协议扩展成最大40字节以供修改。在修改之后,使用层指针,重写引擎能够相似地将剩余字节拼接到修改的字节。Assume that the protocol layer cannot be extended by more than 40 bytes, but the maximum variant of the associated protocol is 64 bytes. In some embodiments, the rewrite engine extends the header protocol to a maximum of 40 bytes for modification. After the modification, using the layer pointer, the rewrite engine can similarly splice the remaining bytes to the modified bytes.
使用层指针显著地减少硬件逻辑和复杂性,因为它仅需应对一个给定的协议层。硬件命令的范围限于给定的层。由于命令引擎对先前层和在它之后的层无依赖性,所以如果每层需要更多命令则可以用多通过方式使用命令硬件。换而言之,由于命令没有与命令关联的内部状态,所以可以并行地使用多个命令。相似地,可以并行地修改多层。Using layer pointers significantly reduces hardware logic and complexity, as it only needs to address a given protocol layer. Hardware commands are limited in scope to a given layer. Since the command engine has no dependencies on previous or subsequent layers, the command hardware can be used in a multi-pass fashion if more commands are required per layer. In other words, since commands have no internal state associated with them, multiple commands can be used in parallel. Similarly, multiple layers can be modified in parallel.
图21图示根据本发明的一些实施例的重写引擎的又一方法2100。重写引擎是网络交换机的部分并且在分组从网络交换机被发送出之前修改它们。在步骤2105,针对每个分组维护指针结构。指针结构包括层指针和分组的所有报头的总大小。层指针中的每个层指针对应于分组中的关联层的开始位置。FIG21 illustrates another method 2100 of a rewrite engine according to some embodiments of the present invention. The rewrite engine is part of a network switch and modifies packets before they are sent out of the network switch. In step 2105, a pointer structure is maintained for each packet. The pointer structure includes a layer pointer and the total size of all headers of the packet. Each layer pointer corresponds to the starting position of the associated layer in the packet.
指针结构包括N+1个层指针。重写引擎修改分组的N个层。层指针形成尾指针。有总大小的尾指针指示报头的正文。报头的正文是报头的未被重写引擎修改的部分。The pointer structure consists of N+1 layer pointers. The rewrite engine modifies N layers of the packet. The layer pointers form the tail pointer. The tail pointer, along with the total size, indicates the header body. The header body is the portion of the header that is not modified by the rewrite engine.
在步骤2110,基于层指针拆分分组的层以供层修改。检测从分组的协议报头的缺失字段。基于检测,将协议报头扩展成用于对应协议的通用格式。通用格式包括协议的所有可能字段。无论协议报头对应于协议的哪个变体,字段中的每个字段都具有相同偏移。每个经一般化的协议报头包括位矢量,该位矢量具有对于无效字段被标注为不可用或者0的位和对于有效字段被标注为可用或者1的位。使用来自通用命令集合的至少一个命令来修改经一般化的协议报头。通常,在修改之后更新位矢量。At step 2110, the layers of the packet are split for layer modification based on the layer pointers. Missing fields are detected from the protocol header of the packet. Based on the detection, the protocol header is expanded into a common format for the corresponding protocol. The common format includes all possible fields of the protocol. Regardless of the protocol variant to which the protocol header corresponds, each field has the same offset. Each generalized protocol header includes a bit vector having bits marked as unavailable or 0 for invalid fields and bits marked as available or 1 for valid fields. The generalized protocol header is modified using at least one command from the common command set. Typically, the bit vector is updated after the modification.
在步骤2115,基于层修改来更新层指针。In step 2115, the layer pointer is updated based on the layer modification.
在步骤2120,基于经更新的层指针将层拼接回到一起。At step 2120, the layers are stitched back together based on the updated layer pointers.
图22图示根据本发明的一些实施例的网络交换机的又一方法2200。在步骤2205,在网络交换机的传入端口处接收分组。Figure 22 illustrates yet another method 2200 of a network switch according to some embodiments of the present invention.At step 2205, a packet is received at an incoming port of the network switch.
在步骤2210,使用指针结构来分离分组的协议层。指针结构包括指向分组的N+1个位置的N+1个层指针和分组的所有报头的总大小。位置包括协议层的起始定位。基于分组的解析的数据来初始化指针结构。At step 2210, a pointer structure is used to separate the protocol layers of the packet. The pointer structure includes N+1 layer pointers pointing to N+1 locations in the packet and the total size of all headers of the packet. The location includes the starting position of the protocol layer. The pointer structure is initialized based on the parsed data of the packet.
在步骤2215,使经分离的协议层一般化以进行修改。对于每层,提取层的大小以确定该大小是否超过用于修改该层的硬件能力。通过将在指针结构中的两个相邻层指针相减来提取该大小。基于该确定,使用两个相邻层指针中的第一层指针并且形成正文。At step 2215, the separated protocol layers are generalized for modification. For each layer, the size of the layer is extracted to determine whether the size exceeds the hardware capabilities for modifying the layer. The size is extracted by subtracting two adjacent layer pointers in the pointer structure. Based on this determination, the first of the two adjacent layer pointers is used and the body is formed.
在步骤2220,基于修改来更新指针结构。At step 2220, the pointer structure is updated based on the modification.
在步骤2225,使用经更新的指针结构来智能地将经修改的协议层拼接回到一起以形成新协议报头。At step 2225, the updated pointer structure is used to intelligently stitch the modified protocol layers back together to form a new protocol header.
在步骤2230,经由网络交换机的传出端口发送出具有新协议报头的分组。At step 2230, the packet with the new protocol header is sent out via the egress port of the network switch.
本领域普通技术人员将认识到,也存在其它使用和优点。尽管已经参照许多具体细节描述本发明,但是本领域普通技术人员将认识到,可以在其它具体形式中体现本发明而不脱离本发明的精神实质。因此,本领域普通技术人员将理解到,本发明不受前述示例细节限制,而是将由所附权利要求限定。Those skilled in the art will recognize that other uses and advantages exist. Although the present invention has been described with reference to numerous specific details, those skilled in the art will recognize that the present invention can be embodied in other specific forms without departing from the spirit of the invention. Therefore, those skilled in the art will understand that the present invention is not limited by the foregoing illustrative details, but is defined by the appended claims.
Claims (24)
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US14/309,659 US9635146B2 (en) | 2014-06-19 | 2014-06-19 | Method of using bit vectors to allow expansion and collapse of header layers within packets for enabling flexible modifications and an apparatus thereof |
US14/309,659 | 2014-06-19 |
Publications (2)
Publication Number | Publication Date |
---|---|
HK1220827A1 HK1220827A1 (en) | 2017-05-12 |
HK1220827B true HK1220827B (en) | 2021-07-16 |
Family
ID=
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US12381963B2 (en) | Method of using bit vectors to allow expansion and collapse of header layers within packets for enabling flexible modifications and an apparatus thereof | |
KR102380012B1 (en) | Method of modifying packets to a generic format for enabling programmable modifications and an apparatus thereof | |
US9473601B2 (en) | Method of representing a generic format header using continuous bytes and an apparatus thereof | |
KR102368168B1 (en) | Method of splitting a packet into individual layers for modification and intelligently stitching layers back together after modification and an apparatus thereof | |
CN105187330B (en) | Method for identifying packet structure using unique packet identifier and network switch | |
KR102368166B1 (en) | Method of using generic modification instructions to enable flexible modifications of packets and an apparatus thereof | |
HK1220827B (en) | A method of using bit vectors to allow expansion and collapse of header layers within packets for enabling flexible modifications and an apparatus thereof | |
HK1220834B (en) | A method of modifying packets to a generic format for enabling programmable modifications and an apparatus thereof | |
HK1219186B (en) | A method of representing a generic format header using continuous bytes and an apparatus thereof |