Chair for Network Architectures and Services Technical University of Munich (TUM) MoonGen A Scriptable High-Speed Packet Generator Sebastian Gallenm¨ uller, Paul Emmerich October 31th, 2015 Chair for Network Architectures and Services Department of Informatics Technical University of Munich (TUM) Sebastian Gallenm¨ uller – MoonGen: A Scriptable High-Speed Packet Generator 1
Chair for Network Architectures and Services Technical University of Munich (TUM) Design goals Design goal of MoonGen Combine the advantages of software (cheap, flexible) and hardware (precise, accurate) packet generators. Sebastian Gallenm¨ uller – MoonGen: A Scriptable High-Speed Packet Generator 2
Chair for Network Architectures and Services Technical University of Munich (TUM) Design goals Design goal of MoonGen Combine the advantages of software (cheap, flexible) and hardware (precise, accurate) packet generators. ◮ Fast: DPDK for packet I/O, explicit multi-core support ◮ Flexible: Craft all packets in user-controller Lua scripts ◮ Timestamping: Utilize hardware features found on modern commodity NICs ◮ Rate control: Hardware features and a novel software approach Sebastian Gallenm¨ uller – MoonGen: A Scriptable High-Speed Packet Generator 2
Chair for Network Architectures and Services Technical University of Munich (TUM) Lua VM Architecture Lua VM Lua VM Userscript Userscript Userscript Userscript Userscript master spawn slave config API data API MoonGen MoonGen Core config API data API DPDK Q 0 ... Q n HW NIC NIC Port Port Sebastian Gallenm¨ uller – MoonGen: A Scriptable High-Speed Packet Generator 3
Chair for Network Architectures and Services Technical University of Munich (TUM) Device Initilization function master(txPort, rxPort, rate) 1 local tDev = device.config{port = txPort, txQueues = 2} 2 local rDev = device.config{port = rxPort, rxQueues = 2} 3 device.waitForLinks() 4 tDev:getTxQueue(0):setRate(rate) 5 mg.launchLua("loadSlave", tDev:getTxQueue(0)) 6 mg.launchLua("timerSlave", tDev:getTxQueue(1), 7 rDev:getRxQueue(1)) 8 mg.waitForSlaves() 9 end 10 Paul Emmerich – MoonGen: A Scriptable High-Speed Packet Generator 4
Chair for Network Architectures and Services Technical University of Munich (TUM) Measuring Latency function timerSlave(txQ, rxQ) 1 rxQ.dev:filterTimestamps(rxQ) 2 local timestamper = ts:newUdpTimestamper(txQ, rxQ) 3 local hist = histogram:new() 4 while mg.running() do 5 hist:update(timestamper:measureLatency(function(buf) 6 local pkt = buf:getUdpPacket() 7 pkt.ip4.src:set(math.random(0, 2^32 - 1)) 8 pkt.udp.src:set(math.random(0, 2^16 - 1)) 9 end)) 10 end 11 hist:save("histogram.csv") 12 end 13 Paul Emmerich – MoonGen: A Scriptable High-Speed Packet Generator 5
Chair for Network Architectures and Services Technical University of Munich (TUM) Generating Load function loadSlave(queue) 1 local mempool = memory.createMemPool(function(buf) 2 buf:getUdpPacket():fill() 3 end) 4 local bufs = mempool:bufArray() 5 while mg.running() do 6 bufs:alloc(60) 7 for i, buf in ipairs(bufs) do 8 local pkt = buf:getUdpPacket() 9 pkt.ip4.src:set(math.random(0, 2^32 - 1)) 10 pkt.udp.src:set(math.random(0, 2^16 - 1)) 11 end 12 bufs:offloadUdpChecksums() 13 queue:send(bufs) 14 end 15 Paul Emmerich – MoonGen: A Scriptable High-Speed Packet Generator 6
Recommend
More recommend