Skip to content

Commit

Permalink
Simplify "probe" interface to rely on ARP
Browse files Browse the repository at this point in the history
  • Loading branch information
wingo committed Jul 31, 2017
1 parent b949911 commit 9155b53
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 36 deletions.
9 changes: 6 additions & 3 deletions src/program/ipfix/probe/README
@@ -1,12 +1,13 @@
Usage: snabb ipfix probe [options] <input> <output>
snabb ipfix probe --help

Mandatory arguments:
Available options:
-m, --host-mac <macaddr> The MAC address of the host running the exporter.
Defaults to a randomly generated MAC.
-a, --host-ip <ipaddr> The IP address of the host running the exporter.
Defaults to 10.0.0.1.
-c, --collector <ipaddr> The IP address of the flow collector.

Optional arguments:
Defaults to 10.0.0.2.
-i, --input-type <type> One of pcap, raw, or intel10g. Specifies
how to interpret the <input> argument. Interprets
<input> as a pcap file path, device name, or
Expand All @@ -23,3 +24,5 @@ Optional arguments:
--transport <proto> The transport protocol to use to communicate to
the flow collector. Valid values depend on whether
IPFIX or Netflow V9 is used.
--cpu <cpu> Bind to the given CPU. See the Snabb
performance guide for more details.
48 changes: 16 additions & 32 deletions src/program/ipfix/probe/probe.lua
Expand Up @@ -37,7 +37,6 @@ local long_opts = {
port = "p",
transport = 1,
stats = "s",
["host-mac"] = "m",
["host-ip"] = "a",
["input-type"] = "i",
["output-type"] = "o",
Expand All @@ -53,15 +52,15 @@ function run (args)

local input_type, output_type = "intel10g", "intel10g"

local host_mac, host_ip
local collector_mac, colletor_ip
local host_mac
local host_ip = '10.0.0.1' -- Just to have a default.
local collector_ip = '10.0.0.2' -- Likewise.
local port = 4739

local active_timeout, idle_timeout
local ipfix_version = 10

local cpu
local report = false

-- TODO: better input validation
local opt = {
Expand All @@ -83,9 +82,6 @@ function run (args)
p = function (arg)
port = assert(tonumber(arg), "expected number for port")
end,
s = function (arg)
report = true
end,
m = function (arg)
host_mac = arg
end,
Expand All @@ -95,10 +91,6 @@ function run (args)
c = function (arg)
collector_ip = arg
end,
-- TODO: this should probably be superceded by using ARP
M = function (arg)
collector_mac = arg
end,
["active-timeout"] = function (arg)
active_timeout =
assert(tonumber(arg), "expected number for active timeout")
Expand Down Expand Up @@ -126,23 +118,16 @@ function run (args)
main.exit(1)
end

assert(host_mac, "--host-mac argument required")
assert(host_ip, "--host-ip argument required")
assert(collector_ip, "--collector argument required")

local in_link, in_app = in_out_apps[input_type](args[1])
local out_link, out_app = in_out_apps[output_type](args[2])

local arp_config = { self_mac = host_mac,
self_ip = host_ip,
next_mac = collector_mac,
next_ip = collector_ip }
local arp_config = { self_mac = host_mac and ethernet:pton(self_mac),
self_ip = ipv4:pton(host_ip),
next_ip = ipv4:pton(collector_ip) }
local ipfix_config = { active_timeout = active_timeout,
idle_timeout = idle_timeout,
ipfix_version = ipfix_version,
exporter_mac = host_mac,
exporter_ip = host_ip,
collector_mac = collector_mac,
collector_ip = collector_ip,
collector_port = port }
local c = config.new()
Expand All @@ -164,21 +149,20 @@ function run (args)
end
end

local start_time = now()
local t1 = now()
if cpu then numa.bind_to_cpu(cpu) end

engine.configure(c)
engine.busywait = true
engine.main({ duration = duration, done = done })

if report then
local end_time = now()
local stats = link.stats(engine.app_table.ipfix.input.input)
print("IPFIX probe stats:")
print(string.format("bytes: %s packets: %s bps: %s Mpps: %s",
lib.comma_value(stats.rxbytes),
lib.comma_value(stats.rxpackets),
lib.comma_value(math.floor((stats.rxbytes * 8) / (end_time - start_time))),
lib.comma_value(stats.rxpackets / ((end_time - start_time) * 1000000))))
end
local t2 = now()
local stats = link.stats(engine.app_table.ipfix.input.input)
print("IPFIX probe stats:")
local comma = lib.comma_value
print(string.format("bytes: %s packets: %s bps: %s Mpps: %s",
comma(stats.rxbytes),
comma(stats.rxpackets),
comma(math.floor((stats.rxbytes * 8) / (t2 - t1))),
comma(stats.rxpackets / ((t2 - t1) * 1000000))))
end
2 changes: 1 addition & 1 deletion src/program/ipfix/tests/bench.sh
Expand Up @@ -26,7 +26,7 @@ function benchmark {
for (( i=1; i<=$ITERS; i++ ))
do
# run the probe
./snabb ipfix probe --cpu $CPU -s -i intel10g -o intel10g -m 00:11:22:33:44:55 -a 192.168.1.2 -M 55:44:33:22:11:00 -c 192.168.1.3 -p 2100 -D $DURATION $PCI1 $PCI3 > $output &
./snabb ipfix probe --cpu $CPU -D $DURATION $PCI1 $PCI3 > $output &
# blast with pcap traffic
./snabb packetblaster replay -D $DURATION $pcap $PCI2 > /dev/null &
wait
Expand Down

0 comments on commit 9155b53

Please sign in to comment.