-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdump.lua
More file actions
33 lines (29 loc) · 788 Bytes
/
dump.lua
File metadata and controls
33 lines (29 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local mg = require "moongen"
local memory = require "memory"
local device = require "device"
local stats = require "stats"
local log = require "log"
function configure(parser)
parser:argument("rxDev", "The device to receive from"):convert(tonumber)
end
function master(args)
local rxDev = device.config{port = args.rxDev, dropEnable = false}
device.waitForLinks()
mg.startTask("dumpSlave", rxDev:getRxQueue(0))
mg.waitForTasks()
end
function dumpSlave(queue)
local bufs = memory.bufArray()
local pktCtr = stats:newPktRxCounter("Packets counted", "plain")
while mg.running() do
local rx = queue:tryRecv(bufs, 100)
for i = 1, rx do
local buf = bufs[i]
--buf:dump()
pktCtr:countPacket(buf)
end
bufs:free(rx)
pktCtr:update()
end
pktCtr:finalize()
end