Go Back N协议计算指南
一、性能参数说明
基于Go Back N协议仿真测试程序,可以通过分析下面的11个参数,从而评估协议性能。
我们以下面的日志记录进行说明:
- 输入参数
---- Go-Back-N Network Simulator Version 1.1 --------
Enter the number of messages to simulate: 20
Enter packet loss probability [enter 0.0 for no loss]:0.2
Enter packet corruption probability [0.0 for no corruption]:0
Enter average time between messages from sender's layer5 [ > 0.0]:5
Enter TRACE:2
- Trace输出
EVENT time: 0.467849, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=1): aaaaaaaaaaaaaaaaaaaa
send_window: send packet (seq=1): aaaaaaaaaaaaaaaaaaaa
EVENT time: 5.960295, type: 2, fromlayer3 entity: 1
B_input: recv packet (seq=1): aaaaaaaaaaaaaaaaaaaa
B_input: send ACK (ack=1)
EVENT time: 8.038575, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=2): bbbbbbbbbbbbbbbbbbbb
send_window: send packet (seq=2): bbbbbbbbbbbbbbbbbbbb
EVENT time: 8.459425, type: 2, fromlayer3 entity: 0
A_input: got ACK (ack=1)
Warning: attempt to start a timer that is already started
A_input: timer + 80.000000
EVENT time: 9.439863, type: 2, fromlayer3 entity: 1
B_input: recv packet (seq=2): bbbbbbbbbbbbbbbbbbbb
B_input: send ACK (ack=2)
EVENT time: 11.610156, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=3): cccccccccccccccccccc
send_window: send packet (seq=3): cccccccccccccccccccc
EVENT time: 14.876553, type: 2, fromlayer3 entity: 0
A_input: got ACK (ack=2)
Warning: attempt to start a timer that is already started
A_input: timer + 80.000000
EVENT time: 15.106326, type: 2, fromlayer3 entity: 1
B_input: recv packet (seq=3): cccccccccccccccccccc
B_input: send ACK (ack=3)
EVENT time: 16.664021, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=4): dddddddddddddddddddd
send_window: send packet (seq=4): dddddddddddddddddddd
EVENT time: 17.991364, type: 2, fromlayer3 entity: 0
A_input: got ACK (ack=3)
Warning: attempt to start a timer that is already started
A_input: timer + 80.000000
EVENT time: 21.240454, type: 2, fromlayer3 entity: 1
B_input: recv packet (seq=4): dddddddddddddddddddd
B_input: send ACK (ack=4)
EVENT time: 25.289467, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=5): eeeeeeeeeeeeeeeeeeee
send_window: send packet (seq=5): eeeeeeeeeeeeeeeeeeee
EVENT time: 28.731649, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=6): ffffffffffffffffffff
send_window: send packet (seq=6): ffffffffffffffffffff
EVENT time: 28.795433, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=7): gggggggggggggggggggg
send_window: send packet (seq=7): gggggggggggggggggggg
TOLAYER3: packet being lost
EVENT time: 29.269722, type: 2, fromlayer3 entity: 0
A_input: got ACK (ack=4)
Warning: attempt to start a timer that is already started
A_input: timer + 80.000000
EVENT time: 30.850855, type: 2, fromlayer3 entity: 1
B_input: recv packet (seq=5): eeeeeeeeeeeeeeeeeeee
B_input: send ACK (ack=5)
EVENT time: 31.855524, type: 2, fromlayer3 entity: 0
A_input: got ACK (ack=5)
Warning: attempt to start a timer that is already started
A_input: timer + 80.000000
EVENT time: 32.483902, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=8): hhhhhhhhhhhhhhhhhhhh
send_window: send packet (seq=8): hhhhhhhhhhhhhhhhhhhh
EVENT time: 36.460464, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=9): iiiiiiiiiiiiiiiiiiii
send_window: send packet (seq=9): iiiiiiiiiiiiiiiiiiii
TOLAYER3: packet being lost
EVENT time: 36.798424, type: 2, fromlayer3 entity: 1
B_input: recv packet (seq=6): ffffffffffffffffffff
B_input: send ACK (ack=6)
EVENT time: 39.976803, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
EVENT time: 44.952938, type: 2, fromlayer3 entity: 0
A_input: got ACK (ack=6)
Warning: attempt to start a timer that is already started
A_input: timer + 80.000000
EVENT time: 45.325787, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=10): jjjjjjjjjjjjjjjjjjjj
send_window: send packet (seq=10): jjjjjjjjjjjjjjjjjjjj
EVENT time: 45.626087, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=11): kkkkkkkkkkkkkkkkkkkk
send_window: send packet (seq=11): kkkkkkkkkkkkkkkkkkkk
EVENT time: 50.230320, type: 2, fromlayer3 entity: 0
A_input: got NAK (ack=6). drop.
EVENT time: 50.332897, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
TOLAYER3: packet being lost
EVENT time: 53.431808, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=12): llllllllllllllllllll
send_window: send packet (seq=12): llllllllllllllllllll
EVENT time: 54.884609, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
EVENT time: 56.689381, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
EVENT time: 59.354839, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=13): mmmmmmmmmmmmmmmmmmmm
send_window: send packet (seq=13): mmmmmmmmmmmmmmmmmmmm
TOLAYER3: packet being lost
EVENT time: 60.580311, type: 2, fromlayer3 entity: 0
A_input: got NAK (ack=6). drop.
EVENT time: 63.766899, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=14): nnnnnnnnnnnnnnnnnnnn
send_window: send packet (seq=14): nnnnnnnnnnnnnnnnnnnn
EVENT time: 65.803215, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
TOLAYER3: packet being lost
EVENT time: 68.434067, type: 2, fromlayer3 entity: 0
A_input: got NAK (ack=6). drop.
EVENT time: 71.390114, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=15): oooooooooooooooooooo
send_window: send packet (seq=15): oooooooooooooooooooo
EVENT time: 72.517166, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=16): pppppppppppppppppppp
send_window: send packet (seq=16): pppppppppppppppppppp
EVENT time: 72.550797, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
TOLAYER3: packet being lost
EVENT time: 75.854424, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
EVENT time: 77.397987, type: 2, fromlayer3 entity: 0
A_input: got NAK (ack=6). drop.
EVENT time: 80.231331, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=17): qqqqqqqqqqqqqqqqqqqq
send_window: send packet (seq=17): qqqqqqqqqqqqqqqqqqqq
EVENT time: 80.467850, type: 0, timerinterrupt entity: 0
A_timerinterrupt: resend packet (seq=7): gggggggggggggggggggg
A_timerinterrupt: resend packet (seq=8): hhhhhhhhhhhhhhhhhhhh
A_timerinterrupt: resend packet (seq=9): iiiiiiiiiiiiiiiiiiii
A_timerinterrupt: resend packet (seq=10): jjjjjjjjjjjjjjjjjjjj
A_timerinterrupt: resend packet (seq=11): kkkkkkkkkkkkkkkkkkkk
A_timerinterrupt: resend packet (seq=12): llllllllllllllllllll
A_timerinterrupt: resend packet (seq=13): mmmmmmmmmmmmmmmmmmmm
A_timerinterrupt: resend packet (seq=14): nnnnnnnnnnnnnnnnnnnn
A_timerinterrupt: resend packet (seq=15): oooooooooooooooooooo
A_timerinterrupt: resend packet (seq=16): pppppppppppppppppppp
A_timerinterrupt: resend packet (seq=17): qqqqqqqqqqqqqqqqqqqq
A_timerinterrupt: timer + 80.000000
EVENT time: 81.956238, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=18): rrrrrrrrrrrrrrrrrrrr
send_window: send packet (seq=18): rrrrrrrrrrrrrrrrrrrr
EVENT time: 83.008820, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=19): ssssssssssssssssssss
send_window: send packet (seq=19): ssssssssssssssssssss
EVENT time: 86.149239, type: 2, fromlayer3 entity: 1
B_input: not the expected seq. send NAK (ack=6)
TOLAYER3: packet being lost
EVENT time: 90.211800, type: 1, fromlayer5 entity: 0
A_output: bufferred packet (seq=20): tttttttttttttttttttt
send_window: send packet (seq=20): tttttttttttttttttttt
EVENT time: 93.544029, type: 2, fromlayer3 entity: 1
Simulator terminated at time 91.544029
after sending 20 msgs from layer5
二、各性能参数计算方法
1. 接收端吞吐率
一共收到了20个packet,用时93.544029个time unit,因此 r = 20 / 91.544029 = 0.2184 ( p k t / t i m e _ u n i t ) r=20/91.544029=0.2184(pkt/time\_unit) r=20/91.544029=0.2184(pkt/time_unit)。
2. 发送端超时重传次数
设置一个每重传一次就加1的全局变量即可。本次A_timerinterrupt
共重传了1次。
3. 发送端超时packet个数
如下:
EVENT time: 80.467850, type: 0, timerinterrupt entity: 0
A_timerinterrupt: resend packet (seq=7): gggggggggggggggggggg
A_timerinterrupt: resend packet (seq=8): hhhhhhhhhhhhhhhhhhhh
A_timerinterrupt: resend packet (seq=9): iiiiiiiiiiiiiiiiiiii
A_timerinterrupt: resend packet (seq=10): jjjjjjjjjjjjjjjjjjjj
A_timerinterrupt: resend packet (seq=11): kkkkkkkkkkkkkkkkkkkk
A_timerinterrupt: resend packet (seq=12): llllllllllllllllllll
A_timerinterrupt: resend packet (seq=13): mmmmmmmmmmmmmmmmmmmm
A_timerinterrupt: resend packet (seq=14): nnnnnnnnnnnnnnnnnnnn
A_timerinterrupt: resend packet (seq=15): oooooooooooooooooooo
A_timerinterrupt: resend packet (seq=16): pppppppppppppppppppp
A_timerinterrupt: resend packet (seq=17): qqqqqqqqqqqqqqqqqqqq
因此重传了6个packet,N_pkt_retran=6。
4. 正确接收packet数
观察函数B_input代码,可知当打印下列语句时则为正确接收数据包:
printf(" B_input: recv packet (seq=%d): ", packet.seqnum);
设置一个全局变量,每打印一次加1即可。本次共接收按序packet共计6次。
5. 乱序接收packet数
观察函数B_input代码,可知当打印下列语句时则为正确接收数据包:
printf(" B_input: not the expected seq. send NAK (ack=%d)\n", packet_to_send.acknum);
设置一个全局变量,每打印一次加1即可。本次共接收乱序packet共计8次。
6. 接收packet总数
顺序加乱序的packet求和,N_pkt_total=14(然而,这只是输出的)
7. 发送端Layer5丢包数量
观察A_output函数,当打印下列语句时,说明buffer已满,不能发送数据:
printf(" A_output: buffer full. drop the message: %s\n", data);
设置一个全局变量,每打印一次加1即可。本次没有这样的丢包。
8. 链路丢包数量
A
端输出TOLAYER3: packet being lost
的次数,共3次。
9. 仿真结束时缓冲区剩余packet
修改代码如下:
terminate:{
float bufremain;
bufremain=buffer_next % BUF_SIZE;
printf("%f\n",bufremain);
printf(" Simulator terminated at time %f\n after sending %d msgs from layer5\n",time,nsim);
}
即可输出缓冲区余量。
10. 仿真结束时发送剩余packet
在terminate中添加如下代码:
sndremain=(nextseq-base)%window_size-1;
printf(" Sender Remains: %f pkts\n",sndremain);
即可输出发送端数据包余量。
11. 发送端缓冲区长度
根据代码来看,全局变量BUFSIZE
值为64,代表64pkts。
三、说明
由于本人水平有限,上述说明仅供参考