CS455 Syllabus

### The Receiver Windew

• Receiver window and Receiver buffer

• Recall: Receive/Receiver window

• Receive  Window = the list of sequence numbers that the receiver will consider (= accept) as new (data) frames

Example:

• Recall: Receive/Receiver buffer

 Receiver buffer = buffer in the receiver to store undeliverable data frames

Example:

• Receiver window = [5,6,7,8]

Receiver has 4 (frame) buffers

Then:

Receiver will buffer frames 5,6,7,8

(Typically: receiver window size = receive buffer size)

• How the receiver window changes (= "moves")

• Update algorithm for the receiver window:

 ``` Let Receiver Window = [ A .. B ] Receiver receives a data frame; Let X = send sequence number in received data frame; if ( A ≤ X ≤ B ) { Save the received data frame in the receiver buffer; Send ACK X; /* -------------------------------------- Try to deliver data frames in sequence -------------------------------------- */ if ( X == A ) { /* ----------------------------------------------------- First new frame is received, we can deliver some data frames ----------------------------------------------------- */ for ( frame i = A; i ≤ B; i++ ) do { if ( frame i was received (previously) ) { Deliver frame i } else { break; } } Receiver Window = [i .. i+(B-A)+1] // Advance receiver window !!! } } else { /* ========================================== Frame X has bee received previusly !!! ========================================== */ Discard frame !!! Send ACK X; // The ACK for frame X may have been lost !!! // That may be why the sender re-transmits X !!! } ```

• Example 1:

• Suppose:

 Sender window = [1,2,3,4] Receiver window = [1,2,3,4]

Events:

 The sender transmits frames 1,2,3,4 But: Frame 1 is lost

Graphically:

Explanation: how the receiver process the received frames:

 ``` Receiver window = [1 .. 4] Frame 1: lost Frame 2: 1 ≤ 2 ≤ 4 ? Yes ===> buffer frame 2 Send ACK 2 2 == 1 ? No ===> Cannot deliver frame Frame 3: 1 ≤ 3 ≤ 4 ? Yes ===> buffer frame 3 Send ACK 3 3 == 1 ? No ===> Cannot deliver frame Same result for frame 4 ```

Note:

 The receiver window does not slide forward !!!         (because no frame has been delivered !!!).

• Example 2: example continues

• Since the receiver did not transmit any ACK frames back:

 the sender will time out

Suppose after the time out, the sender retransmits frame 1 and we received correctly

Graphically:

How the receiver process the received frame (#1):

 ``` Receiver window = [1 .. 4] Frame 1: 1 ≤ 1 ≤ 4 ? Yes ===> buffer frame 2 Send ACK 2 1 == 1 ? Yes ===> deliver frames for ( i = 1; i ≤ 4 ; i++ ) do: { frame i = 1 received: Yes ===> deliver frame 1 frame i = 2 received: Yes ===> deliver frame 2 frame i = 3 received: Yes ===> deliver frame 3 frame i = 4 received: Yes ===> deliver frame 4 } Receiver window = [5.6.7.8] ```

• Note:

• When the sender receives the ACK 1 frame, the sender window will move as follows:

The sender window and receiver window are "lined up" (= starts with the same seq. no.)

• Example Program: (Demo above code)

• Prog file: /home/cs455000/demo/SelAck/run

How to run the program:

• Send 2 new frames
• Pause
• Click on frame 0 and kill it
• Resume

Observe that:

 The Receiver window will slide only when the retransmission of frame 1 was received