CITS3002 Computer Networks  
prev
next CITS3002 help3002 CITS3002 schedule  

A Sample selective-repeat Protocol, continued

When the layer above (here, the Application Layer) provides a message for delivery, we must now buffer that message for possible future retransmission. Care is required to use the correct buffer!

As we also have a finite number of buffers in the sender, we must choke or throttle the Application Layer when our buffers are exhausted.

EVENT_HANDLER(appl_ready)
{
    CnetAddr dest;
    int      nf   = nextdatatosend % NRBUFS;

    outframe[nf].len   = MAX_MESSAGE_SIZE;

    CHECK(CNET_read_application(&dest, outframe[nf].msg, &(outframe[nf].len)));

    if(++nbuffered == NRBUFS) {         // out of buffer space!
	CNET_disable_application(dest);
    }
    transmit_frame(&outframe[nf], DL_DATA, FRAME_SIZE(outframe[nf]), nextdatatosend);
    inc(&nextdatatosend);
}




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