WO2015131720A1 - 报文处理方法及装置 - Google Patents

报文处理方法及装置 Download PDF

Info

Publication number
WO2015131720A1
WO2015131720A1 PCT/CN2015/071634 CN2015071634W WO2015131720A1 WO 2015131720 A1 WO2015131720 A1 WO 2015131720A1 CN 2015071634 W CN2015071634 W CN 2015071634W WO 2015131720 A1 WO2015131720 A1 WO 2015131720A1
Authority
WO
WIPO (PCT)
Prior art keywords
keyword
parameter
packet
flow table
location
Prior art date
Application number
PCT/CN2015/071634
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 WO2015131720A1 publication Critical patent/WO2015131720A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/22Parsing or analysis of headers

Definitions

  • the present invention relates to a communication technology, and in particular, to a message processing method and apparatus.
  • the forwarding device after receiving the packet, the forwarding device needs to determine the format of the packet data, for example, determining that the packet is an Internet Protocol (IP), or a multi-protocol label exchange (full name in English). Multiple protocol Label Switching (abbreviated as MPLS) packets, so that the packets are processed according to the protocol.
  • IP Internet Protocol
  • MPLS Multiple protocol Label Switching
  • the switch after receiving the Ethernet frame, the switch needs to determine, according to the port table, that the protocol of the Ethernet frame is a media access control (English full name is Media Access Control, abbreviated as MAC) protocol. Then, the switch parses the MAC protocol header of the Ethernet frame according to the MAC protocol, thereby acquiring a destination MAC protocol address of the Ethernet frame.
  • MAC Media Access Control
  • an embodiment of the present invention provides a packet processing method and apparatus. Before processing a message, it is not necessary to understand the data format of the message.
  • the above technical solutions are highly flexible and versatile, helping to quickly deploy new services.
  • a packet processing method including:
  • the central processing unit (English for the central processing unit, abbreviated as CPU) obtains the location parameter of the keyword (English name is key) and the identifier of the flow table (English name is flow table), and the position parameter of the key is used to indicate The location of the key in the message;
  • the CPU acquires the keyword from the packet according to the location parameter of the keyword
  • the CPU searches for and describes the flow table according to the keyword and the identifier of the flow table.
  • the flow table entry matched by the keyword;
  • the CPU processes the message according to the flow table entry.
  • the location parameter of the keyword includes a first parameter and a second parameter
  • the first parameter is an offset value of the start bit of the keyword from a packet header of the packet (the English name is offset), and the second parameter is an end bit distance of the keyword.
  • the offset of the packet header of the packet or
  • the first parameter is an offset value of a start bit of the keyword from a packet header of the packet
  • the second parameter is a length value of the keyword (the English name is length);
  • the first parameter is an offset value of an end bit of the keyword from a packet header of the packet
  • the second parameter is a length value of the keyword
  • a second aspect provides a message processing apparatus, including: a first virtual machine;
  • the first virtual machine includes:
  • a first acquiring unit configured to acquire a location parameter of the first keyword and an identifier of the first flow table, where the location parameter of the first keyword is used to indicate a location of the first keyword in the packet;
  • a second acquiring unit configured to acquire the first keyword from the packet according to the location parameter of the first keyword acquired by the first acquiring unit
  • a first searching unit configured to search, in the first flow table, according to the first keyword acquired by the second acquiring unit and the identifier of the first flow table acquired by the first acquiring unit The flow table entry matched by the first keyword;
  • a first processing unit configured to process the message according to the flow table entry in the first flow table that is searched by the first searching unit to obtain a first packet.
  • the location parameter of the first keyword includes a first parameter and a second parameter
  • the first parameter is an offset value of a start bit of the first keyword from a packet header of the packet
  • the second parameter is an end bit distance of the first keyword from the packet The offset of the header of the message
  • the first parameter is an offset value of a start bit of the first keyword from a packet header of the packet, and the second parameter is a length value of the first keyword;
  • the first parameter is an offset value of an end bit of the first keyword from a packet header of the packet
  • the second parameter is a length value of the first keyword
  • a second possible implementation of the second aspect including: a second virtual machine
  • the first processing unit is specifically configured to perform an operation of outputting the first message to the second virtual machine and an operation of outputting a flow table jump GOTO_TABLE instruction to the second virtual machine, where the flow table jumps
  • the instruction includes an identifier of the second flow table
  • the second virtual machine includes a receiving unit, configured to receive the first packet and the flow table jump instruction output by the first virtual machine.
  • a third possible implementation of the second aspect including:
  • a third acquiring unit configured to acquire a location parameter of the second keyword, and obtain an identifier of the second flow table from the flow table jump instruction, where the location parameter of the second keyword is used to indicate the first The location of the two keywords in the message;
  • a fourth acquiring unit configured to acquire the second keyword from the first packet received by the receiving unit according to the location parameter of the second keyword acquired by the third acquiring unit;
  • a second searching unit configured to search and search the second flow table according to the second keyword acquired by the fourth acquiring unit and the identifier of the second flow table acquired by the third acquiring unit a flow table entry matched by the second keyword;
  • a second processing unit configured to process the first packet according to the flow table entry in the second flow table that is searched by the second searching unit.
  • a fourth possible implementation manner of the second aspect is further provided, where the location parameter of the second keyword includes a third parameter and a fourth parameter;
  • the third parameter is an offset value of a start bit of the second keyword from a packet header of the packet
  • the fourth parameter is an end bit distance of the second keyword from the packet The offset of the header of the message
  • the third parameter is an offset value of a start bit of the second keyword from a packet header of the packet, and the fourth parameter is a length value of the second keyword;
  • the third parameter is an offset value of an end bit of the second keyword from a packet header of the packet
  • the fourth parameter is a length value of the second keyword
  • a CPU including:
  • a first obtaining unit configured to acquire a location parameter of the keyword and an identifier of the flow table, where the location parameter of the keyword is used to indicate a location of the keyword in the packet;
  • a second acquiring unit configured to acquire the keyword from the packet according to the location parameter of the keyword acquired by the first acquiring unit
  • a searching unit configured to search, in the flow table, a flow table matching the keyword according to the keyword acquired by the second obtaining unit and the identifier of the flow table acquired by the first acquiring unit Entry;
  • a processing unit configured to process the packet according to the flow table entry searched by the searching unit.
  • the location parameter of the keyword includes a first parameter and a second parameter
  • the first parameter is an offset value of a start bit of the keyword from a packet header of the packet
  • the second parameter is a packet header of the end point of the keyword from the packet. Offset value
  • the first parameter is an offset value of a start bit of the keyword from a packet header of the packet, and the second parameter is a length value of the keyword;
  • the first parameter is an offset value of an end bit of the keyword from a packet header of the packet
  • the second parameter is a length value of the keyword
  • the CPU can acquire the keyword from the message by using the location parameter of the keyword.
  • the CPU uses the keyword to search a flow table corresponding to the identifier of the flow table to determine a flow table entry for processing the message.
  • the CPU processes the message by using the flow table entry.
  • the CPU does not need to identify the format adopted by the message. Therefore, the above technical solutions are highly flexible and versatile, which helps to quickly deploy new services.
  • FIG. 1 is a flowchart of a packet processing method according to an embodiment of the present invention.
  • FIG. 2 is a schematic structural diagram of a CPU according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present invention.
  • a packet processing method provided by an embodiment of the present invention includes:
  • the CPU acquires a location parameter of the keyword and an identifier of the flow table, where the location parameter of the keyword is used to indicate the location of the keyword in the packet.
  • the CPU may obtain the location parameter of the keyword and the identifier of the flow table from the description information of the flow table.
  • the identifier of the flow table is used to distinguish different flow tables.
  • the CPU may access the flow table according to the identifier of the flow table.
  • the identifier of the flow table may be the serial number of the flow table, or may be the storage location of the flow table, or other information used to distinguish the flow table, and will not be exemplified one by one.
  • the location parameter of the keyword includes a first parameter and a second parameter.
  • the first parameter is an offset value of a start bit of the keyword from a packet header of the packet
  • the second parameter is a packet header of the end point of the keyword from the packet. Offset value.
  • the first parameter is an offset value of a start bit of the keyword from a packet header of the packet
  • the second parameter is a length value of the keyword
  • the first parameter is an offset value of an end bit of the keyword from a packet header of the packet
  • the second parameter is a length value of the keyword
  • the start bit of the keyword may be the most significant bit of the binary sequence (English name is binary sequence) corresponding to the keyword (English name is most significant bit, English abbreviation is MSB).
  • the end bit of the keyword may be the least significant bit of the binary sequence corresponding to the keyword (English full name is least significant bit, abbreviated as LSB).
  • the keyword may include only one field in the message (the English name is field), and may include multiple fields in the message.
  • the keyword may include only the destination IP address in the IP header of the IP packet.
  • the keyword may include a source port and a destination in a TCP header of the TCP packet. port.
  • the keyword may also include a source IP address, a destination IP address, and a protocol (English name is protocol) in the IP header of the TCP packet.
  • the keyword may further include information other than the message.
  • the keyword can include information in a register.
  • the CPU may be a CPU in a server, or may be a CPU in a personal computer (English full name is personal computer, abbreviated as PC).
  • the CPU may be a CPU in a network device.
  • the network device may be a router, a network switch, a firewall, a load balancer, a wavelength division multiplexing device, a packet transport network device, a base station, a base station controller, or a data center.
  • the CPU can be a device of the control plane of the network device.
  • the CPU may be a single core CPU or a multi-core CPU.
  • the CPU acquires the keyword from the packet according to the location parameter of the keyword.
  • the keyword may be a field in a packet header (English name header) of the packet, or may be a data segment in the payload of the packet (English name is payload) (English name) For the data segment).
  • the keyword may include a field in a header of the message and a data segment in a payload of the message.
  • the CPU searches, in the flow table, a flow table entry that matches the keyword according to the keyword and the identifier of the flow table.
  • the CPU may access the flow table corresponding to the identifier stored in the memory according to the identifier of the flow table.
  • the CPU may perform an addressing operation by using the identifier of the flow table to access the flow table.
  • the identifier of the flow table is a serial number
  • the CPU may access the flow table according to the serial number.
  • the sequence number can be equal to the array pointer.
  • the array pointer points to a storage space of the flow table.
  • the CPU accesses the flow table according to a storage space pointed by the array pointer.
  • the flow table may be any one of a plurality of flow tables that the CPU can access.
  • the flow table and the description information of the flow table may be saved in the same storage space.
  • the flow table and the description information of the flow table may be saved in different storage spaces.
  • the description information of the flow table and the flow table may be stored in one table, or the description information of the flow table and the flow table may be stored in different tables, respectively.
  • the CPU may use a mask matching algorithm, a longest prefix match (English long name prefix match, LPM) algorithm, or an exact matching algorithm to search for matching with the keyword from the flow table.
  • the flow table entry For example, the CPU uses an exact matching algorithm to compare the keyword with a matching value included in each flow table entry in the flow table, and obtains a flow table entry in which the matching value is the same as the keyword. An example of searching with other matching algorithms is not described here.
  • the flow table entry may include an instruction (English name is "instruction”), and may also include multiple instructions.
  • the instruction may be defined in the OpenFlow Switch Specification 1.3.0 (English name is OpenFlow Switch Specification 1.3.0) published by the Open Network Foundation (English for Open Networking Foundation, English abbreviated as ONF). Instruction or action.
  • the instruction included in the flow table entry may be a flow table jump (English name is GOTO_TABLE) instruction, a discarded (English name is DROP) instruction, an output (English name is OUTPUT) instruction, or a send instruction.
  • the uploading instruction is to send the message to a network device capable of communicating with the device to which the CPU belongs.
  • the network device in communication with the device to which the CPU belongs may be a controller, a server, or a switch.
  • the CPU processes the packet according to the flow table entry.
  • the CPU may execute the location according to the order of the position of each instruction in the instruction sequence in the flow table entry or the priority of each instruction.
  • a plurality of instructions are described to process the message.
  • the priority of the instruction is used to indicate that the corresponding instruction is in the The sequence of times in which multiple instructions are executed. For example, an instruction with a higher priority is executed before an instruction with a lower priority.
  • the CPU includes an OUTPUT instruction in response to the obtained flow table entry.
  • the CPU outputs the message to another device.
  • the other device may be a server, a switch, a router, or a PC.
  • the method may further include: the CPU receiving an enable instruction.
  • the enable command is an instruction that instructs the CPU to process the message.
  • the enable command may be a flow table jump instruction.
  • the enable command may also be an instruction that instructs the CPU to receive the message from a port (English name is port).
  • the enable command may carry an identifier of the port.
  • the instruction indicating that the packet is processed may carry a port number of a port that receives the packet, and the CPU receives the packet from a port corresponding to the port number, and executes the foregoing S11. To S14.
  • the CPU may access the another flow table according to the identifier of another flow table carried in the GOTO_TABLE instruction to be according to the another flow.
  • the table performs message processing.
  • the message processing can be similar to S11 to S14.
  • the CPU does not need to identify the data format of the message.
  • the CPU may use the location parameter of the keyword to obtain a keyword from the packet, and process the packet according to the flow table entry in the flow table that matches the keyword. Therefore, the CPU can process the message without understanding the data format of the message.
  • the CPU may be a CPU in a server, or may be a CPU in a personal computer (English full name is personal computer, abbreviated as PC). Additionally, the CPU may be a CPU in a network device.
  • the network device may be a router, a network switch, a firewall, a load balancer, a wavelength division multiplexing device, a packet transport network device, a base station, a base station controller, or a data center.
  • the CPU can be a device of the control plane of the network device.
  • the CPU may be a single core CPU or a multi-core CPU. Referring to FIG. 2, the CPU includes a first obtaining unit 20, a second obtaining unit 21, a searching unit 22, and a processing unit 23.
  • the first obtaining unit 20 is configured to obtain a location parameter of the keyword and an identifier of the flow table, where the location parameter of the keyword is used to indicate the location of the keyword in the message.
  • the first obtaining unit 20 may obtain the location parameter of the keyword and the identifier of the flow table from the description information of the flow table.
  • the identifier of the flow table is used to distinguish different flow tables.
  • the first obtaining unit 20 accesses the flow table according to the identifier of the flow table.
  • the identifier of the flow table may be the sequence number of the flow table, or may be the storage location of the flow table, or other information that can be used to distinguish the flow table, and details are not described herein again.
  • the location parameter of the keyword includes a first parameter and a second parameter.
  • the first parameter is an offset value of a start bit of the keyword from a packet header of the packet
  • the second parameter is a packet header of the end point of the keyword from the packet. Offset value.
  • the first parameter is an offset value of a start bit of the first key word from a message header of the message
  • the second parameter is a length value of the keyword
  • the first parameter is an offset value of an end bit of the keyword from a packet header of the packet
  • the second parameter is a length value of the keyword
  • the start bit of the keyword may be the MSB of the binary sequence corresponding to the keyword.
  • the end bit of the keyword may be the LSB of the binary sequence corresponding to the keyword.
  • the second obtaining unit 21 is configured to obtain the keyword from the packet according to the location parameter of the keyword acquired by the first acquiring unit 20.
  • the keyword may be a field in a header of the packet, or may be a data segment in a payload of the packet.
  • the keyword may include a field in a header of the message and a data segment in a payload of the message.
  • the searching unit 22 is configured to search, according to the keyword acquired by the second acquiring unit 21 and the identifier of the flow table acquired by the first acquiring unit 20, in the flow table, to match the keyword Flow table entry.
  • the searching unit 22 can access the flow table corresponding to the identifier saved in the memory according to the identifier of the flow table.
  • the flow table may be any one of a plurality of flow tables that the lookup unit 22 can access.
  • the searching unit 22 may use a mask matching algorithm, an LPM algorithm, or an exact matching algorithm to search for a flow table entry matching the keyword from the flow table. For example, the search unit 22 compares the keyword with the matching value included in each flow table entry in the flow table, and obtains the flow table entry in which the matching value is the same as the keyword. An example of finding using other matching methods will not be described here.
  • the processing unit 23 is configured to process the message according to the flow table entry searched by the searching unit 22. For example, when the flow table entry includes multiple instructions, the processing unit 23 may be in accordance with the order of the positions in the instruction sequence in the flow table entry or the priority of each instruction according to each instruction. Executing the plurality of instructions to process the message. The priority of the instruction is used to indicate the order of the time at which the corresponding instruction was executed in the plurality of instructions. For example, an instruction with a higher priority is executed before an instruction with a lower priority.
  • the CPU further includes a storage unit, where the storage unit is configured to save a flow table resource, where the flow table resource includes a location parameter of the keyword, an identifier of the flow table, and the flow table.
  • the CPU provided by the embodiment corresponding to FIG. 2 can be used to execute the method provided by the embodiment corresponding to FIG. 1.
  • the CPU shown in FIG. 2 may be a CPU of a server or a PC.
  • the CPU does not need to identify the data format of the message.
  • the CPU may use the location parameter of the keyword to obtain a keyword from the packet, and process the packet according to the flow table entry in the flow table that matches the keyword. Therefore, the CPU can process the message without understanding the data format of the message.
  • the above technical solutions are highly flexible and versatile, helping to quickly deploy new services.
  • FIG. 3 is a schematic structural diagram of a message processing apparatus according to an embodiment of the present invention.
  • the message processing device may be a server or a personal computer.
  • the message processing device can It is a network device.
  • the network device may be a router, a network switch, a firewall, a load balancer, a wavelength division multiplexing device, a packet transport network device, a base station, a base station controller, or a data center.
  • the message processing apparatus includes: a first virtual machine 30 and a second virtual machine 31.
  • the first virtual machine 30 of this embodiment can be used to perform the method provided by the embodiment corresponding to FIG.
  • the first virtual machine 30 includes a first obtaining unit 301, a second obtaining unit 302, a first searching unit 303, and a first processing unit 304.
  • the first obtaining unit 301 is configured to obtain a location parameter of the first keyword and an identifier of the first flow table, where the location parameter of the first keyword is used to indicate a location of the first keyword in the packet.
  • the second obtaining unit 302 is configured to obtain the first keyword from the packet according to the location parameter of the first keyword acquired by the first acquiring unit 301.
  • the first keyword may be a field in a header of the packet, or may be a data segment in a payload of the packet.
  • the first keyword may include a field in a header of the message and a data segment in a payload of the message.
  • the first searching unit 303 is configured to search and search the first flow table according to the first keyword acquired by the second acquiring unit 302 and the identifier of the first flow table acquired by the first acquiring unit 301. The flow table entry matched by the first keyword.
  • the first searching unit 303 can access the first flow table corresponding to the identifier of the first flow table stored in a memory included in the message processing apparatus according to the identifier of the first flow table.
  • the first flow table may be any one of a plurality of flow tables that the first search unit 303 can access.
  • the first searching unit 303 may use a mask matching algorithm, an LPM algorithm, or an exact matching algorithm to search for a flow table entry that matches the first keyword from the first flow table.
  • the first processing unit 304 is configured to process the packet according to the flow table entry in the first flow table that is searched by the first searching unit 303 to obtain a first packet.
  • the first processing unit 304 may be in accordance with the order of the positions in the instruction sequence in the flow table entry or the priority of each instruction according to each instruction. Level, executing the plurality of instructions to process the message.
  • the priority of the instruction is used to indicate the order of the time at which the corresponding instruction was executed in the plurality of instructions. For example, an instruction with a higher priority is executed before an instruction with a lower priority.
  • the first A message can be the same as the message.
  • the processing by the first processing unit 304 for the message is to count the operation of the message.
  • the first packet may be different from the packet.
  • the processing by the first processing unit 304 for the message is an operation of adding a field (English name is ADD_FIELD) to the message.
  • the first processing unit 304 is configured to perform outputting the first packet to the second virtual machine 31 according to the flow table entry in the first flow table that is searched by the first searching unit 303.
  • the operation of the GOTO_TABLE command to the second virtual machine 31 is operated and output.
  • the flow table jump instruction includes an identifier of the second flow table.
  • the second virtual machine 31 includes a receiving unit 311.
  • the receiving unit 311 is configured to receive the first packet and the flow table jump instruction output by the first virtual machine 30.
  • the receiving unit 311 is configured to receive the first packet and the flow table jump instruction output by the first processing unit 304.
  • the second virtual machine 31 can be used to implement similar functions of the CPU provided by the embodiment corresponding to FIG.
  • the second virtual machine 31 further includes: a third obtaining unit 312, a fourth obtaining unit 313, a second searching unit 314, and a second processing unit 315.
  • the third obtaining unit 312 is configured to acquire a location parameter of the second keyword, and obtain an identifier of the second flow table from the flow table jump instruction, where the location parameter of the second keyword is used to indicate the second The location of the keyword in the message.
  • the location parameter of the second keyword includes a third parameter and a fourth parameter.
  • the third parameter is an offset value of a start bit of the second keyword from a packet header of the packet
  • the fourth parameter is an end bit distance of the second keyword from the packet The offset value of the message header.
  • the third parameter is an offset value of a start bit of the second keyword from a packet header of the packet
  • the fourth parameter is a length value of the second keyword
  • the third parameter is an offset value of an end bit of the second keyword from a packet header of the packet
  • the fourth parameter is a length value of the second keyword
  • the start bit of the second keyword may be the MSB of the binary sequence corresponding to the second keyword.
  • the end bit of the second keyword may be an LSB of a binary sequence corresponding to the second keyword.
  • the fourth obtaining unit 313 is configured to acquire the second keyword from the first packet received by the receiving unit 311 according to the location parameter of the second keyword that is acquired by the third acquiring unit 312.
  • the second keyword may be a field in a header of the first packet, or may be a data segment in a payload of the first packet.
  • the second keyword may include a field in a header of the first packet and a data segment in a payload of the first packet.
  • the second searching unit 314 is configured to use, according to the second keyword acquired by the fourth acquiring unit 313 and the identifier of the second flow table acquired by the third acquiring unit 312, in the second flow table. Find a flow table entry that matches the second keyword. For example, the second searching unit 314 can access the second flow table corresponding to the identifier of the second flow table stored in the memory included in the message processing device according to the identifier of the second flow table.
  • the second processing unit 315 is configured to process the first packet according to the flow table entry in the second flow table that is searched by the second searching unit 314. For example, when the flow table entry includes multiple instructions, the second processing unit 315 may be in accordance with the order of the positions in the instruction sequence in the flow table entry or the priority of each instruction according to each instruction. Level, executing the plurality of instructions to process the first message. The priority of the instruction is used to indicate the order of the time at which the corresponding instruction was executed in the plurality of instructions. For example, an instruction with a higher priority is executed before an instruction with a lower priority.
  • the second virtual machine 31 can perform the second flow table carried according to the flow table jump instruction from the first virtual machine 30. And identifying, according to the flow table entry matching the keyword searched from the second flow table, the first packet.
  • the same flow table resource includes a location parameter of the first keyword, an identifier of the first flow table, a first flow table, a location parameter of the second keyword, an identifier of the second flow table, and a second flow table.
  • the second virtual machine 31 and the first virtual machine 30 can access different flow table resources.
  • the flow table resource accessible by the first virtual machine 30 includes a location parameter of the first keyword, an identifier of the first flow table, and a first flow table.
  • the flow table resource accessible by the second virtual machine 31 includes a location parameter of the second keyword, an identifier of the second flow table, and a second flow table.
  • the first virtual machine 30 executes an OUTPUT command to output a first message to the second virtual machine 31.
  • the second virtual machine 31 After receiving the first packet sent by the first virtual machine 30, the second virtual machine 31 obtains a second keyword according to the location parameter of the second keyword, and uses the second The flow table entry matching the second keyword obtained in the flow table corresponding to the identifier of the flow table is processed, and the first packet sent by the first virtual machine 30 is processed.
  • first virtual machine 30 and the second virtual machine 31 may run in the same server or PC.
  • the packet processing apparatus helps to implement different services on different virtual machines.
  • Each virtual machine processes packets separately to facilitate management of different services.
  • the first virtual machine 30 can process the second packet while the first virtual machine 30 processes the first packet.
  • the first virtual machine and the second virtual machine do not need to identify the data format of the message, and each virtual machine can obtain the keyword from the message by using the location parameter of the keyword, and according to the flow table.
  • the flow table entry matching the keyword processes the message. Therefore, each virtual machine does not need to understand the data format of the packet to process the packet.
  • Fig. 4 shows a message processing apparatus.
  • the message processing device may be a server or a personal computer. Additionally, the message processing device can be a network device.
  • the network device may be a router, a network switch, a firewall, a load balancer, a wavelength division multiplexing device, a packet transport network device, a base station, a base station controller, or a data center.
  • the message processing apparatus includes an interface circuit 401, an interface circuit 402, a memory 403, and a processor 404.
  • the processor 404 includes an instruction execution circuit 405, an instruction memory 406, and a lookup engine 407.
  • the message processing apparatus of this embodiment can be used for a server or a computer.
  • the message processing apparatus of this embodiment can be used to implement the message processing apparatus in the embodiment corresponding to FIG. 2 or FIG. 3.
  • the message processing apparatus of this embodiment is capable of executing the method provided by the embodiment corresponding to FIG.
  • the processor 404 is coupled to the interface circuit 401, the interface circuit 402, and the memory 403, respectively, and the instruction execution circuit 405 is coupled to the instruction memory 406 and the lookup engine 407, respectively.
  • the instruction memory 406 is for storing computer instructions, and the instruction execution circuit 405 performs the following operations by reading the computer instructions:
  • the search engine 407 is triggered to cause the search engine 407 to search for the flow table entry matching the keyword in the flow table of the memory 403 according to the keyword and the identifier of the flow table. .
  • the message is received by the message processing device via the interface circuit 401.
  • the processor 404 can perform an operation of outputting the message and outputting a flow table jump instruction through the interface circuit 402.
  • the above general purpose processor may be a microprocessor or the processor or any conventional processor.
  • the steps of the method disclosed in the embodiment of the present invention may be directly implemented as a hardware processor, or may be performed by a combination of hardware and software modules in the processor.
  • the code implementing the above functions may be stored in a computer readable medium.
  • Computer readable media includes computer storage media.
  • a storage medium may be any available media that can be accessed by a computer.
  • the computer readable medium may be a random access memory (English full name is random access memory, abbreviated as RAM), read-only memory (English full name is read only memory, abbreviated as ROM), electricity Erasable programmable read-only memory (English full name electrically programmable programmable read-only memory, English abbreviation for EEPROM), read-only optical disc (English full name compact disc-read only memory, English abbreviation for CD-ROM) or other optical disc storage
  • RAM random access memory
  • read-only memory English full name is read only memory, abbreviated as ROM
  • electricity Erasable programmable read-only memory English full name electrically programmable programmable read-only memory, English abbreviation for EEPROM
  • read-only optical disc English full name compact disc-read only memory, English abbreviation for CD-ROM
  • CD-ROM compact disc-read only memory
  • CD-ROM compact disc-read only memory
  • the computer readable medium may be a compact disc (English full name compact disk, abbreviated as CD), a laser disc, a disc, a digital video disc (English full name digital video disc, abbreviated as DVD), a floppy disk or a Blu-ray disc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明实施例公开了一种报文处理方法和装置,在对报文进行处理前,不需要理解所述报文的数据格式,灵活性和通用性较高,有助于快速部署新业务。所述方法包括:中央处理器CPU获取关键字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置。所述CPU根据所述关键字的位置参数,从所述报文中获取所述关键字。所述CPU根据所述关键字和所述流表的标识,在所述流表中查找与所述关键字匹配的流表表项。所述CPU根据所述流表表项处理所述报文。

Description

报文处理方法及装置
本申请要求于2014年3月4日提交中国专利局、申请号为CN201410076738.6、发明名称为“一种报文处理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及一种通信技术,尤其涉及一种报文处理方法及装置。
背景技术
现有技术中,转发设备接收到报文后,需要确定报文数据格式,例如确定报文是网际协议(英文全称为Internet Protocol,英文缩写为IP)数据包或者多协议标签交换(英文全称为Multiple protocol Label Switching,英文缩写为MPLS)报文,从而根据所述协议对所述报文进行处理。例如,交换机收到以太网帧后,需要根据端口表确定所述以太网帧的协议为媒体访问控制(英文全称为Media Access Control,英文缩写为MAC)协议。然后,所述交换机根据MAC协议,对所述以太网帧的MAC协议头进行解析,从而获取所述以太网帧的目的MAC协议地址。
发明内容
有鉴于此,本发明实施例提供了一种报文处理方法及装置。对报文进行处理前,不需要理解所述报文的数据格式。上述技术方案的灵活性和通用性较高,有助于快速部署新业务。
本发明实施例提供的技术方案如下。
第一方面,提供了一种报文处理方法,包括:
中央处理器(英文全称为central processing unit,英文缩写为CPU)获取关键字(英文名称为key)的位置参数和流表(英文名称为flow table)的标识,所述key的位置参数用以指示所述key在报文中的位置;
所述CPU根据所述关键字的位置参数,从所述报文中获取所述关键字;
所述CPU根据所述关键字和所述流表的标识,在所述流表中查找与所述 关键字匹配的流表表项;以及
所述CPU根据所述流表表项处理所述报文。
在上述第一方面的第一种可能的实现方式中,所述关键字的位置参数包含第一参数和第二参数;
所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值(英文名称为offset),所述第二参数为所述关键字的结束位距所述报文的报文头的偏移值;或者
所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值(英文名称为length);或者
所述第一参数为所述关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
第二方面,提供了一种报文处理装置,包括:第一虚拟机;
所述第一虚拟机包括:
第一获取单元,用于获取第一关键字的位置参数和第一流表的标识,所述第一关键字的位置参数用以指示所述第一关键字在报文中的位置;
第二获取单元,用于根据所述第一获取单元获取的所述第一关键字的位置参数,从所述报文中获取所述第一关键字;
第一查找单元,用于根据所述第二获取单元获取的所述第一关键字和所述第一获取单元获取的所述第一流表的标识,在所述第一流表中查找与所述第一关键字匹配的流表表项;以及
第一处理单元,用于根据所述第一查找单元查找的所述第一流表中的所述流表表项处理所述报文以获得第一报文。
在上述第二方面的第一种可能的实现方式中,所述第一关键字的位置参数包含第一参数和第二参数;
所述第一参数为所述第一关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述第一关键字的结束位距所述报文的报文头的偏移值;或者
所述第一参数为所述第一关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述第一关键字的长度值;或者
所述第一参数为所述第一关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述第一关键字的长度值。
结合上述第二方面或第二方面的第一种可能的实现方式,还提供了第二方面的第二种可能的实现方式,包括:第二虚拟机;
所述第一处理单元具体用于执行输出所述第一报文至所述第二虚拟机的操作和输出流表跳转GOTO_TABLE指令至所述第二虚拟机的操作,所述流表跳转指令中包含第二流表的标识;
所述第二虚拟机包括接收单元,用于接收所述第一虚拟机输出的所述第一报文和所述流表跳转指令。
结合上述第二方面的第二种可能的实现方式,还提供了第二方面的第三种可能的实现方式,包括:
第三获取单元,用于获取第二关键字的位置参数和从所述流表跳转指令中获取所述第二流表的标识,所述第二关键字的位置参数用以指示所述第二关键字在所述报文中的位置;
第四获取单元,用于根据所述第三获取单元获取的所述第二关键字的位置参数,从所述接收单元接收的所述第一报文中获取所述第二关键字;
第二查找单元,用于根据所述第四获取单元获取的所述第二关键字和所述第三获取单元获取的所述第二流表的标识,在所述第二流表中查找与所述第二关键字匹配的流表表项;以及
第二处理单元,用于根据所述第二查找单元查找的所述第二流表中的所述流表表项处理所述第一报文。
结合上述第二方面的第三种可能的实现方式,还提供了第二方面的第四种可能的实现方式,所述第二关键字的位置参数包含第三参数和第四参数;
所述第三参数为所述第二关键字的起始位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的结束位距所述报文的报文头的偏移值;或者
所述第三参数为所述第二关键字的起始位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的长度值;或者
所述第三参数为所述第二关键字的结束位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的长度值。
第三方面,提供了一种CPU,包括:
第一获取单元,用于获取关键字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置;
第二获取单元,用于根据所述第一获取单元获取的所述关键字的位置参数,从所述报文中获取所述关键字;
查找单元,用于根据所述第二获取单元获取的所述关键字和所述第一获取单元获取的所述流表的标识,在所述流表中查找与所述关键字匹配的流表表项;以及
处理单元,用于根据所述查找单元查找的所述流表表项处理所述报文。
在上述第三方面的第一种可能的实现方式中,所述关键字的位置参数包含第一参数和第二参数;
所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的结束位距所述报文的报文头的偏移值;或者
所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值;或者
所述第一参数为所述关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
通过上述方案,CPU可利用关键字的位置参数,从报文获取所述关键字。CPU利用所述关键字查找与流表的标识对应的流表,以确定用以处理所述报文的流表表项。CPU利用所述流表表项处理所述报文。上述技术方案中,CPU无需对报文所采用的格式进行识别。因此,上述技术方案的灵活性和通用性较高,有助于快速部署新业务。
附图说明
为了更清楚地说明本发明的技术方案,下面将对实施方式中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施方式,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以如这些附图获得其他的附图。
图1为本发明实施例提供的一种报文处理方法的流程图。
图2为本发明实施例提供的一种CPU的结构示意图。
图3为本发明实施例提供的一种报文处理装置的结构示意图。
图4为本发明实施例提供的一种报文处理装置的结构示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
如图1所示,本发明实施例提供的一种报文处理方法,包括:
S11,CPU获取关键字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置。
举例来说,所述CPU可从流表的描述信息中获取所述关键字的位置参数和所述流表的标识。
举例来说,所述流表的标识用以区分不同的流表。所述CPU根据所述流表的标识可访问所述流表。所述流表的标识可以为所述流表的序号,还可以为所述流表的存储位置,或者为其它用以区分流表的信息,在此不再逐一举例说明。
举例来说,所述关键字的位置参数包含第一参数和第二参数。所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的结束位距所述报文的报文头的偏移值。
可替换的,所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
可替换的,所述第一参数为所述关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
上述技术方案中,所述关键字的起始位可以是所述关键字对应的二进制序列(英文名称为binary sequence)的最高有效位(英文全称为most significant bit,英文缩写为MSB)。所述关键字的结束位可以是所述关键字对应的二进制序列的最低有效位(英文全称为least significant bit,英文缩写为LSB)。
举例来说,所述关键字可以只包括所述报文中的一个字段(英文名称为field),可以包括所述报文中的多个字段。例如,在所述报文是IP报文的场景中,所述关键字可以只包括所述IP报文的IP头中的目的IP地址。例如,在所述报文是传输控制协议(英文全称为Transmission Control Protocol,英文缩写为TCP)报文的场景中,所述关键字可以包括所述TCP报文的TCP头中的源端口和目的端口。所述关键字还可以包括所述TCP报文的IP头中的源IP地址、目的IP地址以及协议(英文名称为protocol)。
可选地,所述关键字还可以包括所述报文之外的信息。例如,所述关键字可以包括寄存器中的信息。
举例来说,所述CPU可以为服务器中的CPU,也可以是个人计算机(英文全称为personal computer,英文缩写为PC)中的CPU。另外,所述CPU可以是网络设备中的CPU。所述网络设备可以是路由器、网络交换机、防火墙、负载均衡器、波分复用设备、分组传送网设备、基站、基站控制器或者数据中心。具体来说,所述CPU可以所述网络设备的控制平面的器件。举例来说,所述CPU可以是单核CPU,也可以是多核CPU。
S12,所述CPU根据所述关键字的位置参数,从所述报文中获取所述关键字。
举例来说,所述关键字可以是所述报文的报文头(英文名称header)中的字段,也可以是所述报文的净荷(英文名称为payload)中的数据段(英文名称为data segment)。所述关键字可以包括所述报文的header中的字段以及所述报文的payload中的数据段。
S13,所述CPU根据所述关键字和所述流表的标识,在所述流表中查找与所述关键字匹配的流表表项。
举例来说,所述CPU可根据所述流表的标识,访问存储器中存储的与所述标识对应的所述流表。例如:在所述流表的标识为所述流表的存储地址时,所述CPU可利用所述流表的标识进行寻址操作,以访问所述流表。在所述流表的标识为序号时,所述CPU可以根据所述序号访问所述流表。具体来说, 所述序号可以等于数组指针。所述数组指针指向所述流表的存储空间。所述CPU根据所述数组指针指向的存储空间访问所述流表。
举例来说,所述流表可以是所述CPU能够访问的多个流表中的任意一个流表。
举例来说,所述流表和所述流表的描述信息可以保存于同一存储空间中。可替换地,所述流表和所述流表的描述信息可以保存于不同存储空间中。例如:所述流表和所述流表的描述信息可以存储在一个表中,或者所述流表和所述流表的描述信息可以分别存储在不同的表中。
举例来说,所述CPU可采用掩码匹配算法、最长前缀匹配(英文全称为longest prefix match,英文缩写为LPM)算法或者精确匹配算法,从所述流表中查找与所述关键字匹配的所述流表表项。例如:所述CPU采用精确匹配算法,将所述关键字与所述流表中每一流表表项包含的匹配值进行比较,获取与所述关键字相同的匹配值所在的流表表项。在此不再对采用其它匹配算法进行查找的实例进行说明。
举例来说,所述流表表项可以包含一条指令(英文名称为instruction),也可包含多条指令。举例来说,所述指令可以是开放网络基础(英文全称为Open Networking Foundation,英文缩写为ONF)发布的《开放流交换机规范1.3.0》(英文名称为OpenFlow Switch Specification 1.3.0)中定义的指令或者动作。比如:所述流表表项包含的指令可以是流表跳转(英文名称为GOTO_TABLE)指令、丢弃(英文名称为DROP)指令、输出(英文名称为OUTPUT)指令或者上送指令。所述上送指令为将报文发送至能够与所述CPU所属设备通信的网络设备。与所述CPU所属设备通信的网络设备可以是控制器、服务器或者交换机。
S14,所述CPU根据所述流表表项处理所述报文。
举例来说,所述流表表项包含多条指令时,所述CPU可根据每条指令在所述流表表项中的指令序列中的位置的顺序或每条指令的优先级,执行所述多条指令,以对所述报文进行处理。指令的优先级用以指示对应的指令在所 述多条指令中被执行的时间的顺序。例如,优先级高的指令先于优先级低的指令被执行。
举例来说,所述CPU响应于获取的所述流表表项包含OUTPUT指令。所述CPU输出所述报文至另一设备。所述另一设备可以是服务器、交换机、路由器或者PC。
可选地,S11之前,所述方法还可包含:所述CPU接收使能指令。所述使能指令是指示所述CPU处理所述报文的指令。例如:所述使能指令可以是流表跳转指令。所述使能指令也可以是指示所述CPU从一个端口(英文名称为port)接收所述报文的指令。所述使能指令可携带所述端口的标识。
举例来说,所述指示处理所述报文的指令中可携带接收所述报文的端口的端口号,所述CPU从与所述端口号对应的端口接收所述报文,并执行上述S11至S14。
举例来说,所述CPU获取的所述流表表项包含GOTO_TABLE指令时,所述CPU可根据所述GOTO_TABLE指令中携带的另一流表的标识,访问所述另一流表以根据所述另一流表执行报文处理。所述报文处理可以与S11至S14类似。
该实施例的方法中,CPU无需对报文的数据格式进行识别。CPU可以利用关键字的位置参数从报文中获取关键字,并根据流表中与关键字匹配的流表表项处理所述报文。因此,所述CPU不需要理解所述报文的数据格式即可对所述报文进行处理。上述技术方案的灵活性和通用性较高,有助于快速部署新业务。
如图2所示,本发明实施例提供的一种CPU。所述CPU可以为服务器中的CPU,也可以是个人计算机(英文全称为personal computer,英文缩写为PC)中的CPU。另外,所述CPU可以是网络设备中的CPU。所述网络设备可以是路由器、网络交换机、防火墙、负载均衡器、波分复用设备、分组传送网设备、基站、基站控制器或者数据中心。具体来说,所述CPU可以所述网络设备的控制平面的器件。举例来说,所述CPU可以是单核CPU,也可以是多核CPU。 参见图2,所述CPU包括:第一获取单元20、第二获取单元21、查找单元22和处理单元23。
第一获取单元20用于获取关键字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置。
举例来说,第一获取单元20可从所述流表的描述信息中获取所述关键字的位置参数和所述流表的标识。
举例来说,所述流表的标识用以区分不同的流表。所述第一获取单元20根据所述流表的标识访问所述流表。所述流表的标识可以为所述流表的序号,还可以为所述流表的存储位置,或者为其它的可用以区分流表的信息,在此不再赘述。
举例来说,所述关键字的位置参数包含第一参数和第二参数。所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的结束位距所述报文的报文头的偏移值。
可替换的,所述第一参数为所述第键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
可替换的,所述第一参数为所述关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
上述技术方案中,所述关键字的起始位可以是所述关键字对应的binary sequence的MSB。所述关键字的结束位可以是所述关键字对应的binary sequence的LSB。
第二获取单元21用于根据所述第一获取单元20获取的所述关键字的位置参数,从所述报文中获取所述关键字。举例来说,所述关键字可以是所述报文的header中的field,也可以是所述报文的payload中的data segment。所述关键字可以包括所述报文的header中的field以及所述报文的payload中的data segment。
查找单元22用于根据所述第二获取单元21获取的所述关键字和所述第一获取单元20获取的所述流表的标识,在所述流表中查找与所述关键字匹配的 流表表项。
举例来说,查找单元22可根据所述流表的标识,访问存储器中保存的与所述标识对应的所述流表。所述流表可以是查找单元22能够访问的多个流表中的任意一个流表。
举例来说,查找单元22可采用掩码匹配算法、LPM算法或者精确匹配算法,从所述流表中查找与所述关键字匹配的流表表项。例如:查找单元22采用精确匹配,将所述关键字与所述流表中每一流表表项包含的匹配值进行比较,获取与所述关键字相同的匹配值所在的流表表项。在此不再对采用其它匹配方法进行查找的实例进行说明。
处理单元23用于根据所述查找单元22查找的所述流表表项处理所述报文。举例来说,所述流表表项包含多条指令时,所述处理单元23可根据每条指令在所述流表表项中的指令序列中的位置的顺序或每条指令的优先级,执行所述多条指令,对所述报文进行处理。指令的优先级用以指示对应的指令在所述多条指令中被执行的时间的顺序。例如,优先级高的指令先于优先级低的指令被执行。
可选地,CPU还包含存储单元,所述存储单元用以保存流表资源,所述流表资源包含所述关键字的位置参数、所述流表的标识和所述流表。
与图2对应的实施例提供的CPU能够用于执行与图1对应的实施例提供的方法。
图2所示的CPU可以是服务器或PC的CPU。
上述技术方案中,CPU无需对报文的数据格式进行识别。CPU可以利用关键字的位置参数从报文中获取关键字,并根据流表中与关键字匹配的流表表项处理所述报文。因此,所述CPU不需要理解所述报文的数据格式即可对所述报文进行处理。上述技术方案的灵活性和通用性较高,有助于快速部署新业务。
图3为本发明实施例提供的一种报文处理装置的结构示意图。所述报文处理装置可以是服务器,也可以是个人计算机。另外,所述报文处理装置可以 是网络设备。所述网络设备可以是路由器、网络交换机、防火墙、负载均衡器、波分复用设备、分组传送网设备、基站、基站控制器或者数据中心。参见图3,所述报文处理装置包括:第一虚拟机30和第二虚拟机31。该实施例的第一虚拟机30可用于执行与图1对应的实施例提供的方法。
所述第一虚拟机30包括:第一获取单元301、第二获取单元302、第一查找单元303和第一处理单元304。
第一获取单元301用于获取第一关键字的位置参数和第一流表的标识,所述第一关键字的位置参数用以指示所述第一关键字在报文中的位置。
第二获取单元302用于根据所述第一获取单元301获取的所述第一关键字的位置参数,从所述报文中获取所述第一关键字。
举例来说,所述第一关键字可以是所述报文的header中的field,也可以是所述报文的payload中的data segment。所述第一关键字可以包括所述报文的header中的字段以及所述报文的payload中的数据段。
第一查找单元303用于根据所述第二获取单元302获取的所述第一关键字和所述第一获取单元301获取的所述第一流表的标识,在所述第一流表中查找与所述第一关键字匹配的流表表项。
举例来说,第一查找单元303可根据所述第一流表的标识,访问报文处理装置包含的存储器中存储的与所述第一流表的标识对应的所述第一流表。所述第一流表可以是第一查找单元303能够访问的多个流表中的任意一个流表。
可选地,第一查找单元303可采用掩码匹配算法、LPM算法或精确匹配算法,从第一流表中查找与第一关键字匹配的流表表项。
第一处理单元304用于根据所述第一查找单元303查找的所述第一流表中的所述流表表项处理所述报文,以获得第一报文。举例来说,所述流表表项包含多条指令时,所述第一处理单元304可根据每条指令在所述流表表项中的指令序列中的位置的顺序或每条指令的优先级,执行所述多条指令,对所述报文进行处理。指令的优先级用以指示对应的指令在所述多条指令中被执行的时间的顺序。例如,优先级高的指令先于优先级低的指令被执行。所述第 一报文可以与所述报文相同。例如,第一处理单元304对所述报文的处理为对所述报文进行计数操作。所述第一报文可以与所述报文不同。例如,第一处理单元304对所述报文的处理为对所述报文进行添加字段(英文名称为ADD_FIELD)的操作。
可选地,第一处理单元304用于根据所述第一查找单元303查找的所述第一流表中的所述流表表项,执行输出所述第一报文至第二虚拟机31的操作和输出所述GOTO_TABLE指令至第二虚拟机31的操作。所述流表跳转指令中包含第二流表的标识。
所述第二虚拟机31包括接收单元311。所述接收单元311用于接收第一虚拟机30输出的所述第一报文和所述流表跳转指令。举例来说,所述接收单元311用于接收第一处理单元304输出的所述第一报文和所述流表跳转指令。
可选地,第二虚拟机31能够用于实现与图1对应的实施例提供的CPU的类似的功能。所述第二虚拟机31还包括:第三获取单元312、第四获取单元313、第二查找单元314和第二处理单元315。
第三获取单元312用于获取第二关键字的位置参数和从所述流表跳转指令获取所述第二流表的标识,所述第二关键字的位置参数用以指示所述第二关键字在所述报文中的位置。
举例来说,所述第二关键字的位置参数包含第三参数和第四参数。所述第三参数为所述第二关键字的起始位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的结束位距所述报文的报文头的偏移值。
可替换的,所述第三参数为所述第二关键字的起始位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的长度值。
可替换的,所述第三参数为所述第二关键字的结束位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的长度值。
上述技术方案中,所述第二关键字的起始位可以是所述第二关键字对应的binary sequence的MSB。所述第二关键字的结束位可以是所述第二关键字对应的binary sequence的LSB。
第四获取单元313用于根据所述第三获取单元312获取的所述第二关键字的位置参数,从所述接收单元311接收的所述第一报文中获取所述第二关键字。举例来说,所述第二关键字可以是所述第一报文的header中的field,也可以是所述第一报文的payload中的data segment。所述第二关键字可包括所述第一报文的header中的field和所述第一报文的payload中的data segment。
第二查找单元314用于根据所述第四获取单元313获取的所述第二关键字和所述第三获取单元312获取的所述第二流表的标识,在所述第二流表中查找与所述第二关键字匹配的流表表项。举例来说,第二查找单元314可根据所述第二流表的标识,访问报文处理装置包含的存储器中存储的所述第二流表的标识对应的所述第二流表。
第二处理单元315用于根据所述第二查找单元314查找的所述第二流表中的所述流表表项处理所述第一报文。举例来说,所述流表表项包含多条指令时,所述第二处理单元315可根据每条指令在所述流表表项中的指令序列中的位置的顺序或每条指令的优先级,执行所述多条指令,以对所述第一报文进行处理。指令的优先级用以指示对应的指令在所述多条指令中被执行的时间的顺序。例如,优先级高的指令先于优先级低的指令被执行。
举例来说,第二虚拟机31和第一虚拟机30可以访问相同的流表资源时,第二虚拟机31可根据来自第一虚拟机30的流表跳转指令携带的第二流表的标识,根据从第二流表中查找的与关键字匹配的流表表项处理所述第一报文。所述相同的流表资源包含第一关键字的位置参数、第一流表的标识、第一流表、第二关键字的位置参数、第二流表的标识和第二流表。
可替换的,第二虚拟机31和第一虚拟机30可以访问不同的流表资源。具体来说,第一虚拟机30可访问的流表资源包含第一关键字的位置参数、第一流表的标识和第一流表。第二虚拟机31可访问的流表资源包含第二关键字的位置参数、第二流表的标识和第二流表。第一虚拟机30执行OUTPUT指令以向第二虚拟机31输出第一报文。第二虚拟机31接收第一虚拟机30发送的所述第一报文后,根据第二关键字的位置参数获取第二关键字,利用从所述第二 流表的标识对应的流表中获取的与第二关键字匹配的流表表项,处理所述第一虚拟机30发送的所述第一报文。
可选地,第一虚拟机30和第二虚拟机31可以运行在同一台服务器或PC中。
上述技术方案提供的报文处理装置有助于实现在不同的虚拟机上部署不同的业务。每台虚拟机对报文分别进行处理,方便对不同业务进行管理。例如:第一虚拟机30在对第一报文进行处理的同时,第二虚拟机31可对第二报文进行处理。
该实施例的装置中,第一虚拟机和第二虚拟机无需对报文的数据格式进行识别,每台虚拟机均可利用关键字的位置参数从报文中获取关键字,并根据流表中与关键字匹配的流表表项处理所述报文。因此,每台虚拟机不需要理解报文的数据格式即可对报文进行处理。上述技术方案的灵活性和通用性较高,有助于快速部署新业务。
图4示出了一种报文处理装置。所述报文处理装置可以是服务器,也可以是个人计算机。另外,所述报文处理装置可以是网络设备。所述网络设备可以是路由器、网络交换机、防火墙、负载均衡器、波分复用设备、分组传送网设备、基站、基站控制器或者数据中心。参见图4,报文处理装置包含接口电路401、接口电路402、存储器403和处理器404。所述处理器404包括指令执行电路405、指令存储器406和查找引擎407。该实施例的报文处理装置可以用于服务器或计算机。该实施例的报文处理装置可以用于实现与图2或图3对应的实施例中的报文处理装置。该实施例的报文处理装置能够执行与图1对应的实施例提供的方法。
所述处理器404分别与所述接口电路401、所述接口电路402和所述存储器403耦合,所述指令执行电路405分别与所述指令存储器406和查找引擎407耦合。
所述指令存储器406用于存储计算机指令,所述指令执行电路405通过读取所述计算机指令执行如下操作:
触发所述查找引擎407,以使所述查找引擎407从所述存储器403获取关键 字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置;
根据所述关键字的位置参数,从所述接口电路401接收的所述报文中获取所述关键字;
触发所述查找引擎407,以使所述查找引擎407根据所述关键字和所述流表的标识,在所述存储器403的所述流表中查找与所述关键字匹配的流表表项。
根据所述流表表项处理所述报文。
举例来说,所述报文是所述报文处理装置通过接口电路401接收到的。
可选地,处理器404可通过接口电路402执行输出所述报文的操作和输出流表跳转指令的操作。
上述通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器。结合本发明实施例所公开的方法的步骤,可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。当使用软件实现时,可以将实现上述功能的代码存储在计算机可读介质中。计算机可读介质包括计算机存储介质。存储介质可以是计算机能够存取的任何可用介质。以此为例但不限于:计算机可读介质可以是随机存取存储器(英文全称为random access memory,英文缩写为RAM)、只读存储器(英文全称为read only memory,英文缩写为ROM)、电可擦可编程只读存储器(英文全称为electrically erasable programmable read-only memory,英文缩写为EEPROM)、只读光盘(英文全称为compact disc-read only memory,英文缩写为CD-ROM)或其他光盘存储、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质。计算机可读介质可以是压缩光碟(英文全称为compact disk,英文缩写为CD)、激光碟、光碟、数字视频光碟(英文全称为digital video disc,英文缩写为DVD)、软盘或者蓝光光碟。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对 其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims (9)

  1. 一种报文处理方法,其特征在于,所述方法包括:
    中央处理器CPU获取关键字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置;
    所述CPU根据所述关键字的位置参数,从所述报文中获取所述关键字;
    所述CPU根据所述关键字和所述流表的标识,在所述流表中查找与所述关键字匹配的流表表项;以及
    所述CPU根据所述流表表项处理所述报文。
  2. 如权利要求1所述的方法,其特征在于,所述关键字的位置参数包含第一参数和第二参数;
    所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的结束位距所述报文的报文头的偏移值;或者
    所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值;或者
    所述第一参数为所述关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
  3. 一种报文处理装置,其特征在于,所述装置包含第一虚拟机;
    所述第一虚拟机包括:
    第一获取单元,用于获取第一关键字的位置参数和第一流表的标识,所述第一关键字的位置参数用以指示所述第一关键字在报文中的位置;
    第二获取单元,用于根据所述第一获取单元获取的所述第一关键字的位置参数,从所述报文中获取所述第一关键字;
    第一查找单元,用于根据所述第二获取单元获取的所述第一关键字和所述第一获取单元获取的所述第一流表的标识,在所述第一流表中查找与所述第一关键字匹配的流表表项;以及
    第一处理单元,用于根据所述第一查找单元查找的所述第一流表中的所 述流表表项处理所述报文以获得第一报文。
  4. 如权利要求3所述的装置,其特征在于,所述第一关键字的位置参数包含第一参数和第二参数;
    所述第一参数为所述第一关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述第一关键字的结束位距所述报文的报文头的偏移值;或者
    所述第一参数为所述第一关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述第一关键字的长度值;或者
    所述第一参数为所述第一关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述第一关键字的长度值。
  5. 如权利要求3或4所述的装置,其特征在于,所述装置还包含第二虚拟机;
    所述第一处理单元具体用于执行输出所述第一报文至所述第二虚拟机的操作和输出流表跳转GOTO_TABLE指令至所述第二虚拟机的操作,所述流表跳转指令中包含第二流表的标识;
    所述第二虚拟机包括接收单元,用于接收所述第一虚拟机输出的所述第一报文和所述流表跳转指令。
  6. 如权利要求5所述的装置,其特征在于,所述第二虚拟机还包括:
    第三获取单元,用于获取第二关键字的位置参数和从所述流表跳转指令中获取所述第二流表的标识,所述第二关键字的位置参数用以指示所述第二关键字在所述报文中的位置;
    第四获取单元,用于根据所述第三获取单元获取的所述第二关键字的位置参数,从所述接收单元接收的所述第一报文中获取所述第二关键字;
    第二查找单元,用于根据所述第四获取单元获取的所述第二关键字和所述第三获取单元获取的所述第二流表的标识,在所述第二流表中查找与所述第二关键字匹配的流表表项;以及
    第二处理单元,用于根据所述第二查找单元查找的所述第二流表中的所 述流表表项处理所述第一报文。
  7. 如权利要求6所述的装置,其特征在于,所述第二关键字的位置参数包含第三参数和第四参数;
    所述第三参数为所述第二关键字的起始位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的结束位距所述报文的报文头的偏移值;或者
    所述第三参数为所述第二关键字的起始位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的长度值;或者
    所述第三参数为所述第二关键字的结束位距所述报文的报文头的偏移值,所述第四参数为所述第二关键字的长度值。
  8. 一种中央处理器,其特征在于,所述中央处理器包括:
    第一获取单元,用于获取关键字的位置参数和流表的标识,所述关键字的位置参数用以指示所述关键字在报文中的位置;
    第二获取单元,用于根据所述第一获取单元获取的所述关键字的位置参数,从所述报文中获取所述关键字;
    查找单元,用于根据所述第二获取单元获取的所述关键字和所述第一获取单元获取的所述流表的标识,在所述流表中查找与所述关键字匹配的流表表项;以及
    处理单元,用于根据所述查找单元查找的所述流表表项处理所述报文。
  9. 如权利要求8所述的中央处理器,其特征在于,所述关键字的位置参数包含第一参数和第二参数;
    所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的结束位距所述报文的报文头的偏移值;或者
    所述第一参数为所述关键字的起始位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值;或者
    所述第一参数为所述关键字的结束位距所述报文的报文头的偏移值,所述第二参数为所述关键字的长度值。
PCT/CN2015/071634 2014-03-04 2015-01-27 报文处理方法及装置 WO2015131720A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410076738.6 2014-03-04
CN201410076738.6A CN103825824A (zh) 2014-03-04 2014-03-04 一种报文处理方法及装置

Publications (1)

Publication Number Publication Date
WO2015131720A1 true WO2015131720A1 (zh) 2015-09-11

Family

ID=50760663

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/071634 WO2015131720A1 (zh) 2014-03-04 2015-01-27 报文处理方法及装置

Country Status (4)

Country Link
US (1) US20150256459A1 (zh)
EP (1) EP2916516A1 (zh)
CN (1) CN103825824A (zh)
WO (1) WO2015131720A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019128817A1 (zh) * 2017-12-26 2019-07-04 华为技术有限公司 报文处理的方法和装置

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103825824A (zh) * 2014-03-04 2014-05-28 华为技术有限公司 一种报文处理方法及装置
CN105450527B (zh) * 2014-06-05 2019-02-05 华为技术有限公司 处理报文、发送信息、接收信息的方法及装置
CN108600107B (zh) * 2017-11-07 2021-06-01 北京交通大学 一种可自定义内容字段的流匹配方法
CN109995645B (zh) * 2019-03-07 2021-03-16 盛科网络(苏州)有限公司 一种灵活查找fdb表项的芯片实现方法
CN114356418B (zh) * 2022-03-10 2022-08-05 之江实验室 一种智能表项控制器及控制方法

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101834802A (zh) * 2010-05-26 2010-09-15 华为技术有限公司 转发数据包的方法及装置
CN102291294A (zh) * 2011-05-12 2011-12-21 中兴通讯股份有限公司 一种实现pos/eth线卡互通的方法及装置
CN103825824A (zh) * 2014-03-04 2014-05-28 华为技术有限公司 一种报文处理方法及装置

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030007489A1 (en) * 2001-07-09 2003-01-09 Ram Krishnan Data extraction system for packet analysis
US7133409B1 (en) * 2001-07-19 2006-11-07 Richard Willardson Programmable packet filtering in a prioritized chain
US7580408B2 (en) * 2001-11-21 2009-08-25 Alcatel Lucent Configurable packet processor
JP2003308206A (ja) * 2002-04-15 2003-10-31 Fujitsu Ltd プロセッサ装置
US7724740B1 (en) * 2002-08-27 2010-05-25 3Com Corporation Computer system and network interface supporting class of service queues
JP5807672B2 (ja) * 2011-03-15 2015-11-10 日本電気株式会社 移動管理システム、移動管理方法、アクセスgw装置、移動管理制御装置、及びプログラム
EP2560338B1 (en) * 2011-06-13 2016-01-13 Huawei Technologies Co., Ltd. Method and apparatus for protocol parsing
US8718064B2 (en) * 2011-12-22 2014-05-06 Telefonaktiebolaget L M Ericsson (Publ) Forwarding element for flexible and extensible flow processing software-defined networks
US8711860B2 (en) * 2011-12-22 2014-04-29 Telefonaktiebolaget L M Ericsson (Publ) Controller for flexible and extensible flow processing in software-defined networks
CN102447637B (zh) * 2012-01-09 2014-07-30 福建星网锐捷网络有限公司 报文处理方法、系统和网络设备
CN103560951A (zh) * 2013-11-13 2014-02-05 华为技术有限公司 报文处理方法及物理转发设备

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101834802A (zh) * 2010-05-26 2010-09-15 华为技术有限公司 转发数据包的方法及装置
CN102291294A (zh) * 2011-05-12 2011-12-21 中兴通讯股份有限公司 一种实现pos/eth线卡互通的方法及装置
CN103825824A (zh) * 2014-03-04 2014-05-28 华为技术有限公司 一种报文处理方法及装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019128817A1 (zh) * 2017-12-26 2019-07-04 华为技术有限公司 报文处理的方法和装置
US11240148B2 (en) 2017-12-26 2022-02-01 Huawei Technologies Co., Ltd. Packet processing method and apparatus
US11792117B2 (en) 2017-12-26 2023-10-17 Huawei Technologies Co., Ltd. Packet processing method and apparatus

Also Published As

Publication number Publication date
CN103825824A (zh) 2014-05-28
US20150256459A1 (en) 2015-09-10
EP2916516A1 (en) 2015-09-09

Similar Documents

Publication Publication Date Title
US10764181B2 (en) Pipelined evaluations for algorithmic forwarding route lookup
WO2015131720A1 (zh) 报文处理方法及装置
EP2826213B1 (en) Method and system for fast and large-scale longest prefix matching
CN107547349B (zh) 一种虚拟机迁移的方法及装置
JP6269999B2 (ja) パケット処理方法および装置
US9154418B1 (en) Efficient packet classification in a network device
US11729300B2 (en) Generating programmatically defined fields of metadata for network packets
US10237130B2 (en) Method for processing VxLAN data units
CN106878194B (zh) 一种报文处理方法和装置
US9906449B2 (en) System and method for reduced forwarding information storage
WO2015109821A1 (zh) 一种管理业务链的方法、系统及装置
US8923298B2 (en) Optimized trie-based address lookup
US9729446B1 (en) Protocol-independent packet routing
US9979648B1 (en) Increasing entropy across routing table segments
US10313154B2 (en) Packet forwarding
CN109921995B (zh) 一种配置地址表的方法、fpga和应用该fpga的网络设备
WO2015101113A1 (zh) 处理报文的方法与设备
JP2018528699A (ja) パケット処理
US9985885B1 (en) Aggregating common portions of forwarding routes
US20220263746A1 (en) Method for monitoring running state of peer, apparatus, and storage medium
EP3267641A1 (en) Method and device realizing upload of protocol packet to cpu
US10887234B1 (en) Programmatic selection of load balancing output amongst forwarding paths
US9749262B2 (en) Packet processing method and forwarding element
WO2015149367A1 (zh) 报文处理的方法与设备
US9019951B2 (en) Routing apparatus and method for processing network packet thereof

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

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

Ref document number: 15759287

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 15759287

Country of ref document: EP

Kind code of ref document: A1