emmericp / MoonGen

MoonGen is a fully scriptable high-speed packet generator built on DPDK and LuaJIT. It can saturate a 10 Gbit/s connection with 64 byte packets on a single CPU core while executing user-provided Lua scripts for each packet. Multi-core support allows for even higher rates. It also features precise and accurate timestamping and rate control.
MIT License
1.04k stars 234 forks source link

Cannot reset pcap with ratelimiter #240

Closed Gavindeed closed 5 years ago

Gavindeed commented 5 years ago

Hi,

Currently I try to replay pcap traces using MoonGen. I came across an issue that, if I set rate limiter with the loop option (e.g., using -l -r 10), MoonGen will not reset the pcap trace. If I do not set the rate limiter, everything works well. Here are the detailed outputs:

$ sudo ./build/MoonGen ./examples/pcap/replay-pcap.lua 0 trace/caida16.pcap -r 10 -l [INFO] 1 device is up. [Device: id=0] TX: 5.29 Mpps, 2884 Mbit/s (3729 Mbit/s with framing) [Device: id=0] TX: 4.88 Mpps, 2663 Mbit/s (3443 Mbit/s with framing) [Device: id=0] TX: 5.48 Mpps, 2993 Mbit/s (3869 Mbit/s with framing) [Device: id=0] TX: 5.46 Mpps, 2978 Mbit/s (3852 Mbit/s with framing) [Device: id=0] TX: 5.37 Mpps, 2932 Mbit/s (3792 Mbit/s with framing) [Device: id=0] TX: 3.60 Mpps, 1964 Mbit/s (2540 Mbit/s with framing) [Device: id=0] TX: 0.00 Mpps, 0 Mbit/s (0 Mbit/s with framing) [Device: id=0] TX: 0.00 Mpps, 0 Mbit/s (0 Mbit/s with framing) [Device: id=0] TX: 0.00 Mpps, 0 Mbit/s (0 Mbit/s with framing) [Device: id=0] TX: 0.00 Mpps, 0 Mbit/s (0 Mbit/s with framing) [Device: id=0] TX: 0.00 Mpps, 0 Mbit/s (0 Mbit/s with framing)

$ sudo ./build/MoonGen ./examples/pcap/replay-pcap.lua 0 trace/caida16.pcap -l [INFO] 1 device is up. [Device: id=0] TX: 12.83 Mpps, 7004 Mbit/s (9056 Mbit/s with framing) [Device: id=0] TX: 13.56 Mpps, 7400 Mbit/s (9569 Mbit/s with framing) [Device: id=0] TX: 14.16 Mpps, 7729 Mbit/s (9994 Mbit/s with framing) [Device: id=0] TX: 14.16 Mpps, 7730 Mbit/s (9995 Mbit/s with framing) [Device: id=0] TX: 14.16 Mpps, 7728 Mbit/s (9995 Mbit/s with framing) [Device: id=0] TX: 14.15 Mpps, 7730 Mbit/s (9995 Mbit/s with framing) [Device: id=0] TX: 14.16 Mpps, 7728 Mbit/s (9995 Mbit/s with framing) [Device: id=0] TX: 14.15 Mpps, 7730 Mbit/s (9994 Mbit/s with framing) [Device: id=0] TX: 14.16 Mpps, 7726 Mbit/s (9992 Mbit/s with framing) [Device: id=0] TX: 14.15 Mpps, 7730 Mbit/s (9994 Mbit/s with framing) [Device: id=0] TX: 14.17 Mpps, 7728 Mbit/s (9995 Mbit/s with framing) [Device: id=0] TX: 14.15 Mpps, 7730 Mbit/s (9994 Mbit/s with framing) [Device: id=0] TX: 14.16 Mpps, 7728 Mbit/s (9995 Mbit/s with framing) [Device: id=0] TX: 14.15 Mpps, 7730 Mbit/s (9995 Mbit/s with framing)

I am using the CAIDA16 trace. I also tried other traces, and I got the same result.

Thanks, Junzhi

Gavindeed commented 5 years ago

Fix that. Change line 65 from "if rateLimiter then" to "if rateLimiter and n > 0 then".

Junzhi