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

--maxsleep broken for values less than 1000 #421

Closed
GrantEdwards opened this issue Oct 5, 2017 · 3 comments
Closed

--maxsleep broken for values less than 1000 #421

GrantEdwards opened this issue Oct 5, 2017 · 3 comments
Assignees

Comments

@GrantEdwards
Copy link

GrantEdwards commented Oct 5, 2017

On Linux, the --maxsleep option only seems to work correctly for values of 1000 or larger. [Correction, it's broken for any value that isn't a multiple of 1000.] Values smaller than 1000 send packets way faster than they should. It's hard to get accurate test results, but it sort of looks like values less than 1000 are getting treated as microseconds rather than milliseconds. A value of 999 sends around 1000pps, and a value of 500 sends about 2000pps. I get pretty much the same same results for -T gtod, nano, select.

@GrantEdwards
Copy link
Author

To convert from ms to ns, you need to multiply by 1000000 instead of 1000:

diff --git a/src/tcpreplay_api.c b/src/tcpreplay_api.c
index fde27d6a..b6124358 100644
--- a/src/tcpreplay_api.c
+++ b/src/tcpreplay_api.c
@@ -200,7 +200,7 @@ tcpreplay_post_args(tcpreplay_t *ctx, int argc)
 
     if (HAVE_OPT(MAXSLEEP)) {
         options->maxsleep.tv_sec = OPT_VALUE_MAXSLEEP / 1000;
-        options->maxsleep.tv_nsec = (OPT_VALUE_MAXSLEEP % 1000) * 1000;
+        options->maxsleep.tv_nsec = (OPT_VALUE_MAXSLEEP % 1000) * 1000000;
     }

@fklassen fklassen self-assigned this Oct 10, 2017
fklassen added a commit that referenced this issue Jan 26, 2018
@fklassen
Copy link
Member

Thanks for the bug report and the patch. The patch fixes the issue.

fklassen added a commit that referenced this issue Jan 26, 2018
@fklassen
Copy link
Member

Fixed in Pr #460

fklassen added a commit that referenced this issue Oct 19, 2018
* Enhancement_#493_codacy_fixes: (26 commits)
  Enhancement #493 - fixes for Codacy identified issues
  Bug #486 Enforce max snaplen rather than doing realloc
  Bug #486 CVE-2018-17974 realloc memory if packet size increases
  Bug #484 CVE-2018-17582 Check for corrupt PCAP files
  4.3 - revert travis updates from merge
  Remove dead code
  resolve possible null pointer dereference
  travis-ci: add autogen package
  Bug #461 build warnings (#462)
  #412 fix gcc 6.3 compiler warning
  #421 fix ms to ns conversion
  Bug #423 remove commented code
  Bug #423 Remove limit for tcpprep -S
  Bug #398 Rewrite of tcpdump.c (#457)
  Bug #402 memset dlt radiotap get 80211 (#454)
  #404 fix check_list return values (#453)
  #406 fix zero-length IP headers
  #416 apply STDIN restore to all programs
  #416 fix compile issue introduced by downstream PR
  #416 update CHANGELOG [ci skip]
  ...
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