-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
23 lines (19 loc) · 877 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use anyhow::bail;
use std::time::Duration;
use stp_rs::stp::eth::EthSwitch;
/// How often switches broadcast their routing state to neighbors
const BPDU_RESEND_FREQ: Duration = Duration::from_secs(2);
/// How long a switch is allowed to wait for an ethernet packet to
/// arrive on a specific port. Relevant ports are polled in an
/// event loop.
const SWITCH_TICK_SPEED: Option<Duration> = Some(Duration::from_micros(1000));
/// How long switches stay in their initial learning mode before
/// beginning to forward host packets.
const STARTUP_DURATION: Duration = Duration::from_millis(1000);
fn main() -> anyhow::Result<()> {
let Some(switch_name) = std::env::args().nth(1) else {
bail!("First argument must be the switch name");
};
let switch = EthSwitch::build(&switch_name, BPDU_RESEND_FREQ, SWITCH_TICK_SPEED)?;
switch.run(STARTUP_DURATION)
}