Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BEGIN {
- recv_bytes = 0;
- start_time = 999999;
- stop_time = 0;
- total_delay = 0;
- send_pkt = 0;
- recv_pkt = 0;
- drop_pkt = 0;
- }
- {
- event = $1;
- time = $2;
- trace_type = $4;
- pkt_id = $6;
- pkt_type = $7; # Column 7 is the packet type (e.g., cbr, tcp, AODV)
- pkt_size = $8;
- # 1. Track exactly how many packets are SENT from the Application layer
- if (event == "s" && trace_type == "AGT") {
- send_pkt++;
- send_time[pkt_id] = time;
- }
- # 2. Track exactly how many packets are RECEIVED at the Application layer
- if (event == "r" && trace_type == "AGT") {
- recv_bytes += pkt_size;
- recv_pkt++;
- if (pkt_id in send_time) {
- delay = time - send_time[pkt_id];
- total_delay += delay;
- }
- if (time < start_time) {
- start_time = time;
- }
- if (time > stop_time) {
- stop_time = time;
- }
- }
- # 3. Track packets DROPPED anywhere in the network (MAC, Router, or Queue layer)
- # We only count data packets (tcp or cbr), ignoring dropped routing packets
- if (event == "D" && (pkt_type == "cbr" || pkt_type == "tcp")) {
- drop_pkt++;
- }
- }
- END {
- duration = stop_time - start_time;
- # Calculate Packet Delivery Ratio (PDR) as a percentage
- if (send_pkt > 0) {
- pdr = (recv_pkt / send_pkt) * 100;
- } else {
- pdr = 0;
- }
- if (recv_pkt > 0) {
- throughput = (recv_bytes * 8) / duration / 1000;
- avg_delay = (total_delay / recv_pkt) * 1000;
- printf "========================================\n";
- printf " SIMULATION SCOREBOARD \n";
- printf "========================================\n";
- printf "Total Packets Sent : %d\n", send_pkt;
- printf "Total Packets Recv : %d\n", recv_pkt;
- printf "Total Packets Drop : %d\n", drop_pkt;
- printf "Packet Delivery Ratio: %.2f %%\n", pdr;
- printf "----------------------------------------\n";
- printf "Total Data Received : %d bytes\n", recv_bytes;
- printf "Simulation Duration : %.2f seconds\n", duration;
- printf "Overall Throughput : %.2f kbps\n", throughput;
- printf "Average E2E Delay : %.2f ms\n", avg_delay;
- printf "========================================\n";
- } else {
- print "No data packets were received at the AGT layer.";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment