From 9155b53bf6d31d4d7df2a9452320b34b6253ee89 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 26 Jul 2017 15:53:54 +0200 Subject: [PATCH] Simplify "probe" interface to rely on ARP --- src/program/ipfix/probe/README | 9 ++++-- src/program/ipfix/probe/probe.lua | 48 +++++++++++-------------------- src/program/ipfix/tests/bench.sh | 2 +- 3 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/program/ipfix/probe/README b/src/program/ipfix/probe/README index ff1e6d4a01..7082604659 100644 --- a/src/program/ipfix/probe/README +++ b/src/program/ipfix/probe/README @@ -1,12 +1,13 @@ Usage: snabb ipfix probe [options] snabb ipfix probe --help -Mandatory arguments: +Available options: -m, --host-mac The MAC address of the host running the exporter. + Defaults to a randomly generated MAC. -a, --host-ip The IP address of the host running the exporter. + Defaults to 10.0.0.1. -c, --collector The IP address of the flow collector. - -Optional arguments: + Defaults to 10.0.0.2. -i, --input-type One of pcap, raw, or intel10g. Specifies how to interpret the argument. Interprets as a pcap file path, device name, or @@ -23,3 +24,5 @@ Optional arguments: --transport The transport protocol to use to communicate to the flow collector. Valid values depend on whether IPFIX or Netflow V9 is used. + --cpu Bind to the given CPU. See the Snabb + performance guide for more details. diff --git a/src/program/ipfix/probe/probe.lua b/src/program/ipfix/probe/probe.lua index 4d86897e0e..1c17eba043 100644 --- a/src/program/ipfix/probe/probe.lua +++ b/src/program/ipfix/probe/probe.lua @@ -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", @@ -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 = { @@ -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, @@ -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") @@ -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() @@ -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 diff --git a/src/program/ipfix/tests/bench.sh b/src/program/ipfix/tests/bench.sh index 3d9c710acc..1708e90bd6 100755 --- a/src/program/ipfix/tests/bench.sh +++ b/src/program/ipfix/tests/bench.sh @@ -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