pub fn run_report_csv(
    hostname: &str,
    target_addr: IpAddr,
    report_cycles: usize,
    resolver: &DnsResolver,
    trace_data: &Arc<RwLock<Trace>>,
) {
    let trace = wait_for_round(trace_data, report_cycles);
    println!("Target,TargetIp,Hop,Addrs,Loss%,Snt,Recv,Last,Avg,Best,Wrst,StdDev,");
    for hop in trace.hops().iter() {
        let ttl = hop.ttl();
        let hosts = hop.addrs().map(|ip| resolver.reverse_lookup(*ip)).join(":");
        let host = if hosts.is_empty() {
            String::from("???")
        } else {
            hosts
        };
        let sent = hop.total_sent();
        let recv = hop.total_recv();
        let last = hop
            .last_ms()
            .map_or_else(|| String::from("???"), |last| format!("{:.1}", last));
        let best = hop
            .best_ms()
            .map_or_else(|| String::from("???"), |best| format!("{:.1}", best));
        let worst = hop
            .worst_ms()
            .map_or_else(|| String::from("???"), |worst| format!("{:.1}", worst));
        let stddev = hop.stddev_ms();
        let avg = hop.avg_ms();
        let loss_pct = hop.loss_pct();
        println!(
            "{},{},{},{},{:.1}%,{},{},{},{:.1},{},{},{:.1}",
            hostname, target_addr, ttl, host, loss_pct, sent, recv, last, avg, best, worst, stddev
        );
    }
}
/// Generate a CSV report of trace data.
Generate a CSV report of trace data.
Generate a CSV report of trace data .
pub fn run_report_csv(
    hostname: &str,
    target_addr: IpAddr,
    report_cycles: usize,
    resolver: &DnsResolver,
    trace_data: &Arc<RwLock<Trace>>,
) {
    let trace = wait_for_round(trace_data, report_cycles);
    println!("Target,TargetIp,Hop,Addrs,Loss%,Snt,Recv,Last,Avg,Best,Wrst,StdDev,");
    for hop in trace.hops().iter() {
        let ttl = hop.ttl();
        let hosts = hop.addrs().map(|ip| resolver.reverse_lookup(*ip)).join(":");
        let host = if hosts.is_empty() {
            String::from("???")
        } else {
            hosts
        };
        let sent = hop.total_sent();
        let recv = hop.total_recv();
        let last = hop
            .last_ms()
            .map_or_else(|| String::from("???"), |last| format!("{:.1}", last));
        let best = hop
            .best_ms()
            .map_or_else(|| String::from("???"), |best| format!("{:.1}", best));
        let worst = hop
            .worst_ms()
            .map_or_else(|| String::from("???"), |worst| format!("{:.1}", worst));
        let stddev = hop.stddev_ms();
        let avg = hop.avg_ms();
        let loss_pct = hop.loss_pct();
        println!(
            "{},{},{},{},{:.1}%,{},{},{},{:.1},{},{},{:.1}",
            hostname, target_addr, ttl, host, loss_pct, sent, recv, last, avg, best, worst, stddev
        );
    }
}
pub fn run_report_csv ( hostname : & str , target_addr : IpAddr , report_cycles : usize , resolver : & DnsResolver , trace_data : & Arc < RwLock < Trace > > , ) { let trace = wait_for_round ( trace_data , report_cycles ) ; println ! ( " " ) ; for hop in trace . hops ( ) . iter ( ) { let ttl = hop . ttl ( ) ; let hosts = hop . addrs ( ) . map ( | ip | resolver . reverse_lookup ( * ip ) ) . join ( " " ) ; let host = if hosts . is_empty ( ) { String :: from ( " " ) } else { hosts } ; let sent = hop . total_sent ( ) ; let recv = hop . total_recv ( ) ; let last = hop . last_ms ( ) . map_or_else ( | | String :: from ( " " ) , | last | format ! ( " " last ) ) ; let best = hop . best_ms ( ) . map_or_else ( | | String :: from ( " " ) , | best | format ! ( " " best ) ) ; let worst = hop . worst_ms ( ) . map_or_else ( | | String :: from ( " " ) , | worst | format ! ( " " worst ) ) ; let stddev = hop . stddev_ms ( ) ; let avg = hop . avg_ms ( ) ; let loss_pct = hop . loss_pct ( ) ; println ! ( " " hostname target_addr ttl host loss_pct sent recv last avg best worst stddev ) ; } }
Generate a CSV report of trace data.
Generate a CSV report of trace data .
hostname
&str
target_addr
IpAddr
report_cycles
usize
resolver
&DnsResolver
trace_data
&Arc<RwLock<Trace>>