Professional Documents
Culture Documents
Selective Repeat
1. Selective Repeat
Selective Repeat
( ). Selective Repeat
. Tanenbaum ( 5),
3.4.3, .
, , ,
.
1.1
Go Back N
. ,
.
.
.
,
. 0
MAX_SEQ. ,
MAX_SEQ.
. bit
. ,
.
, .
. ,
.
, Stop and Wait Go Back N.
, ,
. ,
( ) (
). .
,
, .
, /
. , 4 bit
, 0 15.
. ,
1
0 7
8 15, (0
7) (8 15). , Selective Repeat
(MAX_SEQ+1)/2. , 3 bit,
, 4 bit, .
:
;
. ,
,
. 4 bit,
0 7. i i
mod 8.
Selective Repeat
Go Back N .
, () .
.
:
(
).
,
. no_nak Selective Repeat
frame_expected.
,
.
, no_nak
. ,
.
1.2
, , .. lab5.tcl,
. , .
, ,
, .
,
awk. , , script
.
.awk
.
awk.exe.
: 1,
.
*.tcl (File > Save).
(cursor) Command Prompt, Xgraph,
. X ,
File. log off .
.
2
2.
2.1
.
# Create a simulator object
set ns [new Simulator]
,
, (trace files),
.
# Open the nam trace file
set nf [open lab5.nam w]
$ns namtrace-all $nf
set trf [open lab5.tr w]
$ns trace-all $trf
2.2
, n(0) n(1)
, 1.
1 -
3
# The following line sets the queue limit of the two simplex links that connect node0 and node1 to
the number specified.
$ns queue-limit $n(0) $n(1) 200
$ns queue-limit $n(1) $n(0) 200
2.3
Selective Repeat TCP
SACK (Selective Acknowledgement). TCP
n(0) n(1). :
# Create TCP agent
set tcp0 [new Agent/TCP/Sack1]
2.4
,
FTP, 0.5 sec 4.5 sec.
FTP
:
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
2.5
, :
# Events
$ns at 0.5 "$ftp0 start"
$ns at 4.5 "$ftp0 stop"
$ns at 5.0 "finish"
3. (trace file)
,
,
.
3.1 (trace file)
lab5.tr :
r
+
r
0.507432
0.508664
0.508664
0.508664
0.509896
1
0
1
1
0
0
1
0
0
1
ack
tcp
ack
ack
tcp
40 ------- 0
1540 ------40 ------- 0
40 ------- 0
1540 -------
1.0 0.0 1
0 0.0 1.0
1.0 0.0 2
1.0 0.0 2
0 0.0 1.0
5
2 2
6
6
3 3
+
r
+
0.509896
0.509896
0.511232
0.511232
1
1
1
0
0
0
0
1
ack
ack
ack
tcp
40 ------- 0
40 ------- 0
40 ------- 0
1540 -------
1.0 0.0 3
1.0 0.0 3
1.0 0.0 0
0 0.0 1.0
7
7
4
4 8
,
.
. +
, - , r
, d .
. ,
( TCP IP).
.
(flow ID),
. flow ID (IP.port),
(sequence number) (unique number)
.
3.2 awk
, awk
. awk .
BEGIN {}
, .
, , ..
. .
,
. :
/^r/&&/tcp/ {
packets++;
data+=$6;
}
, r
(/^r/) (&&) tcp (/tcp/), packets
1, data ($6)
.
END{}
,
.
3.3
Selective Repeat
.
, .
TCP.
r tcp.
packets ( ) ,
data ( ) .
awk:
BEGIN {
data=0;
packets=0;
}
/^r/&&/tcp/ {
data+=$6;
packets++;
}
END{
printf("Total Data received\t: %d Bytes\n", data);
printf("Total Packets received\t: %d\n", packets);
}
3.4
awk, (interpreter) awk
.
lab5.awk lab5.tr, :
awk.exe -f lab5.awk < lab5.tr
4. Selective Repeat
4.1
()
, 1;
()
, :
( )/( )
TRANSP , (
)/( )
PROP
TRANSA
S
, : S = TRANSP + 2 x PROP + TRANSA
()
;
;
()
awk,
(
). .
()
,
, 40 byte
TCP IP, (ACK) 40 byte.
; , ;
() , ,
.
; (
) .
;
()
(),
,
. ; bits
Selective
Repeat ;
()
(),
.
, .
.
()
,
.