Skip to content

Commit f3f1a44

Browse files
add new frames and their tests
1 parent 350fd9f commit f3f1a44

File tree

4 files changed

+361
-25
lines changed

4 files changed

+361
-25
lines changed

quinn-proto/src/cid_queue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ mod tests {
139139

140140
fn cid(sequence: u64, retire_prior_to: u64) -> NewConnectionId {
141141
NewConnectionId {
142+
path_id: None,
142143
sequence,
143144
id: ConnectionId::new(&[0xAB; 8]),
144145
reset_token: ResetToken::from([0xCD; crate::RESET_TOKEN_SIZE]),

quinn-proto/src/connection/mod.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,7 @@ impl Connection {
13731373
space: SpaceId,
13741374
ack: frame::Ack,
13751375
) -> Result<(), TransportError> {
1376+
// TODO(@divma): check path id
13761377
if ack.largest >= self.spaces[space].next_packet_number {
13771378
return Err(TransportError::PROTOCOL_VIOLATION("unsent packet acked"));
13781379
}
@@ -2788,7 +2789,11 @@ impl Connection {
27882789
}
27892790
self.streams.received_stop_sending(id, error_code);
27902791
}
2791-
Frame::RetireConnectionId { sequence } => {
2792+
Frame::RetireConnectionId(frame::RetireConnectionId {
2793+
path_id: _,
2794+
sequence,
2795+
}) => {
2796+
// TODO(@divma): use path id
27922797
let allow_more_cids = self
27932798
.local_cid_state
27942799
.on_cid_retirement(sequence, self.peer_params.issue_cids_limit())?;
@@ -2942,6 +2947,18 @@ impl Connection {
29422947
migration_observed_addr = Some(observed)
29432948
}
29442949
}
2950+
Frame::PathAbandon(_) => {
2951+
// TODO(@divma): jump ship?
2952+
}
2953+
Frame::PathAvailable(_) => {
2954+
// TODO(@divma): do stuff
2955+
}
2956+
Frame::MaxPathId(_) => {
2957+
// TODO(@divma): do stuff
2958+
}
2959+
Frame::PathsBlocked(_) => {
2960+
// TODO(@divma): do stuff
2961+
}
29452962
}
29462963
}
29472964

@@ -3304,6 +3321,7 @@ impl Connection {
33043321
}
33053322

33063323
// NEW_CONNECTION_ID
3324+
// TODO(@divma): need to change this; add a decent size fn
33073325
while buf.len() + 44 < max_size {
33083326
let issued = match space.pending.new_cids.pop() {
33093327
Some(x) => x,
@@ -3315,6 +3333,7 @@ impl Connection {
33153333
"NEW_CONNECTION_ID"
33163334
);
33173335
frame::NewConnectionId {
3336+
path_id: None, // TODO(@divma): multipath!
33183337
sequence: issued.sequence,
33193338
retire_prior_to: self.local_cid_state.retire_prior_to(),
33203339
id: issued.id,
@@ -3326,15 +3345,19 @@ impl Connection {
33263345
}
33273346

33283347
// RETIRE_CONNECTION_ID
3348+
// TODO(@divma): buf size bounds are now wrong
33293349
while buf.len() + frame::RETIRE_CONNECTION_ID_SIZE_BOUND < max_size {
3330-
let seq = match space.pending.retire_cids.pop() {
3350+
let sequence = match space.pending.retire_cids.pop() {
33313351
Some(x) => x,
33323352
None => break,
33333353
};
3334-
trace!(sequence = seq, "RETIRE_CONNECTION_ID");
3335-
buf.write(frame::FrameType::RETIRE_CONNECTION_ID);
3336-
buf.write_var(seq);
3337-
sent.retransmits.get_or_create().retire_cids.push(seq);
3354+
trace!(sequence, "RETIRE_CONNECTION_ID");
3355+
frame::RetireConnectionId {
3356+
path_id: None, // TODO(@divma): multipath!
3357+
sequence,
3358+
}
3359+
.write(buf);
3360+
sent.retransmits.get_or_create().retire_cids.push(sequence);
33383361
self.stats.frame_tx.retire_connection_id += 1;
33393362
}
33403363

@@ -3401,7 +3424,8 @@ impl Connection {
34013424
delay_micros
34023425
);
34033426

3404-
frame::Ack::encode(delay as _, space.pending_acks.ranges(), ecn, buf);
3427+
// TODO(@divma): connect here when path management is ready
3428+
frame::Ack::encode(None, delay as _, space.pending_acks.ranges(), ecn, buf);
34053429
stats.frame_tx.acks += 1;
34063430
}
34073431

@@ -3441,6 +3465,7 @@ impl Connection {
34413465
trace!("negotiated max idle timeout {:?}", self.idle_timeout);
34423466
if let Some(ref info) = params.preferred_address {
34433467
self.rem_cids.insert(frame::NewConnectionId {
3468+
path_id: None, // TODO(@divma): use
34443469
sequence: 1,
34453470
id: info.connection_id,
34463471
reset_token: info.stateless_reset_token,

quinn-proto/src/connection/stats.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ pub struct FrameStats {
5454
pub stop_sending: u64,
5555
pub stream: u64,
5656
pub observed_addr: u64,
57+
pub path_abandon: u64,
58+
pub path_available: u64,
59+
pub max_path_id: u64,
60+
pub paths_blocked: u64,
5761
}
5862

5963
impl FrameStats {
6064
pub(crate) fn record(&mut self, frame: &Frame) {
6165
match frame {
6266
Frame::Padding => {}
6367
Frame::Ping => self.ping += 1,
68+
// TODO(@divma): path acks independently?
6469
Frame::Ack(_) => self.acks += 1,
6570
Frame::ResetStream(_) => self.reset_stream += 1,
6671
Frame::StopSending(_) => self.stop_sending += 1,
@@ -87,6 +92,7 @@ impl FrameStats {
8792
}
8893
}
8994
Frame::NewConnectionId(_) => self.new_connection_id += 1,
95+
// TODO(@divma): split stats?
9096
Frame::RetireConnectionId { .. } => self.retire_connection_id += 1,
9197
Frame::PathChallenge(_) => self.path_challenge += 1,
9298
Frame::PathResponse(_) => self.path_response += 1,
@@ -95,6 +101,11 @@ impl FrameStats {
95101
Frame::ImmediateAck => self.immediate_ack += 1,
96102
Frame::HandshakeDone => self.handshake_done = self.handshake_done.saturating_add(1),
97103
Frame::ObservedAddr(_) => self.observed_addr += 1,
104+
Frame::PathAbandon(_) => self.path_abandon = self.path_abandon.saturating_add(1),
105+
// TODO(@divma): split stats?
106+
Frame::PathAvailable(_) => self.path_available = self.path_available.saturating_add(1),
107+
Frame::MaxPathId(_) => self.max_path_id = self.max_path_id.saturating_add(1),
108+
Frame::PathsBlocked(_) => self.paths_blocked = self.paths_blocked.saturating_add(1),
98109
}
99110
}
100111
}

0 commit comments

Comments
 (0)