Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] looping inflates some packet counters #749

Closed
infrastation opened this issue Sep 7, 2022 · 2 comments
Closed

[Bug] looping inflates some packet counters #749

infrastation opened this issue Sep 7, 2022 · 2 comments
Assignees

Comments

@infrastation
Copy link
Contributor

infrastation commented Sep 7, 2022

Describe the bug
Some of the statistics become incorrect when the loop counter is greater than the default one.

To Reproduce
Steps to reproduce the behavior:

  1. Run tcpreplay with a file that includes both flow and non-flow packets without the -l flag and note the counters.
  2. Run tcpreplay again with two loops and note that "successful packets" are twice as high, whereas "flow packets" and "non-flow" are 4 times (2*2) as high.
  3. Run tcpreplay again with three loops and note that "successful packets" are three times as high, whereas "flow packets" and "non-flow" are 9 times (3*3) as high.
  4. ...and so on

Expected behavior
The counters are proportional to the number of loops rather than the square of the number of loops.

Screenshots

# tcpreplay --mbps 1 -i eth0 isakmp4500.pcap 
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Actual: 35 packets (6246 bytes) sent in 0.049980 seconds
Rated: 124969.9 Bps, 0.999 Mbps, 700.28 pps
Flows: 4 flows, 80.03 fps, 27 flow packets, 8 non-flow
Statistics for network device: eth0
	Successful packets:        35
	Failed packets:            0
	Truncated packets:         0
	Retried packets (ENOBUFS): 0
	Retried packets (EAGAIN):  0

# tcpreplay -l 2 --mbps 1 -i eth0 isakmp4500.pcap 
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Actual: 70 packets (12492 bytes) sent in 0.099940 seconds
Rated: 124994.9 Bps, 0.999 Mbps, 700.42 pps
Flows: 4 flows, 40.02 fps, 108 flow packets, 32 non-flow
Statistics for network device: eth0
	Successful packets:        70
	Failed packets:            0
	Truncated packets:         0
	Retried packets (ENOBUFS): 0
	Retried packets (EAGAIN):  0

# tcpreplay -l 3 --mbps 1 -i eth0 isakmp4500.pcap 
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Actual: 105 packets (18738 bytes) sent in 0.149910 seconds
Rated: 124994.9 Bps, 0.999 Mbps, 700.42 pps
Flows: 4 flows, 26.68 fps, 243 flow packets, 72 non-flow
Statistics for network device: eth0
	Successful packets:        105
	Failed packets:            0
	Truncated packets:         0
	Retried packets (ENOBUFS): 0
	Retried packets (EAGAIN):  0

# tcpreplay -l 4 --mbps 1 -i eth0 isakmp4500.pcap 
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Warning: isakmp4500.pcap was captured using a snaplen of 1536 bytes.  This may mean you have truncated packets.
Actual: 140 packets (24984 bytes) sent in 0.199878 seconds
Rated: 124996.2 Bps, 0.999 Mbps, 700.42 pps
Flows: 4 flows, 20.01 fps, 432 flow packets, 128 non-flow
Statistics for network device: eth0
	Successful packets:        140
	Failed packets:            0
	Truncated packets:         0
	Retried packets (ENOBUFS): 0
	Retried packets (EAGAIN):  0

System:

  • OS: Ubuntu Linux 22.04 AMD64
  • Tcpreplay master branch at commit 76644c2
@fklassen fklassen self-assigned this Dec 28, 2022
fklassen added a commit that referenced this issue Dec 30, 2022
Flow, fps, flow packet counts make sense for many combinations of packet
modifiers and cache settings:

