摘要 |
A packet editing method and a related device. The packet editing method comprises: generating an input packet template according to N protocol header fields to be edited of an input packet and a preset protocol field mapping relationship, the input packet template comprising N protocol descriptors in one-to-one correspondence with the N protocol header fields, and the protocol field mapping relationship being a mapping relationship between protocol fields comprised in protocol descriptors and protocol fields comprised in protocol header fields having a correspondence to the protocol descriptors; editing the input packet template to obtain an output packet template; and converting M protocol descriptors comprised in the obtained output packet template into M protocol header fields of an output packet according to the preset protocol field mapping relationship, and replacing the N protocol header fields in the input packet with the M protocol header fields to obtain the output packet. The solution helps to reduce the complexity of instructions for packet editing and improve the efficiency of packet editing. |