Skip to content

Commit 344f79c

Browse files
committed
style: fix typo
1 parent 15539d0 commit 344f79c

File tree

5 files changed

+50
-50
lines changed

5 files changed

+50
-50
lines changed

rattan-core/src/cells/bandwidth/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ where
142142
}
143143

144144
/// If and only if there is enough bandwidth to send a packet which is enqueued into a 0-sized
145-
/// queue and thus being returnd, this function returns `Some`. When this happens, the caller
145+
/// queue and thus being returned, this function returns `Some`. When this happens, the caller
146146
/// should send out the packet immediately.
147147
#[inline(always)]
148148
#[must_use]
@@ -179,7 +179,7 @@ where
179179
break;
180180
}
181181
// `new_packet` can be None only if `self.egress` is closed.
182-
// The new_packet's timestamp is ealier than self.next_available.
182+
// The new_packet's timestamp is earlier than self.next_available.
183183
new_packet = self.egress.recv() => {
184184
let new_packet = crate::check_cell_state!(self.state, new_packet?);
185185
if let Some(packet) = self.enqueue_packet(new_packet){
@@ -206,7 +206,7 @@ where
206206
}
207207
}
208208
// Here, either:
209-
// 1) No more packets can be retrived from egress, or
209+
// 1) No more packets can be retrieved from egress, or
210210
// 2) A packet, that should enter the queue after `self.next_available` is seen.
211211
// Thus the `dequeue_at()` sees a correct queue, containing any packet that should
212212
// enter the AQM at `self.next_available`.
@@ -519,7 +519,7 @@ where
519519
}
520520

521521
/// If and only if there is enough bandwidth to send a packet which is enqueued into a 0-sized
522-
/// queue and thus being returnd, this function returns `Some`. When this happens, the caller
522+
/// queue and thus being returned, this function returns `Some`. When this happens, the caller
523523
/// should send out the packet immediately.
524524
#[inline(always)]
525525
fn enqueue_packet(&mut self, new_packet: P) -> Option<P> {
@@ -600,7 +600,7 @@ where
600600
}
601601

602602
// Here, either:
603-
// 1) No more packets can be retrived from egress, or
603+
// 1) No more packets can be retrieved from egress, or
604604
// 2) A packet, that should enter the queue after `self.next_available` is seen.
605605
// Thus the `dequeue_at()` sees a correct queue, containing any packet that should
606606
// enter the AQM at `self.next_available`.
@@ -637,7 +637,7 @@ where
637637
.get_at_timestamp(timestamp)
638638
.map(|bw| transfer_time(packet.l3_length(), *bw, self.bw_type));
639639

640-
// release the packet immediately (aka infinity bandwidth) when no avaiable bandwidth has been set.
640+
// release the packet immediately (aka infinity bandwidth) when no available bandwidth has been set.
641641
let transfer_time = transfer_time.unwrap_or_default();
642642

643643
if timestamp >= self.next_available {

rattan-core/src/cells/bandwidth/queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ where
8282
}
8383

8484
/// Dequeue a packet from the AQM based on the timestamp.
85-
/// The function tries to maintain the queue status at the given timestamp before dequeing a packet,
85+
/// The function tries to maintain the queue status at the given timestamp before dequeuing a packet,
8686
/// by enqueuing any packets that should have been enqueued by that timestamp.
8787
///
8888
/// The caller ensures that:

