Receiving Reply Packets and Calculating Statistics

The receive_probe_packets() event is invoked through the timer.

It calls the FreeBSD recvfrom() function to read the packet from the target, retrieves the data from the packet according to the protocol, and then calls the process_probe_packets() function.

Calculating Packet Statistics

The process_probe_packets() function handles the packet statistics. Statistics are kept in the packet_stats structure defined in the header file, ipprobe.h:

typedef struct packet_stats_s {
    float sd_delay;     /** Source-to-destination delay */
    float ds_delay;     /** Destination-to-source delay */
    float rrt;          /** Round-trip-time */
    float sd_jitter;    /** Source-to-destination jitter */
    float ds_jitter;    /** Destination-to-source jitter */
    float rr_jitter;    /** Round-trip jitter */
} packet_stats_t;

The data_buf variable points to the packet data structure, which is defined as follows in the ipprobe-manager.h file:

typedef struct {
    u_short id;                     /** Probe ID */
    u_short type;                   /** Packet type */
    u_short seq;                    /** Packet sequence number */
    struct timeval tx_time;         /** Initiator transmit time */
    struct timeval target_rx_time;  /** Target receive time */
    struct timeval target_tx_time;  /** Target transmit time */
    struct timeval rx_time;         /** Initiator receive time */
    char pad[0];                    /** Pad section */
} probe_packet_data_t;

The code calculates the time differences and populates the struct:

for (i = 0; i < rx_count; i++) {
        if (probe_params.protocol != IPPROTO_ICMP) {
            packet_stats[i].sd_delay = time_diff(&data_buf[i].tx_time,

            packet_stats[i].ds_delay = time_diff(&data_buf[i].target_tx_time,
        packet_stats[i].rrt = time_diff(&data_buf[i].tx_time,

        if (i == (probe_params.packet_count - 1)) {
        if (probe_params.protocol != IPPROTO_ICMP) {
            packet_stats[i].sd_jitter = time_diff(&data_buf[i].target_rx_time,
                    &data_buf[i + 1].target_rx_time) -
                    &data_buf[i + 1].tx_time);

            packet_stats[i].ds_jitter = time_diff(&data_buf[i].rx_time,
                    &data_buf[i + 1].rx_time) -
                    &data_buf[i + 1].target_tx_time);
        packet_stats[i].rr_jitter = time_diff(&data_buf[i].rx_time,
                &data_buf[i + 1].rx_time) -
                &data_buf[i + 1].tx_time);

2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:26:47 2010 for Juniper Networks Partner Solution Development Platform JUNOS SDK 10.2R1 by Doxygen 1.4.5