```
# tcpreplay -i enp0s5 -l1 --mbps=1 ping.pcap
Actual: 16 packets (1568 bytes) sent in 0.012564 seconds
Rated: 124801.0 Bps, 0.998 Mbps, 1273.47 pps
Flows: 2 flows, 159.18 fps, 16 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        16
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l1 --mbps=1 -K ping.pcap
File Cache is enabled
Actual: 16 packets (1568 bytes) sent in 0.012561 seconds
Rated: 124830.8 Bps, 0.998 Mbps, 1273.78 pps
Flows: 2 flows, 159.22 fps, 16 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        16
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125452 seconds
Rated: 124988.0 Bps, 0.999 Mbps, 1275.38 pps
Flows: 2 flows, 15.94 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 -K ping.pcap
File Cache is enabled
Actual: 160 packets (15680 bytes) sent in 0.125451 seconds
Rated: 124989.0 Bps, 0.999 Mbps, 1275.39 pps
Flows: 2 flows, 15.94 fps, 16 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125451 seconds
Rated: 124989.0 Bps, 0.999 Mbps, 1275.39 pps
Flows: 20 flows, 159.42 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 -K ping.pcap
File Cache is enabled
Actual: 160 packets (15680 bytes) sent in 0.125457 seconds
Rated: 124983.0 Bps, 0.999 Mbps, 1275.33 pps
Flows: 20 flows, 159.41 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125456 seconds
Rated: 124984.0 Bps, 0.999 Mbps, 1275.34 pps
Flows: 8 flows, 63.76 fps, 64 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 -K ping.pcap
File Cache is enabled
Actual: 160 packets (15680 bytes) sent in 0.125450 seconds
Rated: 124990.0 Bps, 0.999 Mbps, 1275.40 pps
Flows: 8 flows, 63.77 fps, 64 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

```
fklassen added a commit that referenced this issue Dec 30, 2022
Bug #749 flow stats: avoid overstating flow packet count
@fklassen
Copy link
Member

fklassen commented Dec 30, 2022

Fixed in PR #765 and targeted for v4.4.3.

Verification:

# tcpreplay -i enp0s5 -l1 --mbps=1 ping.pcap
Actual: 16 packets (1568 bytes) sent in 0.012564 seconds
Rated: 124801.0 Bps, 0.998 Mbps, 1273.47 pps
Flows: 2 flows, 159.18 fps, 16 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        16
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l1 --mbps=1 -K ping.pcap
File Cache is enabled
Actual: 16 packets (1568 bytes) sent in 0.012561 seconds
Rated: 124830.8 Bps, 0.998 Mbps, 1273.78 pps
Flows: 2 flows, 159.22 fps, 16 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        16
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125452 seconds
Rated: 124988.0 Bps, 0.999 Mbps, 1275.38 pps
Flows: 2 flows, 15.94 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 -K ping.pcap
File Cache is enabled
Actual: 160 packets (15680 bytes) sent in 0.125451 seconds
Rated: 124989.0 Bps, 0.999 Mbps, 1275.39 pps
Flows: 2 flows, 15.94 fps, 16 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125451 seconds
Rated: 124989.0 Bps, 0.999 Mbps, 1275.39 pps
Flows: 20 flows, 159.42 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 -K ping.pcap
File Cache is enabled
Actual: 160 packets (15680 bytes) sent in 0.125457 seconds
Rated: 124983.0 Bps, 0.999 Mbps, 1275.33 pps
Flows: 20 flows, 159.41 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125456 seconds
Rated: 124984.0 Bps, 0.999 Mbps, 1275.34 pps
Flows: 8 flows, 63.76 fps, 64 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay -i enp0s5 -l10 --mbps=1 --unique-ip --unique-ip-loops=3 -K ping.pcap
File Cache is enabled
Actual: 160 packets (15680 bytes) sent in 0.125450 seconds
Rated: 124990.0 Bps, 0.999 Mbps, 1275.40 pps
Flows: 8 flows, 63.77 fps, 64 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

# tcpreplay-edit -i enp0s5 -l10 --mbps=1 --seed=42 ping.pcap
Actual: 160 packets (15680 bytes) sent in 0.125454 seconds
Rated: 124986.0 Bps, 0.999 Mbps, 1275.36 pps
Flows: 20 flows, 159.42 fps, 160 unique flow packets, 0 unique non-flow packets
Statistics for network device: enp0s5
        Successful packets:        160
        Failed packets:            0
        Truncated packets:         0
        Retried packets (ENOBUFS): 0
        Retried packets (EAGAIN):  0

@infrastation
Copy link
Contributor Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants