local dpdk = require "dpdk"
local memory = require "memory"
local ts = require "timestamping"
local device = require "device"
local filter = require "filter"
local stats = require "stats"
local timer = require "timer"
local histogram = require "histogram"
local PKT_SIZE = 60
function master(...)
if not txPort or not rxPort then
errorf("usage: txPort rxPort [rate (Mpps)]")
end
rate = rate or 2
local txDev = device.
config(txPort, 2, 2)
local rxDev = device.
config(rxPort, 2, 2)
dpdk.
launchLua("loadSlave", txDev, rxDev, txDev:getTxQueue(0), rate, PKT_SIZE)
dpdk.
launchLua("timerSlave", txDev:getTxQueue(1), rxDev:getRxQueue(1), PKT_SIZE)
end
function loadSlave(dev, rxDev, queue, rate, size)
ethType = 0x1234
}
end)
rxDev:l2Filter(0x1234, filter.DROP)
bufs:alloc(size)
for _, buf in ipairs(bufs) do
-- this script uses Mpps instead of Mbit (like the other scripts)
end
txStats:updateWithSize(queue:sendWithDelay(bufs), size)
rxStats:update()
--txStats:update()
end
end
function timerSlave(txQueue, rxQueue, size)
local timestamper = ts:newTimestamper(txQueue, rxQueue)
local hist = histogram:
new()
-- wait for a second to give the other task a chance to start
local rateLimiter = timer:
new(0.001)
rateLimiter:reset()
hist:update(timestamper:measureLatency(size))
end
hist:print()
hist:save("histogram.csv")
end