CITS3002 Computer Networks  
prev
next CITS3002 help3002 CITS3002 schedule  

Receiving new messages for delivery

The first thing of interest that will occur after each node has rebooted is that one node's Application Layer will generate and announce a new message for delivery.

We handle the EV_APPLICATIONREADY event with our application_ready() function:

EVENT_HANDLER(application_ready)
{
    CnetAddr destaddr;

    lastlength  = sizeof(MSG);
    CHECK(CNET_read_application(&destaddr, &lastmsg, &lastlength));
    CNET_disable_application(ALLNODES);

    printf("down from application, seq=%d\n",nextdatatosend);

    transmit_frame(&lastmsg, DL_DATA, lastlength, nextdatatosend);

    nextdatatosend = 1 - nextdatatosend;
}

Of note:

  • Assignment statements such as  sequence = 1 - sequence;    are used to quickly toggle between the values 0 and 1.



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