Skip to content

Commit

Permalink
[packetblaster] Add --duration option.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Jun 29, 2015
1 parent 559c7e8 commit 49e9210
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/program/packetblaster/README
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
Usage: packetblaster replay <PCAP-FILE> <PCI>...
Usage: packetblaster replay [OPTIONS] <PCAP-FILE> <PCI>...

-D DURATION, --duration DURATION
Run for DURATION seconds.
-h, --help
Print usage information.

Transmit packets from PCAP-FILE continuously to one or more network
adapters. The PCI arguments are Lua pattern strings that are used to
Expand Down
21 changes: 16 additions & 5 deletions src/program/packetblaster/packetblaster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ local basic_apps = require("apps.basic.basic_apps")
local main = require("core.main")
local PcapReader= require("apps.pcap.pcap").PcapReader
local LoadGen = require("apps.intel.loadgen").LoadGen
local lib = require("core.lib")
local ffi = require("ffi")
local C = ffi.C

local usage = require("program.packetblaster.README_inc")

local long_opts = {
duration = "D",
help = "h"
}

function run (args)
if #args < 3 or table.remove(args, 1) ~= 'replay' then
print(require("program.packetblaster.README_inc"))
os.exit(1)
end
local opt = {}
local duration
function opt.D (arg) duration = tonumber(arg) end
function opt.h (arg) print(usage) main.exit(1) end
if #args < 3 or table.remove(args, 1) ~= 'replay' then opt.h() end
args = lib.dogetopt(args, opt, "hD:", long_opts)
local filename = table.remove(args, 1)
local patterns = args
local c = config.new()
Expand All @@ -42,7 +52,8 @@ function run (args)
end
local t = timer.new("report", fn, 1e9, 'repeating')
timer.activate(t)
app.main()
if duration then app.main({duration=duration})
else app.main() end
end

function is_device_suitable (pcidev, patterns)
Expand Down

0 comments on commit 49e9210

Please sign in to comment.