You are on page 1of 4

Here they are...

>
> ===================== throughput.awk ===============================
>
> BEGIN {
> recv = 0
> }
>
> {
> # Trace line format: normal
> if ($2 != "-t") {
> event = $1
> time = $2
> if (event == "+" || event == "-") node_id = $3
> if (event == "r" || event == "d") node_id = $4
> flow_id = $8
> pkt_id = $12
> pkt_size = $6
> }
> # Trace line format: new
> if ($2 == "-t") {
> event = $1
> time = $3
> node_id = $5
> flow_id = $39
> pkt_id = $41
> pkt_size = $37
> }
>
> # Calculate total received packets' size
> if (flow_id == flow && event == "r" && node_id == dst) {
> if (flow_t != "sctp") {
> recv += pkt_size - hdr_size
> #printf("recv[%g] = %g --> tot:
> %g\n",node_id,pkt_size-hdr_size,recv)
> } else {
> # Rip off SCTP header, whose size depends
> # on the number of chunks in each packet
> if (pkt_size == 40) pkt_size = 0
> if (pkt_size == 448) pkt_size = 400
> if (pkt_size == 864) pkt_size = 800
> if (pkt_size == 1280) pkt_size = 1200
> recv += pkt_size
> #printf("recv[%g] = %g --> tot:
> %g\n",node_id,pkt_size,recv)
> }
> }
> }
>
> END {
> printf("%10g %10s %10g\n",flow,flow_t,(recv/simtime)*(8/1000))
> }
>
> ====================== delay.awk ======================================

BEGIN {
> for (i in send) {
> send[i] = 0
> }
> for (i in recv) {
> recv[i] = 0
> }
> delay = avg_delay = 0
> }
>
> {
> # Trace line format: normal
> if ($2 != "-t") {
> event = $1
> time = $2
> if (event == "+" || event == "-") node_id = $3
> if (event == "r" || event == "d") node_id = $4
> flow_id = $8
> pkt_id = $12
> }
> # Trace line format: new
> if ($2 == "-t") {
> event = $1
> time = $3
> node_id = $5
> flow_id = $39
> pkt_id = $41
> }
>
> # Store packets send time
> if (flow_id == flow && node_id == src && send[pkt_id] == 0 &&
> (event == "+" || event == "s")) {
> send[pkt_id] = time
> #printf("send[%g] = %g\n",pkt_id,time)
> }
> # Store packets arrival time
> if (flow_id == flow && node_id == dst && event == "r") {
> recv[pkt_id] = time
> #printf("\t\trecv[%g] = %g --> delay[%g] =
> %g\n",pkt_id,time,pkt_id,recv[pkt_id]-send[pkt_id])
> }
> }
>
> END {
> # Compute average delay
> for (i in recv) {
> if (send[i] == 0) {
> printf("\nError %g\n",i)
> }
> delay += recv[i] - send[i]
> num ++
> }
>
> printf("%10g ",flow)
> if (num != 0) {
> avg_delay = delay / num
> } else {
> avg_delay = 0
> }
> printf("%10g\n",avg_delay*1000)
> }
>
> ========================= pkt_loss.awk ===========================
>
> BEGIN {
> for (i in send) {
> send[i] = 0
> }
> for (i in recv) {
> recv[i] = 0
> }
> tx = 0
> drop = 0
> pkt_loss = 0
> }
>
> {
> # Trace line format: normal
> if ($2 != "-t") {
> event = $1
> time = $2
> if (event == "+" || event == "-") node_id = $3
> if (event == "r" || event == "d") node_id = $4
> flow_id = $8
> pkt_id = $12
> }
> # Trace line format: new
> if ($2 == "-t") {
> event = $1
> time = $3
> node_id = $5
> flow_id = $39
> pkt_id = $41
> }
>
> # Store packets send time
> if (flow_id == flow && node_id == src && send[pkt_id] == 0 &&
> (event == "+" || event == "s")) {
> send[pkt_id] = 1
> #printf("send[%g] = 1\n",pkt_id)
> }
> # Store packets arrival time
> if (flow_id == flow && node_id == dst && event == "r") {
> recv[pkt_id] = 1
> #printf("\t\trecv[%g] = 1\n",pkt_id)
> }
> }
>
> END {
> printf("%10g ",flow)
> for (i in send) {
> if (send[i] == 1) {
> tx ++
> if (recv[i] == 0) {
> drop ++
> #printf("pkt %g not recvd\n",i)
> }
> }
> }
> if (tx != 0) {
> pkt_loss = drop / tx
> } else {
> pkt_loss = 0
> }
> printf("%10g %10g %10g\n",tx,drop,pkt_loss*100)
> }

You might also like