pub fn run_report_json(
    hostname: &str,
    target_addr: IpAddr,
    report_cycles: usize,
    resolver: &DnsResolver,
    trace_data: &Arc<RwLock<Trace>>,
) {
    let trace = wait_for_round(trace_data, report_cycles);
    let hops: Vec<ReportHop> = trace
        .hops()
        .iter()
        .map(|hop| {
            let hosts: Vec<_> = hop
                .addrs()
                .map(|ip| Host {
                    ip: ip.to_string(),
                    hostname: resolver.reverse_lookup(*ip).to_string(),
                })
                .collect();
            ReportHop {
                ttl: hop.ttl(),
                hosts,
                loss_pct: hop.loss_pct(),
                sent: hop.total_sent(),
                last: hop.last_ms().unwrap_or_default(),
                recv: hop.total_recv(),
                avg: hop.avg_ms(),
                best: hop.best_ms().unwrap_or_default(),
                worst: hop.worst_ms().unwrap_or_default(),
                stddev: hop.stddev_ms(),
            }
        })
        .collect();

    let report = Report {
        info: ReportInfo {
            target: Host {
                ip: target_addr.to_string(),
                hostname: hostname.to_string(),
            },
        },
        hops,
    };
    println!("{}", serde_json::to_string_pretty(&report).unwrap());
}
/// 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_json(
    hostname: &str,
    target_addr: IpAddr,
    report_cycles: usize,
    resolver: &DnsResolver,
    trace_data: &Arc<RwLock<Trace>>,
) {
    let trace = wait_for_round(trace_data, report_cycles);
    let hops: Vec<ReportHop> = trace
        .hops()
        .iter()
        .map(|hop| {
            let hosts: Vec<_> = hop
                .addrs()
                .map(|ip| Host {
                    ip: ip.to_string(),
                    hostname: resolver.reverse_lookup(*ip).to_string(),
                })
                .collect();
            ReportHop {
                ttl: hop.ttl(),
                hosts,
                loss_pct: hop.loss_pct(),
                sent: hop.total_sent(),
                last: hop.last_ms().unwrap_or_default(),
                recv: hop.total_recv(),
                avg: hop.avg_ms(),
                best: hop.best_ms().unwrap_or_default(),
                worst: hop.worst_ms().unwrap_or_default(),
                stddev: hop.stddev_ms(),
            }
        })
        .collect();
    let report = Report {
        info: ReportInfo {
            target: Host {
                ip: target_addr.to_string(),
                hostname: hostname.to_string(),
            },
        },
        hops,
    };
    println!("{}", serde_json::to_string_pretty(&report).unwrap());
}
pub fn run_report_json ( hostname : & str , target_addr : IpAddr , report_cycles : usize , resolver : & DnsResolver , trace_data : & Arc < RwLock < Trace > > , ) { let trace = wait_for_round ( trace_data , report_cycles ) ; let hops : Vec < ReportHop > = trace . hops ( ) . iter ( ) . map ( | hop | { let hosts : Vec < _ > = hop . addrs ( ) . map ( | ip | Host { ip : ip . to_string ( ) , hostname : resolver . reverse_lookup ( * ip ) . to_string ( ) , } ) . collect ( ) ; ReportHop { ttl : hop . ttl ( ) , hosts , loss_pct : hop . loss_pct ( ) , sent : hop . total_sent ( ) , last : hop . last_ms ( ) . unwrap_or_default ( ) , recv : hop . total_recv ( ) , avg : hop . avg_ms ( ) , best : hop . best_ms ( ) . unwrap_or_default ( ) , worst : hop . worst_ms ( ) . unwrap_or_default ( ) , stddev : hop . stddev_ms ( ) , } } ) . collect ( ) ; let report = Report { info : ReportInfo { target : Host { ip : target_addr . to_string ( ) , hostname : hostname . to_string ( ) , } , } , hops , } ; println ! ( " " serde_json to_string_pretty ( report ) unwrap ( ) ) ; }
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>>