Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
source_nic_sink_3.lua
-- Source -> NIC1 -> NIC2 -> Sink
-- How to run:
-- sudo ./snabb snsh source_nic_sink_3.lua
-- The NIC is connected in loop back mode.
-- link report:
-- 9,169,796 sent on nic2.tx -> sink.in1 (loss rate: 0%)
-- 9,237,861 sent on repeater_ms.output -> nic1.rx (loss rate: 0%)
-- 1 sent on source_ms.out -> repeater_ms.input (loss rate: 0%)
local basic_apps = require("apps.basic.basic_apps")
local Intel82599 = require("apps.intel.intel_app").Intel82599
local lib = require("core.lib")
function test (pcidev)
local d1 = lib.hexundump ([[
52:54:00:02:02:02 52:54:00:01:01:01 08 00 45 00
00 54 c3 cd 40 00 40 01 f3 23 c0 a8 01 66 c0 a8
01 01 08 00 57 ea 61 1a 00 06 5c ba 16 53 00 00
00 00 04 15 09 00 00 00 00 00 10 11 12 13 14 15
16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35
36 37
]], 98)
engine.configure(config.new())
local c = config.new()
config.app(c, 'source_ms', basic_apps.Join)
config.app(c, 'repeater_ms', basic_apps.Repeater)
config.app(c, 'sink', basic_apps.Sink)
config.app(c, 'nic1', Intel82599,
{pciaddr = pcidev,
vmdq = true,
macaddr = '52:54:00:01:01:01'})
config.app(c, 'nic2', Intel82599,
{pciaddr = pcidev,
vmdq = true,
macaddr = '52:54:00:02:02:02'})
config.link(c, 'source_ms.out -> repeater_ms.input')
config.link(c, 'repeater_ms.output -> nic1.rx')
config.link(c, 'nic2.tx -> sink.in1')
engine.configure(c)
link.transmit(engine.app_table.source_ms.output.out, packet.from_string(d1))
engine.main({duration=1, report={showlinks=true}})
end
local pcidev = '0000:04:00.0'
test(pcidev)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.