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

add packet_len field to Packet Sent event #1605

Merged
merged 5 commits into from
Jan 24, 2023

Conversation

jmayclin
Copy link
Contributor

Resolved issues:

#1444

Description of changes:

This PR adds a packet_len field to the PacketSent event. It also adds a unit test to check that the packet_len is correct.

Call-outs:

I don't particularly love the location of the unit test right now, but because it relies on the network simulator and the setup methods, it feels easiest to fit it in the s2n-quic crate.

Testing:

  1. run the client_server interaction on the network simulator
  2. capture all network packets transmitted
  3. record all PacketSent events from the server
  4. ensure that packet sent events have the correct lengths, given that we know the size of the network packets

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

EC2 Default User and others added 2 commits January 12, 2023 04:51
This commit adds a packet recorder which lets us check compare the
recorded packet sent events against the packets sent on the network. We
need to do a little extra bookkeeping to compare the network packets
against the quic packets, but looks to work out fine in the end.
quic/s2n-quic-platform/src/io/testing/model.rs Outdated Show resolved Hide resolved
quic/s2n-quic-platform/src/io/testing/network.rs Outdated Show resolved Hide resolved
quic/s2n-quic/src/tests.rs Outdated Show resolved Hide resolved
_info: &ConnectionInfo,
) -> Self::ConnectionContext {
PacketSentContext {
packet_sent: Arc::clone(&self.packet_sent),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
packet_sent: Arc::clone(&self.packet_sent),
packet_sent: self.packet_sent,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler doesn't like that one.

cannot move out of self.packet_sent which is behind a mutable reference
move occurs because self.packet_sent has type Arc<...Mutex<Vec<...PacketSent>>>, which does not implement the Copy trait.

Copy link
Contributor Author

@jmayclin jmayclin Jan 23, 2023

Choose a reason for hiding this comment

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

Is the thought that clone is unnecessary and we should prefer to move, since the packet_sent member of PacketSentSubscriber doesn't get used again?

Some/None would be an option for that, but feels a bit heavy-handed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm dumb; I meant to add a .clone() to the end. Yes the event types are all non-copy in case we want to add non-copyable fields in the future

quic/s2n-quic/src/tests.rs Outdated Show resolved Hide resolved
quic/s2n-quic/src/tests.rs Outdated Show resolved Hide resolved
- run & fix clippy on latest stable toolchain
- run rustfmt on nightly toolchain
- prettier equality checking that Cameron suggested
- remove ugly clone since address implements it
- call clone on variable, rather than Arc::clone(...)
@jmayclin jmayclin merged commit df04fa4 into aws:main Jan 24, 2023
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