emmericp / MoonGen

MoonGen is a fully scriptable high-speed packet generator built on DPDK and LuaJIT. It can saturate a 10 Gbit/s connection with 64 byte packets on a single CPU core while executing user-provided Lua scripts for each packet. Multi-core support allows for even higher rates. It also features precise and accurate timestamping and rate control.
MIT License
1.04k stars 234 forks source link

SetVlan failed #251

Closed qwe131829 closed 4 years ago

qwe131829 commented 4 years ago

Recently, I need to construct a message with a double-layer vlan for testing. I try to modify pktgen, using setVlan function to construct vlan packet based on udp with X710. However, through wireshark analysis, it is found that type is still ip4,0x800, with vlan missing in the middle. Is there anything need to be modified or is there something wrong with the thinking? If I want to construct QINQ based on this, can I only use getEthernetQinQpacket () to add header?

function txSlave(queue, dstMac) -- memory pool with default values for all packets, this is our archetype local mempool = memory.createMemPool(function(buf) buf:getUdpPacket():fill{ -- fields not explicitly set here are initialized to reasonable defaults ethSrc = queue, -- MAC of the tx device ethDst = dstMac, ip4Src =SRC_IP, ip4Dst = "2.2.2.2", udpSrc = SRC_PORT, udpDst = DST_PORT, pktLength = PKT_LEN } buf:setVlan(1234) -- buf:dump() end)

emmericp commented 4 years ago

setVlan enables VLAN offloading for this packet, QinQ handling is probably highly specific to the hardware. getEthernetQinQpacket is probably the better/more portable way here

qwe131829 commented 4 years ago

I also think it is possible, but I cannot accept catching this packert after adding setVlan by TCP dump.