CITS3002 Computer Networks  
prev
next CITS3002 help3002 CITS3002 schedule  

A naive non-adaptive routing algorithm - Flooding

Initially, every 'incoming' packet is retransmitted on every link:

void down_to_networklayer(/* event, timer, data */)
{
    READ_APPLICATION(/* get destn, msg and length */);

    // ... fill in packet header info

    for(int link=1 ; link<=NLINKS ; ++link) {
	DOWN_TO_DATALINK(link, packet, len);
    }
}


void up_to_networklayer(/* packet, length */)
{
    if(packet_is_for_this_node) {
	if(packet_is_data) {
	    WRITE_APPLICATION(/* the msg in the packet */);

	    // ... prepare acknowledgement

	    for(int link=1 ; link<=NLINKS ; ++link) {
		DOWN_TO_DATALINK(link, ... /* send ACK */);
            }
	}
	else {
	    ;  // ACK received => prepare to send more data
        }
    }
    else {     // send packet out again
	for(int link=1 ; link<=NLINKS ; ++link) {
	    DOWN_TO_DATALINK(link, packet, len);
        }
    }
}

Advantage : flooding gives the shortest packet delay (the algorithm chooses the shortest path because it chooses all paths!) and is robust to machine failures.


CITS3002 Computer Networks, Lecture 5, The Network Layer, p11, 25th March 2024.