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 queues to BwDevice #12

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[workspace]
members = ['rattan', 'rattan-cli']
resolver = "2"
10 changes: 5 additions & 5 deletions rattan-cli/src/docker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rand::{rngs::StdRng, SeedableRng};
use rattan::{
core::{RattanMachine, RattanMachineConfig},
devices::{
bandwidth::{BwDevice, BwDeviceConfig},
bandwidth::{queue::InfiniteQueue, BwDevice, BwDeviceConfig, MAX_BANDWIDTH},
external::VirtualEthernet,
},
env::get_container_env,
Expand Down Expand Up @@ -169,15 +169,15 @@ pub fn docker_main(opts: CommandArgs) -> anyhow::Result<()> {
let mut left_fd = vec![left_device_rx];
let mut right_fd = vec![right_device_rx];
if let Some(bandwidth) = bandwidth {
let left_bw_device = BwDevice::<StdPacket>::new();
let right_bw_device = BwDevice::<StdPacket>::new();
let left_bw_device = BwDevice::new(MAX_BANDWIDTH, InfiniteQueue::new());
let right_bw_device = BwDevice::new(MAX_BANDWIDTH, InfiniteQueue::new());
let left_bw_ctl = left_bw_device.control_interface();
let right_bw_ctl = right_bw_device.control_interface();
left_bw_ctl
.set_config(BwDeviceConfig::new(bandwidth))
.set_config(BwDeviceConfig::new(bandwidth, None))
.unwrap();
right_bw_ctl
.set_config(BwDeviceConfig::new(bandwidth))
.set_config(BwDeviceConfig::new(bandwidth, None))
.unwrap();
let (left_bw_rx, left_bw_tx) = machine.add_device(left_bw_device);
info!(left_bw_rx, left_bw_tx);
Expand Down
13 changes: 7 additions & 6 deletions rattan-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use clap::Parser;
use rand::rngs::StdRng;
use rand::SeedableRng;
use rattan::core::{RattanMachine, RattanMachineConfig};
use rattan::devices::bandwidth::{BwDevice, BwDeviceConfig};
use rattan::devices::bandwidth::{queue::InfiniteQueue, BwDevice, BwDeviceConfig, MAX_BANDWIDTH};
use rattan::devices::delay::{DelayDevice, DelayDeviceConfig};
use rattan::devices::external::VirtualEthernet;
use rattan::devices::loss::{IIDLossDevice, IIDLossDeviceConfig};
Expand Down Expand Up @@ -93,15 +93,15 @@ fn main() {
let mut left_fd = vec![left_device_rx];
let mut right_fd = vec![right_device_rx];
if let Some(bandwidth) = bandwidth {
let left_bw_device = BwDevice::<StdPacket>::new();
let right_bw_device = BwDevice::<StdPacket>::new();
let left_bw_device = BwDevice::new(MAX_BANDWIDTH, InfiniteQueue::new());
let right_bw_device = BwDevice::new(MAX_BANDWIDTH, InfiniteQueue::new());
let left_bw_ctl = left_bw_device.control_interface();
let right_bw_ctl = right_bw_device.control_interface();
left_bw_ctl
.set_config(BwDeviceConfig::new(bandwidth))
.set_config(BwDeviceConfig::new(bandwidth, None))
.unwrap();
right_bw_ctl
.set_config(BwDeviceConfig::new(bandwidth))
.set_config(BwDeviceConfig::new(bandwidth, None))
.unwrap();
let (left_bw_rx, left_bw_tx) = machine.add_device(left_bw_device);
info!(left_bw_rx, left_bw_tx);
Expand Down Expand Up @@ -187,7 +187,8 @@ fn main() {
let output = handle.wait_with_output().unwrap();
let stdout = String::from_utf8(output.stdout).unwrap();
stdout.contains("time=")
}; match res {
};
match res {
true => {
info!("ping test passed");
left_ns.enter().unwrap();
Expand Down
10 changes: 7 additions & 3 deletions rattan/benches/bandwidth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ use std::{sync::Arc, thread::JoinHandle};
use criterion::{criterion_group, criterion_main, Criterion};
use rattan::{
core::{RattanMachine, RattanMachineConfig},
devices::{bandwidth::BwDevice, external::VirtualEthernet, StdPacket},
devices::{
bandwidth::{queue::InfiniteQueue, BwDevice, MAX_BANDWIDTH},
external::VirtualEthernet,
StdPacket,
},
env::{get_std_env, StdNetEnvConfig},
metal::{io::AfPacketDriver, netns::NetNs},
};
Expand All @@ -26,8 +30,8 @@ fn prepare_env() -> (JoinHandle<()>, CancellationToken, Arc<NetNs>, Arc<NetNs>)
.unwrap();

runtime.block_on(async move {
let left_bw_device = BwDevice::<StdPacket>::new();
let right_bw_device = BwDevice::<StdPacket>::new();
let left_bw_device = BwDevice::new(MAX_BANDWIDTH, InfiniteQueue::new());
let right_bw_device = BwDevice::new(MAX_BANDWIDTH, InfiniteQueue::new());
let left_device =
VirtualEthernet::<StdPacket, AfPacketDriver>::new(_std_env.left_pair.right.clone());
let right_device =
Expand Down
205 changes: 0 additions & 205 deletions rattan/src/devices/bandwidth.rs

This file was deleted.

Loading
Loading