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

bwtester: simplification, cleanup #209

Merged
merged 3 commits into from
Nov 23, 2021
Merged

bwtester: simplification, cleanup #209

merged 3 commits into from
Nov 23, 2021

Conversation

matzf
Copy link
Contributor

@matzf matzf commented Nov 10, 2021

Simplification, refactoring, cleanup of the bwtester codebase.

This does not introduce any (significant) behaviour changes; the
applications are compatible with the version before this change.
One breaking change is that we've removed the rather pointless -id and
-log_dir flags from the bwtestserver.
In the client, the output format has been slightly adapted.

The motivation for this is to make it easier to convert bwtester to use
the pan library. In particular, one goal was to make HandleDCCnnSend/Receive
functions (shared between client and server) dumber, i.e making them do
nothing but Write/Read on the connection. This will help to adapt this to
pan with its asymmetric dialed/listening connections.

The most relevant changes are:

  • split functions, reduce duplicate code
  • try to get some semblance of reasonable error handling
  • simplify the termination of tests by simplifying; set Read/Write
    deadlines for the data channel (once!), ensuring that the reader/write
    routines abort in time.
  • remove ExpectedFinishTime from BwtestResults struct. Was only used
    for (unnecessarily confusing) internal bookkeeping, does not need to
    be on the wire. The "gob" encoding on the wire is still compatible.
  • server: avoid excessive concurrent access to results map to get rid of
    the excessive locking code. Only add the result entry once it's
    actually available (it's so much easier...).
  • client: shorten output format for Interarrival time (~analogous to
    ping output)

Note that this is a limited cleanup pass, trying not to change too much
at once and not to introduce breaking changes. The code (and the
functionality) can clearly still be improved...


This change is Reviewable

Copy link
Member

@juagargi juagargi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for maintaining this bwtest toolset tidy.
We would like to use these tools and supersede the ad-hoc cbrtester. One of the useful things to do with cbrtester is to leave it running in the background, and start loading the BR.
Some things that would make this tool supersede cbrtester:

  • Instant reporting. Configure reporting every N seconds.
  • Allow noop for one of the directions: typically client-to-server would be empty to test load specific border routers. At the moment the reporting will crash with a divide by zero.
  • Infinite duration. At the moment we could write a big number of seconds for the duration parameter if we change the value of MaxDuration, so this is no big issue.
  • Fine tune reporting: report delays over certain threshold. This is useful while debugging a BR.
  • Useful to identify packets in the captures is the ability of setting up certain pattern in the payload. This greatly simplified finding where the delays were being added.
  • Not present in cbrtester but definitely useful: select the path with a policy (filter predicate).

It could be nice to have a symlink to the binary with a different name, check argv[0] and prepend a default set of arguments if invoked like e.g. cbrbwclienttest.

Reviewed 1 of 4 files at r1, all commit messages.
Reviewable status: 1 of 4 files reviewed, all discussions resolved / 0 of 1 LGTMs obtained / 0 of 1 approvals obtained

Simplification, refactoring, cleanup of the bwtester codebase.

This does not introduce any (significant) behaviour changes; the
applications are compatible with the version before this change.
One breaking change is that we've removed the rather pointless `-id` and
`-log_dir` flags from the bwtestserver.
In the client, the output format has been slightly adapted.

The motivation for this is to make it easier to convert bwtester to use
the pan library. In particular, one goal was to make `HandleDCCnnSend/Receive`
functions (shared between client and server) dumber, i.e making them do
nothing but Write/Read on the connection. This will help to adapt this to
pan with its asymmetric dialed/listening connections.

The most relevant changes are:
* split functions, reduce duplicate code
* try to get some semblance of reasonable error handling
* simplify the termination of tests by simplifying; set Read/Write
  deadlines for the data channel (once!), ensuring that the reader/write
  routines abort in time.
* remove `ExpectedFinishTime` from `BwtestResults` struct. Was only used
  for (unnecessarily confusing) internal bookkeeping, does not need to
  be on the wire. The "gob" encoding on the wire is still compatible.
* server: avoid excessive concurrent access to results map to get rid of
  the excessive locking code. Only add the result entry once it's
  actually available (it's so much easier...).
* client: shorten output format for Interarrival time (~analogous to
  ping output)

Note that this is a limited cleanup pass, trying not to change too much
at once and not to introduce breaking changes. The code (and the
functionality) can clearly still be improved...
@matzf matzf force-pushed the matzf/bwtester-cleanup branch from 8c4741f to 470cead Compare November 16, 2021 16:58
Copy link
Contributor Author

@matzf matzf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allow noop for one of the directions: typically client-to-server would be empty to test load specific border routers. At the moment the reporting will crash with a divide by zero.

Right, I had this fixed already on a different branch, forgot to put this here. Fixed now.
Note that this is a minimal fix only, there are still a number of lurking div-by-zero issues with when parsing the parameters. The easy case of providing only the bandwidth (e.g. -sc 0 -cs 10M) works fine though.

  • Infinite duration. At the moment we could write a big number of seconds for the duration parameter if we change the value of MaxDuration, so this is no big issue.

I agree, 10s is rather short. I guess it was chosen short that to ensure some "fairness" in case multiple clients want to connect and as a simple way to ensure that tests end even if clients crash. We could increase MaxDuration to 5 minutes or so?

  • Useful to identify packets in the captures is the ability of setting up certain pattern in the payload. This greatly simplified finding where the delays were being added.

Sure, this can be done. Currently, both sides expect the encrypted block number, so this would be a protocol change. That's fine, but I'd rather look at this separately later (trying to separate refactoring from protocol change).

  • Instant reporting. Configure reporting every N seconds.
  • Fine tune reporting: report delays over certain threshold. This is useful while debugging a BR.

This can done, probably also requires a protocol change (and a change of the output format, obviously).

Reviewable status: 1 of 4 files reviewed, all discussions resolved / 0 of 1 LGTMs obtained / 0 of 1 approvals obtained

@matzf matzf mentioned this pull request Nov 19, 2021
Copy link
Member

@juagargi juagargi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #211 covers the currently missing features for bwtester to supersede cbrtester
:lgtm:

Reviewed all commit messages.
Reviewable status: :shipit: complete! 1 of 1 LGTMs obtained

@matzf matzf merged commit b1af4ca into master Nov 23, 2021
@matzf matzf deleted the matzf/bwtester-cleanup branch November 23, 2021 09:35
matzf added a commit that referenced this pull request Jan 7, 2022
In #209, we introduced a reusable internal buffer for filling the
packets with PRG data. This buffer was not fully reset for each packet,
resulting in a different output and thus an incompatibility with the
older implementation. Only for the first packet, we would get the
"correct" result, all subsequent packets are rejected.

Fix by resetting buffer on each Fill call.

Looking at this code, I've noticed that the packet data is not actually
filled with PRG data. Only the first 16 bytes, plus a few bytes at the
end, are ever filled with the PRG output. We should just simplify this
anyway.
matzf added a commit that referenced this pull request Jan 7, 2022
In #209, we introduced a reusable internal buffer for filling the
packets with PRG data. This buffer was not fully reset for each packet,
resulting in a different output and thus an incompatibility with the
older implementation. Only for the first packet, we would get the
"correct" result, all subsequent packets are rejected.

Fix by resetting buffer on each Fill call.

Looking at this code, I've noticed that the packet data is not actually
filled with PRG data. Only the first 16 bytes, plus a few bytes at the
end, are ever filled with the PRG output. We should just simplify this
anyway.
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

Successfully merging this pull request may close these issues.

2 participants