"Stop-and-Wait" protocol using NS2 1. Background
"stop-n-wait" (sometimes known as "positive acknowledgement with fundamental technique to provide reliable transfer transfer retransmission" ) is the fundamental under unreliable packet delivery system. 2. How this protocol works.. 1) Normal operation
After transmitting one packet, the sender waits for anacknowledgment (ACK) from the receiver before transmitting the next one. In this way, the sender can recognie that the previous packet is transmitted successfuly and we could say !stop"n"wait! guarantees reliable transfer between nodes. #o support this feature, the sender keeps a record of each packet it sends. Also, to avoid confusion caused by delayed or duplicated A$%s, !stop"n"wait! sends each packets with unique sequence numbers and receives that numbers in each A$%s.
2) Timeout
If the sender doesn&t receive A$% for previous sent packet after a certain period of time, the sender times out and retransmits t hat packet again. #here are two cases when the sender doesn&t receive A$%' ne is when the A$% is lost and the other is when the frame itself is not transmitted. #o support this feature, the sender keeps timer per each packet. 3. How it is shown in nam (network animator)..
!stop"n"wait! protocol can be shown as below in nam.
. *acket+ is sent and A$%+ is received
-. *acket+ is sent and A$%+ is received
. *acket+- will be sent and be received and so on.. 4. Shortcoming
#he main shortcoming of the stop"and"wait algorithm is that it allows the sender to have only one outstanding frame on the link at a time. #he sender should wait till it gets an A$% of previous frame before it sends next frame. As a result, it wastes a substantial amount of network bandwidth. #o improve efficiency while providing reliability, !sliding window! protocol is appeared. Stop-n-Wait ns script / stop and wait protocol in normal situation / features 0 labeling, annotation, nam"graph, and window sie monitoring
set ns 1new 2imulator3 set n 14ns node3 set n 14ns node3 4ns at . !4n label 2ender! 4ns at . !4n label 5eceiver! set nf 1open A"stop"n"wait.nam w3 4ns namtrace"all 4nf set f 1open A"stop"n"wait.tr w3 4ns trace"all 4f 4ns duplex"link 4n 4n .-6b -ms 7rop#ail 4ns duplex"link"op 4n 4n orient right 4ns queue"limit 4n 4n Agent8#$* set nam+tracevar+ true set tcp 1new Agent8#$*3 4tcp set window+ 4tcp set maxcwnd+ 4ns attach"agent 4n 4tcp set sink 1new Agent8#$*2ink3 4ns attach"agent 4n 4sink 4ns connect 4tcp 4sink set ftp 1new Application89#*3 4ftp attach"agent 4tcp
4ns add"agent"trace 4tcp tcp 4ns monitor"agent"trace 4tcp 4tcp tracevar cwnd+ 4ns at . !4ftp start! 4ns at . !4ns detach"agent 4n 4tcp ' 4ns detach"agent 4n 4sink! 4ns at .: !finish! 4ns at . !4ns trace"annotate ;!2top and
? !4ns trace"annotate ;!5eceive Ack+;!! 4ns at .?? !4ns trace"annotate ;!2end *acket+-;!! 4ns at .- !4ns trace"annotate ;!5eceive Ack+- ;!! 4ns at .@ !4ns trace"annotate ;!2end *acket+;!! 4ns at .=> !4ns trace"annotate ;!5eceive Ack+;!! 4ns at . !4ns trace"annotate ;!2end *acket+@;!! 4ns at -. !4ns trace"annotate ;!5eceive Ack+@;!! 4ns at -.- !4ns trace"annotate ;!2end *acket+:;!! 4ns at -.:: !4ns trace"annotate ;!5eceive Ack+: ;!! 4ns at -.>: !4ns trace"annotate ;!2end *acket+=;!! 4ns at -.?? !4ns trace"annotate ;!5eceive Ack+=;!! 4ns at . !4ns trace"annotate ;!9#* stops;!! proc finish BC B global ns nf 4ns flush"trace close 4nf puts !filtering...! exec tclsh ..8ns"allinone"-.b:8nam".a>8bin8namfilter.tcl A"stop"n"wait.nam puts !running nam...! exec nam A"stop"n"wait.nam D exit C 4ns run