rattan-core/src/cells/delay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ where
256256
if let Some((current_delay, duration)) = self.trace.next_delay() {
257257
#[cfg(test)]
258258
tracing::trace!(
259-
"Setting {:?} delay valid from {:?} utill {:?}",
259+
"Setting {:?} delay valid from {:?} until {:?}",
260260
current_delay,
261261
relative_time(timestamp),
262262
relative_time(timestamp + duration),
@@ -588,7 +588,7 @@ mod tests {
588588
std::thread::sleep(Duration::from_millis(15));
589589
config_changer.set_config(DelayCellConfig::new(Duration::from_millis(10)))?;
590590

591-
// The expected behaviour is that the packet exits the cell almost immediately.
591+
// The expected behavior is that the packet exits the cell almost immediately.
592592
let received = rt.block_on(async { egress.dequeue().await });
593593

594594
let duration = start.elapsed().as_micros() as f64 / 1000.0;

rattan-core/src/cells/token_bucket/mod.rs

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ where
105105
update_token_bucket(&mut self.token_bucket, burst_size, token_rate, timestamp);
106106
};
107107

108-
if let (Some(burst_size), Some(token_rate)) = (config.minburst, config.peakrate) {
108+
if let (Some(burst_size), Some(token_rate)) = (config.min_burst, config.peak_rate) {
109109
new_max_size = new_max_size.min(burst_size);
110110
update_token_bucket(
111111
&mut self.peak_token_bucket,
@@ -191,7 +191,7 @@ where
191191
.map(|t| t.reserve(current_size)),
192192
) {
193193
// None: The token bucket is not present.
194-
// Some(None): The token bucket is present, but there is not suffcient token.
194+
// Some(None): The token bucket is present, but there is not sufficient token.
195195
// Some(Some(token)): The token bucket is present, and there is token to be consumed.
196196
(Some(None), _) | (_, Some(None)) => {
197197
// We have packets waiting to be sent, yet at least one token bucket is not ready
@@ -221,7 +221,7 @@ where
221221
}
222222
head_packet.into()
223223
} else {
224-
// Send directly without enque
224+
// Send directly without enqueue
225225
new_packet
226226
}
227227
.expect("There should be a packet here");
@@ -318,7 +318,7 @@ where
318318
derive(Deserialize, Serialize)
319319
)]
320320
#[derive(Debug, Default)]
321-
/// rate and burst, peakrate and minburst must be provided together
321+
/// rate and burst, peak_rate and min_burst must be provided together
322322
pub struct TokenBucketCellConfig {
323323
/// limit of the queue in bytes, default: unlimited
324324
#[cfg_attr(feature = "serde", serde(default))]
@@ -330,11 +330,11 @@ pub struct TokenBucketCellConfig {
330330
/// burst of the bucket in bytes, default: unlimited
331331
pub burst: Option<ByteSize>,
332332
#[cfg_attr(feature = "serde", serde(with = "human_bandwidth::serde", default))]
333-
/// peakrate of the bucket in bps, default: unlimited
334-
pub peakrate: Option<Bandwidth>,
333+
/// peak_rate of the bucket in bps, default: unlimited
334+
pub peak_rate: Option<Bandwidth>,
335335
#[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::byte", default))]
336-
/// minburst of the bucket in bytes, default: unlimited
337-
pub minburst: Option<ByteSize>,
336+
/// min_burst of the bucket in bytes, default: unlimited
337+
pub min_burst: Option<ByteSize>,
338338
}
339339

340340
impl Clone for TokenBucketCellConfig {
@@ -343,8 +343,8 @@ impl Clone for TokenBucketCellConfig {
343343
limit: self.limit,
344344
rate: self.rate,
345345
burst: self.burst,
346-
peakrate: self.peakrate,
347-
minburst: self.minburst,
346+
peak_rate: self.peak_rate,
347+
min_burst: self.min_burst,
348348
}
349349
}
350350
}
@@ -360,15 +360,15 @@ impl TokenBucketCellConfig {
360360
limit: L,
361361
rate: R,
362362
burst: B,
363-
peakrate: PR,
364-
minburst: MT,
363+
peak_rate: PR,
364+
min_burst: MT,
365365
) -> Self {
366366
Self {
367367
limit: limit.into(),
368368
rate: rate.into(),
369369
burst: burst.into(),
370-
peakrate: peakrate.into(),
371-
minburst: minburst.into(),
370+
peak_rate: peak_rate.into(),
371+
min_burst: min_burst.into(),
372372
}
373373
}
374374
}
@@ -385,11 +385,11 @@ fn sanity_check(config: TokenBucketCellConfig) -> Result<TokenBucketCellConfig,
385385
"rate and burst should be provided together".to_string(),
386386
));
387387
}
388-
if (config.peakrate.is_none() && config.minburst.is_some())
389-
|| (config.peakrate.is_some() && config.minburst.is_none())
388+
if (config.peak_rate.is_none() && config.min_burst.is_some())
389+
|| (config.peak_rate.is_some() && config.min_burst.is_none())
390390
{
391391
return Err(Error::ConfigError(
392-
"peakrate and minburst should be provided together".to_string(),
392+
"peak_rate and min_burst should be provided together".to_string(),
393393
));
394394
}
395395
if let Some(rate) = config.rate {
@@ -406,17 +406,17 @@ fn sanity_check(config: TokenBucketCellConfig) -> Result<TokenBucketCellConfig,
406406
));
407407
}
408408
}
409-
if let Some(peakrate) = config.peakrate {
410-
if peakrate.as_bps() == 0 {
409+
if let Some(peak_rate) = config.peak_rate {
410+
if peak_rate.as_bps() == 0 {
411411
return Err(Error::ConfigError(
412-
"peakrate must be greater than 0".to_string(),
412+
"peak_rate must be greater than 0".to_string(),
413413
));
414414
}
415415
}
416-
if let Some(minburst) = config.minburst {
417-
if minburst.as_u64() == 0 {
416+
if let Some(min_burst) = config.min_burst {
417+
if min_burst.as_u64() == 0 {
418418
return Err(Error::ConfigError(
419-
"minburst must be greater than 0".to_string(),
419+
"min_burst must be greater than 0".to_string(),
420420
));
421421
}
422422
}
@@ -435,9 +435,9 @@ impl ControlInterface for TokenBucketCellControlInterface {
435435
}
436436
}
437437

438-
/// Packets whose size is larger than the smaller one of burst and minburst will be dropped before enqueueing.
438+
/// Packets whose size is larger than the smaller one of burst and min_burst will be dropped before enqueueing.
439439
/// If the configuration is modified, packets in the queue whose size is larger than the smaller one of
440-
/// the new burst and the new minburst will be dropped immediately.
440+
/// the new burst and the new min_burst will be dropped immediately.
441441
pub struct TokenBucketCell<P: Packet> {
442442
ingress: Arc<TokenBucketCellIngress<P>>,
443443
egress: TokenBucketCellEgress<P>,
@@ -483,8 +483,8 @@ where
483483
limit: L,
484484
rate: R,
485485
burst: B,
486-
peakrate: PR,
487-
minburst: MT,
486+
peak_rate: PR,
487+
min_burst: MT,
488488
) -> Result<TokenBucketCell<P>, Error> {
489489
debug!("New TokenBucketCell");
490490
let (rx, tx) = mpsc::unbounded_channel();
@@ -507,7 +507,7 @@ where
507507
};
508508

509509
egress.set_config(
510-
TokenBucketCellConfig::new(limit, rate, burst, peakrate, minburst),
510+
TokenBucketCellConfig::new(limit, rate, burst, peak_rate, min_burst),
511511
now,
512512
);
513513

@@ -540,7 +540,7 @@ mod tests {
540540
assert_eq!(expected.len(), logical.len());
541541
for (idx, expected_delay) in expected.iter().enumerate() {
542542
assert_eq!(expected_delay, &logical[idx]);
543-
// A larger torlerance is needed in paralleled testing
543+
// A larger tolerance is needed in paralleled testing
544544
assert!(
545545
expected_delay.saturating_sub(measured[idx]).as_secs_f64()
546546
<= DELAY_ACCURACY_TOLERANCE * 2E-3
@@ -568,8 +568,8 @@ mod tests {
568568
config.limit,
569569
config.rate,
570570
config.burst,
571-
config.peakrate,
572-
config.minburst,
571+
config.peak_rate,
572+
config.min_burst,
573573
)?;
574574
let ingress = cell.sender();
575575
let mut egress = cell.into_receiver();
@@ -654,8 +654,8 @@ mod tests {
654654
config.limit,
655655
config.rate,
656656
config.burst,
657-
config.peakrate,
658-
config.minburst,
657+
config.peak_rate,
658+
config.min_burst,
659659
)?;
660660
let controller_interface = cell.control_interface.clone();
661661
let ingress = cell.sender();
@@ -807,9 +807,9 @@ mod tests {
807807

808808
#[test_log::test]
809809
fn test_token_bucket_cell_prate_low() -> Result<(), Error> {
810-
// test peakrate when peakrate is lower than rate
810+
// test peak_rate when peak_rate is lower than rate
811811
let _span = span!(Level::INFO, "test_token_bucket_cell_prate_low").entered();
812-
info!("Creating cell with 1024 B burst, 8192 bps rate, 128 B minburst, 4096 bps peakrate and a 1024 bytes limit queue.");
812+
info!("Creating cell with 1024 B burst, 8192 bps rate, 128 B min_burst, 4096 bps peak_rate and a 1024 bytes limit queue.");
813813
let config = TokenBucketCellConfig::new(
814814
1024,
815815
Bandwidth::from_bps(8192),
@@ -822,7 +822,7 @@ mod tests {
822822
let (measured_delays, logical_delays) =
823823
get_delays(5, 128 + 14, config, Duration::from_millis(10))?;
824824

825-
// In this test, only minburst and peakrate is the bottleneck
825+
// In this test, only min_burst and peak_rate is the bottleneck
826826
//
827827
// Initially, the bucket contains tokens for 8 / 1 packets
828828
// Each packet consumed token that needs 31.25ms / 250ms to refill
@@ -844,9 +844,9 @@ mod tests {
844844

845845
#[test_log::test]
846846
fn test_token_bucket_cell_prate_high() -> Result<(), Error> {
847-
// test peakrate when peakrate is higher than rate
847+
// test peak_rate when peak_rate is higher than rate
848848
let _span = span!(Level::INFO, "test_token_bucket_cell_prate_high").entered();
849-
info!("Creating cell with 512 B burst, 4096 bps rate, 256 B minburst, 8192 bps peakrate and a 1024 bytes limit queue.");
849+
info!("Creating cell with 512 B burst, 4096 bps rate, 256 B min_burst, 8192 bps peak_rate and a 1024 bytes limit queue.");
850850
let config = TokenBucketCellConfig::new(
851851
1024,
852852
Bandwidth::from_bps(4096),
@@ -857,7 +857,7 @@ mod tests {
857857

858858
let (measured_delays, logical_delays) =
859859
get_delays(5, 128 + 14, config, Duration::from_millis(10))?;
860-
// In this test, rate and minburst is the bottleneck
860+
// In this test, rate and min_burst is the bottleneck
861861
//
862862
// Initially, the bucket contains tokens for 4 / 2 packets
863863
// Each packet consumed token that needs 125ms / 62.5ms to refill

rattan-core/src/config/token_bucket.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ impl TokenBucketCellBuildConfig {
1313
self.limit,
1414
self.rate,
1515
self.burst,
16-
self.peakrate,
17-
self.minburst,
16+
self.peak_rate,
17+
self.min_burst,
1818
)
1919
}
2020
}

0 commit comments

Comments
 (0)