Skip to content

Commit

Permalink
add packet loss calc
Browse files Browse the repository at this point in the history
  • Loading branch information
hb9cwp committed Jan 8, 2016
1 parent 620f02e commit c0f256a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/program/snabbmark/snabbmark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,18 @@ receive_device.interface= "rx1GE"
end
local finish = C.get_monotonic_time()
local runtime = finish - start
local packets = link.stats(engine.app_table.source.output.tx).txpackets
local txpackets = link.stats(engine.app_table.source.output.tx).txpackets
local rxpackets = link.stats(engine.app_table.sink.input.rx).rxpackets
engine.report()
engine.app_table[send_device.interface]:report()
engine.app_table[receive_device.interface]:report()
print()
print(("Processed %.1f million packets in %.2f seconds (rate: %.1f Mpps, %.2f Gbit/s)."):format(packets / 1e6,
runtime, packets / runtime / 1e6,
((packets * packet_size * 8) / runtime) / (1024*1024*1024)))
print(("Processed %.1f million packets in %.2f seconds (rate: %.1f Mpps, %.2f Gbit/s, %.2f %% packet loss)."):format(
txpackets / 1e6, runtime,
txpackets / runtime / 1e6,
((txpackets * packet_size * 8) / runtime) / (1024*1024*1024),
(txpackets - rxpackets) *100 / txpackets
))
if link.stats(engine.app_table.source.output.tx).txpackets < npackets then
print("Packets lost. Test failed!")
main.exit(1)
Expand Down

0 comments on commit c0f256a

Please sign in to comment.