Kein Folientitel
Transport Layer
3-1
Lab 1 (example)
Sender wants to transmit 6 msgs.
The third transmission is lost in the channel.
Windowsize = 4.
1 msec per transmission.
RTT = 15 msec.
Timer = 15 msec.
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-2
Lab 1 (example cont.)
send pkt0
send pkt1
send pkt2
send pkt3
(wait)
sender
receiver
receive pkt0, send ack0
receive pkt1, send ack1
receive pkt3, discard,
(re)send ack1
rcv ack0, send pkt4
rcv ack1, send pkt5
pkt 2 timeout
send pkt2
send pkt3
send pkt4
send pkt5
X loss
receive pkt4, discard,
(re)send ack1
receive pkt5, discard,
(re)send ack1
rcv pkt2, deliver, send ack2
rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5
ignore duplicate ACK
0 1 2 3 4 5 6 7 8
sender window (N=4)
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-3
Lab 1 (implementation)
ComputeChecksum( ): compute the checksum of the packet to be sent from the sender. Follow the checksum algorithm described in the class notes. Note that you need to include payload, sequence number, and ACK number in the computation. The payload always has a fixed length of 20 (as defined in the structure ‘struct msg’.)
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-4
Lab 1 (implementation)
CheckCorrupted( ): check the checksum of the packet received, return TRUE if packet is corrupted, FALSE otherwise.
CheckCorrupted( ): check the checksum of the packet received, return TRUE if packet is corrupted, FALSE otherwise.
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-5
Lab 1 (implementation)
A_output( ): called by layer5 (application) to send data to the other side. Follow the FSM of the GBN sender discussed in class. First, check if ‘nextseqnum’ falls within the sender window.
If yes,
create a packet by filling in the payload (which is contained in the application message) and a proper sequence number.
As this is a data packet, set ACK number to ‘NOTUSED’.
Compute checksum and send out the packet by calling function tolayer3.
Copy the packet to the buffer defined by winbuf.
If it is the first packet in window, start the timer. The timeout of the timer should be set to RTT (which is defined in the file).
If ‘nextseqnum’ does not fall within the sender window,
buffer the message if the sender message buffer is not full, exit otherwise (which typically will not occur).
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-6
Lab 1 (implementation)
A_input( ): called from layer 3, when a packet arrives for layer 4. Follow the FSM of the GBN sender discussed in class. First, check if the packet is corrupted.
If it is not,
delete the acked packets from window buffer, advance the window base pointer, and stop the timer.
Start a new time if there is still pending packets in the window that have not been acked.
If the message buffer is not empty (i.e., there are application messages waiting to be sent), create a new packet and send it.
A_timerinterrupt( ): called when A’s timer goes off. Restart the timer and resend all packets not acked.
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-7
Lab 1 (implementation)
B_input( ): called from layer 3, when a packet arrives for layer 4 at receiver B.
If the packet is not corrupted and is in order,
create an ACK packet (setting seqnum to NOTUSED), send it by calling tolayer3, and deliver received packet to layer 5 by calling tolayer5.
If the received packet is corrupted or out of order,
discard the packet but send an ACK.
A_init( ) and B_init( ): called before any other A’s or B’s functions to do initialization. Be sure to initialize the variables used by your functions such as base, nextseqnum, buffront bufrear, msgnum, winfront, winrear, pktnum, expectedseqnum etc.
‹#›/27
IERG3310 Computer Networks – Tutorial 3
Transport Layer
3-8
Lab 1 (grading policies)
It is important for your program to follow exactly the output format shown in the above two examples.
Late submission: within 24 hours (you will receive a penalty of 30% of your points), after 24 hours (you will receive no points)
Change of code in Sections 0, III, and IV of gbn.c: -5 points per change
You may define new global variables in Section II of gbn.c. However, you should keep the number of new global variables to be fewer than three. 2 points per variable will be deducted when the number of new variables is more than three.
The total points of this lab assignment are 100. Your code will be graded according to the following criteria:
Compilation: Your code should be compilable on Adriatic. 50% of grade will be deducted if your code fails to compile.
Protocol logic and programming style: Correct logic of GBN protocol behavior; 20 points will be deduced if the program uses NACK packets. Proper and meaningful comments for variables and statements.
Accuracy: Your program should generate the correct results AND follow the exact format of output as specified in the examples.
‹#›/27
IERG3310 Computer Networks – Tutorial 3