CITS3002 Computer Networks  
prev
CITS3002 help3002 CITS3002 schedule  

A Sample selective-repeat Protocol, continued

When a DL_DATA frame arrives, we must ensure that it is within the receiver's range of expected frames.

For each frame in a sequence that have arrived successfully, we send it to the layer above.

//  this is the continuation of event-handler  physical_ready

    else if(frame.kind == DL_DATA) {
	if(between(dataexpected, frame.seqno, toofar) &&
	    arrived[frame.seqno % NRBUFS] == false) {

	    arrived[frame.seqno % NRBUFS]    = true;
	    inframe[frame.seqno % NRBUFS]    = frame;   // copies frame

	    while(arrived[dataexpected % NRBUFS]) {
		len   = inframe[dataexpected % NRBUFS].len;
		CHECK(CNET_write_application( inframe[dataexpected % NRBUFS].msg, &len));

		arrived[dataexpected % NRBUFS] = false;
		inc(&dataexpected);
		inc(&toofar);
	    }
	}
	else {
	    ;    // frame is ignored/
        }
	transmit_frame(NULL,DL_ACK,0,(dataexpected+MAXSEQ)%(MAXSEQ+1) );
    }
}

We do not send an DL_ACK for each frame received; instead we simply acknowledgment the 'highest' sequence number correctly received to date.

This DL_ACK implies all 'lower' sequence numbers have been received as well.


CITS3002 Computer Networks, Lecture 3, Data Link Layer protocols, p32, 13th March 2024.