Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expand synth to generate random payloads and include a packet id, add…
… apps.test.npackets an app that only sends n packets from input to output
- Loading branch information
1 parent
31c8d78
commit 4a04933
Showing
3 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module(...,package.seeall) | ||
|
||
local ffi = require("ffi") | ||
local C = ffi.C | ||
Npackets = { | ||
config = { | ||
npackets = { default = 1000000 } | ||
} | ||
} | ||
|
||
function Npackets:new (conf) | ||
return setmetatable({n = conf.npackets}, { __index = Npackets}) | ||
end | ||
|
||
function Npackets:push () | ||
while not link.empty(self.input.input) and | ||
self.n > 0 do | ||
link.transmit(self.output.output, link.receive(self.input.input)) | ||
self.n = self.n - 1 | ||
end | ||
end | ||
|
||
function selftest() | ||
local synth = require("apps.test.synth") | ||
local basic_apps = require("apps.basic.basic_apps") | ||
local counter = require("core.counter") | ||
|
||
local c = config.new() | ||
config.app(c, "src", synth.Synth) | ||
config.app(c, "n", Npackets, { npackets = 100 }) | ||
config.app(c, "sink", basic_apps.Sink) | ||
config.link(c, "src.output -> n.input") | ||
config.link(c, "n.output -> sink.input") | ||
engine.configure(c) | ||
assert(engine.app_table.n.n == 100) | ||
engine.main({duration=1}) | ||
assert(engine.app_table.n.n == 0) | ||
assert(counter.read(engine.link_table['src.output -> n.input'].stats.txpackets) > 100) | ||
local cnt = counter.read(engine.link_table['n.output -> sink.input'].stats.rxpackets) | ||
assert(100 == cnt) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters