pub fn run_report_stream(
    hostname: &str,
    target_addr: IpAddr,
    interval: Duration,
    trace_data: &Arc<RwLock<Trace>>,
) {
    println!("Tracing to {} ({})", hostname, target_addr);
    loop {
        let trace_data = trace_data.read().clone();
        for hop in trace_data.hops() {
            let ttl = hop.ttl();
            let addrs = hop.addrs().collect::<Vec<_>>();
            let sent = hop.total_sent();
            let recv = hop.total_recv();
            let last = hop
                .last_ms()
                .map(|last| format!("{:.1}", last))
                .unwrap_or_default();
            let best = hop
                .best_ms()
                .map(|best| format!("{:.1}", best))
                .unwrap_or_default();
            let worst = hop
                .worst_ms()
                .map(|worst| format!("{:.1}", worst))
                .unwrap_or_default();
            let stddev = hop.stddev_ms();
            let avg = hop.avg_ms();
            let loss_pct = hop.loss_pct();
            println!(
                "ttl={} addrs={:?} loss_pct={:.1}, sent={} recv={} last={} best={} worst={} avg={:.1} stddev={:.1}",
                ttl, addrs, loss_pct, sent, recv, last, best, worst, avg, stddev
            );
        }
        sleep(interval);
    }
}
/// Display a continuous stream of trace data.
Display a continuous stream of trace data.
Display a continuous stream of trace data .
pub fn run_report_stream(
    hostname: &str,
    target_addr: IpAddr,
    interval: Duration,
    trace_data: &Arc<RwLock<Trace>>,
) {
    println!("Tracing to {} ({})", hostname, target_addr);
    loop {
        let trace_data = trace_data.read().clone();
        for hop in trace_data.hops() {
            let ttl = hop.ttl();
            let addrs = hop.addrs().collect::<Vec<_>>();
            let sent = hop.total_sent();
            let recv = hop.total_recv();
            let last = hop
                .last_ms()
                .map(|last| format!("{:.1}", last))
                .unwrap_or_default();
            let best = hop
                .best_ms()
                .map(|best| format!("{:.1}", best))
                .unwrap_or_default();
            let worst = hop
                .worst_ms()
                .map(|worst| format!("{:.1}", worst))
                .unwrap_or_default();
            let stddev = hop.stddev_ms();
            let avg = hop.avg_ms();
            let loss_pct = hop.loss_pct();
            println!(
                "ttl={} addrs={:?} loss_pct={:.1}, sent={} recv={} last={} best={} worst={} avg={:.1} stddev={:.1}",
                ttl, addrs, loss_pct, sent, recv, last, best, worst, avg, stddev
            );
        }
        sleep(interval);
    }
}
pub fn run_report_stream ( hostname : & str , target_addr : IpAddr , interval : Duration , trace_data : & Arc < RwLock < Trace > > , ) { println ! ( " " hostname target_addr ) ; loop { let trace_data = trace_data . read ( ) . clone ( ) ; for hop in trace_data . hops ( ) { let ttl = hop . ttl ( ) ; let addrs = hop . addrs ( ) . collect :: < Vec < _ > > ( ) ; let sent = hop . total_sent ( ) ; let recv = hop . total_recv ( ) ; let last = hop . last_ms ( ) . map ( | last | format ! ( " " last ) ) . unwrap_or_default ( ) ; let best = hop . best_ms ( ) . map ( | best | format ! ( " " best ) ) . unwrap_or_default ( ) ; let worst = hop . worst_ms ( ) . map ( | worst | format ! ( " " worst ) ) . unwrap_or_default ( ) ; let stddev = hop . stddev_ms ( ) ; let avg = hop . avg_ms ( ) ; let loss_pct = hop . loss_pct ( ) ; println ! ( " " ttl addrs loss_pct sent recv last best worst avg stddev ) ; } sleep ( interval ) ; } }
Display a continuous stream of trace data.
Display a continuous stream of trace data .
hostname
&str
target_addr
IpAddr
interval
Duration
trace_data
&Arc<RwLock<Trace>>