Hello,

there are several possibilities. First you can analyse the trace files
by filtering the interesting event. An example for awk you can find in the attachment.

Second you my use an statistic toolset like ns2measure. (see google)

Best regards,
   Volker

neha goel schrieb:
Hi all,
           Can i please know how to find throughput if i am sending udp
packets from one node to another.
 Thanks..


#!/usr/bin/awk -f


BEGIN {
        start_time = 26
        stop_time = 99
        
        # Uplink
        src_ip_port_ul = "4194305.0"
        dest_ip_port_ul = "4194304.0"
        packettype_ul = "cbr"

        # Downlink
        src_ip_port_dl = "4194304.1" ;#"0.0.0.1"
        dest_ip_port_dl =  "4194305.1" ;#"1.0.1.1"
        packettype_dl = "cbr"

        #init var
        # Uplink
        packetcounter_ul = 0
        recv_bytes_ul = 0
        # Downlink
        packetcounter_dl = 0
        recv_bytes_dl = 0
}

{

        # Uplink 
        # r -t 25.017077960 -Hs 0 -Hd 4194304 -Ni 0 -Nx 500.00 -Ny 500.00 -Nz 
0.00 -Ne -1.000000 -Nl AGT -Nw --- -Ma 0 -Md 1000000 -Ms 8 -Mt 0 
        # -Is 4194305.0 -Id 4194304.0 - It cbr -Il 1520 -If 0 -Ii 7 -Iv 32 -Pn 
cbr -Pi 0 -Pf 0 -Po 0 
        # Take only packets into account within transmission period
        if (($3 <= stop_time) && ($3 >= start_time) ){  

                # Count packets and bytes for UPLINK
                if ( ($1 == "r")  && ($19 == "AGT") && ($31 == src_ip_port_ul) 
&& ($33 == dest_ip_port_ul) && ($35 == packettype_dl)){
                        # Packetcounter                         
                        packetcounter_ul++
                        # Datacounter                           
                        recv_bytes_ul=recv_bytes_ul + $37 -20
                }
        }
                
        # Downlink
        # r -t 25.504000981 -Hs 1 -Hd 4194305 -Ni 1 -Nx 700.00 -Ny 500.00 -Nz 
0.00 -Ne -1.000000 -Nl AGT -Nw --- -Ma 0 -Md 0 -Ms 8 -Mt 0 
        # -Is 4194304.1 -Id 4194305.1 -It cbr -Il 1520 -If 0 -Ii 8 -Iv 32 -Pn 
cbr -Pi 0 -Pf 0 -Po 0 
        if (($3 <= stop_time) && ( $3 >= start_time) ){

                # Count packets and bytes for DOWNLINK
                if ( ($1 == "r") && ($19 == "AGT") && ($31 == src_ip_port_dl) 
&& ($33 == dest_ip_port_dl) && ($35 == packettype_dl) ){
                        # Packetcounter                         
                        packetcounter_dl++
                        # Datacounter                           
                        recv_bytes_dl=recv_bytes_dl + $37 -20
                }
        }

}

END {
        # Calculation of throughput
        # Uplink
        if (recv_bytes_ul==0){
                bandwidth_ul = 0
        } else {
                bandwidth_ul = 10^-6*8*recv_bytes_ul/(stop_time-start_time)
        }

        # Downlink
        if (recv_bytes_dl==0){
                bandwidth_dl = 0
        } else {
                bandwidth_dl = 10^-6*8*recv_bytes_dl/(stop_time-start_time)
        }


        # Output of the results
        printf("Start:               %20d\n",start_time)
        printf("Stop:                %20d\n\n",stop_time) 

        printf("Uplink \n\n")
        printf("Statistic for %s-flow from %s to 
%s:\n\n",packettype_ul,src_ip_port_ul,dest_ip_port_ul)
        printf("Received packets:   %20d [%15d 
Bytes]\n",packetcounter_ul,recv_bytes_ul)
        printf("Bandwidth:                                         %6.3f 
Mbit/s\n",bandwidth_ul)
        printf("\n\n")


        printf("Downlink \n\n")
        printf("Statistic for %s-flow from %s to 
%s:\n\n",packettype_dl,src_ip_port_dl,dest_ip_port_dl)
        printf("Received packets:   %20d [%15d 
Bytes]\n",packetcounter_dl,recv_bytes_dl)
        printf("Bandwidth:                                        %6.3f 
Mbit/s\n",bandwidth_dl)
        printf("\n\n")


        printf("Results %6.6f %6.6f \n", bandwidth_ul, bandwidth_dl);

}

Reply via email to