S 2.35 ke zhiheng-experiment 3 Note-tcp udp simulation -- calculate different CBR parameters: Jitter, throughput, packet loss rate awk code

Source: Internet
Author: User

Calculate the awk code of CBR jitter:

# Measure the end to end delay jitter by the trace file # calculation method: the jitter rate is obtained by dividing the delay time difference of adjacent data packets by the Number Difference of data packets; # jitter = (trecvj-tsndj) -(trecvi-tsndi)/(J-I), j> ibegin {# program initializehighest_packet_id = 0 ;}{ action = $1; time = $2; from = $3; To = $4; type = $5; pktsize = $6; flow_id = $8; src = $9; DST = $10; seq_no = $11; packet_id = $12; # record the current Max packet idif (packet_id> highest_packet_id) highest_pac Ket_id = packet_id; # record the Tx time of packetif (start_time [packet_id] = 0) {pkt_seqno [packet_id] = seq_no; start_time [packet_id] = time ;} # record CBR flow_id = 2 RX timeif (flow_id = 2 & Action! = "D") {If (Action = "R") {end_time [packet_id] = Time ;}} elseend_time [packet_id] =-1 ;} end {# When read over, start to calculatelast_seqno = 0; last_delay = 0; seqno_diff = 0; For (packet_id = 0; packet_id <= highest_packet_id; packet_id ++) {start = start_time [packet_id]; end = end_time [packet_id]; duration = start-end; If (start <End) {# calc jitterseqno_diff = pkt_seqno [packet_id]-last_seqno; delay_diff = duration-last_delay; If (seqno_diff = 0) jitter = 0; elsejitter = delay_diff/seqno_diff; printf ("% F \ n", start, jitter ); last_seqno = pkt_seqno [packet_id]; last_delay = duration ;}}}


Code for calculating the throughput:

# Measure the CBR average throughput by the trace file # throughput = byte CNT/Time Interval # Time Interval = cur_time-start_timebegin {# program initializeinit = 0; I = 0 ;} {Action = $1; time = $2; from = $3; To = $4; type = $5; pktsize = $6; flow_id = $8; src = $9; DST = $10; seq_no = $11; packet_id = $12; if (Action = "R" & from = 2 & to = 3 & flow_id = 2) {pkt_byte_sum [I + 1] = pkt_byte_sum [I] + pktsize; If (init = 0) {start_time = time; init = 1;} end_time [I] = time; I = I + 1 ;}}end {# when read over, start to calculateprintf ("%. 2f \ t %. 2f \ n ", end_time [0], 0); For (j = 1; j <I; j ++) {# average throughput from the beginning to the current, instead of the current instantaneous throughput # This calculation seems inaccurate. Th = pkt_byte_sum [J]/(end_time [J]-start_time) * 8/1000; printf ("%. 2f \ t %. 2f \ n ", end_time [J], th) ;}# the first and last values are set to 0 to make a good picture, the last 0 seems a bit inappropriate # printf ("%. 2f \ t %. 2f \ n ", end_time [0], 0 );}

Calculate packet loss rate:

# Measure the CBR packet loss rate by the trace fileBEGIN{# program initializefsDrops = 0;numFs = 0;}{action = $1;time = $2;from = $3;to = $4;type = $5;pktsize = $6;flow_id = $8;src = $9;dst = $10;seq_no = $11;packet_id = $12;# Record how many packets sent from n1if ( from==1 && to==2 && action=="+" )numFs++;# Record flow_id is 2 and droppedif ( flow_id==2 && action=="d" )fsDrops++;}END {# When read over, start to calculateprintf("number of pkts sent:%d, lost:%d, loss rate:%f\n", numFs,fsDrops,fsDrops/numFs);}

Number of Pkts Sent: 550, lost: 8, Loss Rate: 0.014545

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.