
This directory contains cnet implementations of 3 Network Layer flooding
algorithms of increasing complexity and efficiency.  Read the block
comment at the top of each source protocol file for an explanation of
that file's implementation.

Each implementation attempts to quash unecessary packets by limiting the
number of hops they may travel.  The constant MAX_HOPS is set to 4 and
is appropriate for the simple topology in AUSTRALIA.MAP.  The constant
MAX_HOPS may need to be set to larger values for topologies with a
greater diameter, else nodes at the periphery will never be able to
communicate because they are too far away and all their packets will be
silently discarded!

All 3 implementations employ a lot of common code.  This includes a
simple implementation of a Network Layer table - an array of structures
that is simply extended each time a new remote address is found (discovered).
Its implementation begins life (in flooding1.c) as:

    typedef struct {
	CnetAddr    address;
	int         ackexpected;
	int         nextframetosend;
	int         frameexpected;
    } NL_TABLE;

and is extended in later protocols.  Its fields maintain information about
each remote host's address and (from the example above) the sequence
numbers used in a NL stop-and-wait protocol between ourselves and the
remote node.  In later protocols, flooding2 and flooding3, fields are
added so that each NL remembers the best_link on which to address packets
for the remote node, and how many hops away we believe it to be.

A simple encoding "trick" is used in flooding2 and flooding3 in which we
use an integer variable to hold a large boolean bitmap.  A field is added
to the NL table to record the best_link to choose for outgoing packets.
If we don't know the best_link, the constant ALL_LINKS (value = -1)
is used, as its binary representation of "all ones" indicates that all
possible links should be used (full flooding).  Over time, a single
best_link will be known, and that will be stored in an integer variable
with the value (1 << BEST_LINK).  For example, if the best_link to use is
link number 3, the value 8 (i.e. 1<<3) will be stored.  When we wish to
broadcast a packet via all necessary links, the function selective_flood()
accepts a bitmap indicating which links should be used.

As we are assuming 32-bit integers, only nodes with at most 32 links can
use this encoding trick.

------------------------------------
Chris McDonald (chris@cs.uwa.edu.au)
