Links are numbered within each node from 0 to the number of physical links that the node has, with 0 representing the LOOPBACK link. The first ``real'' link is number 1 and every node will have a link number 1.
Perhaps surprisingly, the nodes initially have very little knowledge of the network. Nodes do not know how many other nodes there are, what the other nodes are called, nor the attributes of any nodes or links other than their own. All inter-node communication necessary to learn this information must traverse the Physical Layer.
If necessary, the topology file is first preprocessed by the C-preprocessor, enabling us to use #include, #define and conditional ``compilation'' directives if required. C and C++ style comments are also supported.
/* A simple 2 node network topology */ compile = "stopandwait.c" messagerate = 500ms, propagationdelay = 700ms, probframecorrupt = 3, ostype = "linux" host Perth { x=100, y=100 messagerate = 1000ms, link to Sydney } host Sydney { east of Perth link to Perth { probframeloss = 2 } }
Node attributes and link attributes declared before any nodes are considered global attributes - these will be the defaults unless redefined locally within a node or link definition. Local attributes are declared in a new ``block'', by opening a curly bracket (as in C). In the above topology, the default messagerate (the rate at which the Application Layer will generate a new message for delivery) is 500ms. This becomes the default messagerate for all nodes, but node Perth later declares its own (local) messagerate as 1000ms.
The compile attribute indicates which C source files are to be compiled and executed by cnet. Here, 2 instances the source code in the single file stopandwait.c will be executed by Perth and Sydney. Each node will have its own copy of all variables declared in the file stopandwait.c (globals, static globals, locals and static locals).
Times are stored internally in milliseconds though in the topology file their integral values may be followed by suffixes such as ms and s.
Data sizes are stored internally in bytes though in the topology file their integral values may be followed by suffixes such as bytes, Kbytes, KB, and MB.
Boolean attributes may take on the values true, false, and toggle.
Strings are enclosed within double quotes.
Node attribute | meaning |
---|---|
address | the unique network address of each node |
compile | a compilation string to declare the sourcefile names containing the protocols for each node (locally overrides the -C option) |
messagerate | the rate at which the Application Layer can generate new messages for delivery |
minmessagesize | the minimum size of messages generated by the Application Layer |
maxmessagesize | the maximum size of messages generated by the Application Layer (bounded by MAX_MESSAGE_SIZE |
nodemtbf | the expected time between node hardware failures |
nodemttr | the expected time taken to repair a hardware failure |
ostype | the name of the operating system that runs on the node (only used to set the node's icon). Known types include bsd, hurd, irix, linux, macintosh, nextstep, os2, solaris, and winnt. Gimmick. |
outputfile | the name of the output file for each node. When used as a global attribute, outputfile is used as a filename prefix (as with the -o option). When used locally, outputfile indicates the complete filename |
rebootnode | the name of the ANSI-C function to call when the node reboots (locally overrides the -R option) |
trace | a boolean indicating if event tracing is required (overrides the -t option) |
x, y | integer coordinates of the node's icon on the topology canvas |
winx, winy | screen integer coordinates of the node's window under X-windows |
winopen | boolean attribute requesting that a node's window be opened on startup |
While executing, each node has access to its own CnetNodeinfo structure describing the node's attributes. This structure is best considered read-only as its contents are ``refreshed'' as each node is scheduled for execution.
typedef struct { CnetNodetype nodetype; /* Either a NT_HOST or a NT_ROUTER */ int nodenumber; /* Ranging from 0.._NNODES-1 */ CnetAddr address; /* Possibly different to the nodenumber */ char *nodename; int nlinks; /* Ranging from 0(=LOOPBACK) .. nlinks */ int minmessagesize; /* min size (in bytes) of msgs generated */ int maxmessagesize; /* max size (in bytes) of msgs generated */ int messagerate; /* rate of msg generation (in ms) */ long time_in_ms; /* a monotonically increasing clock */ struct { long sec; long msec; } time_of_day; /* a reflection of the wall-clock time */ } CnetNodeinfo; CnetNodeinfo nodeinfo;
Link bandwidths are stored internally in bits-per-second though in the topology file their integral values may be followed by suffixes such as bps, Kbps, and Mbps.
Probabilities specify a uniform distribution, with their value being the log-base-2 of the chance of failure (yes, this is ugly). In the topology above, the global probframecorrupt attribute declares that a frame will be corrupted with probability of 1 in 8 (2 to the power 3) and the link from Sydney to Perth will lose (on average) every fourth frame. A probability of 0 (the default) means that no errors will be introduced.
Link attribute | meaning |
---|---|
bandwidth | the bandwidth along a link |
costperbyte | the cost (in cents) per byte along this link |
costperframe | the cost (in cents) per frame along this link |
linkmtbf | the expected time between link hardware failures |
linkmttr | the expected time taken to repair a link hardware failure |
probframecorrupt | the probability that a frame on this link will be corrupted |
probframeloss | the probability that a frame on this link will be lost altogether |
propagationdelay | the propagation delay along a link |
While executing, each node has access to its own array of read-only CnetLinkinfo structures:
typedef struct { int linkup; /* TRUE if link not severed */ int bandwidth; /* in bits per second */ int propagationdelay; /* in ms */ int transmitbufsize; /* in bytes */ int costperbyte; /* in cents(?) */ int costperframe; /* in cents(?) */ } CnetLinkinfo; CnetLinkinfo *linkinfo; /* linkinfo[0]..linkinfo[nodeinfo.nlinks] */To find the propagation delay of the first ``real'' link in a 2 node simulation, each node would simply access linkinfo[1].propagationdelay .
Strings are used to declare the location (filenames) of the source and shared object codes for the Application, ``Central'' and Physical Layers used in each simulation. These strings may be provided on the command line, via the -A, -C, and -P options, or via the compile node attribute in the topology file.
In their simplest form, compilation strings may present just a single C sourcefile name, such as "protocol.c". If necessary, cnet, will compile the file protocol.c into the object file protocol.o and then link this file to form the final shared object protocol.cnet. This final shared object file will then be used to provide the code for each node's relevant layer(s).
In its more complex form, a compilation string may also include compilation switches, a number of sourcefile names, and linker switches. For example, the compilation string
includes an embedded (actually preprocessor) switch which is passed onto the compilation process, two sourcefile names and a linker switch (in this case to link with the mathematics library). Each source file is compiled (if necessary) to create its object file, and all object files are then linked together to form a single shared object. The shared object's name is derived from the first sourcefile found, in this case it will be ftp.cnet. The embedded switches -l and -L are recognized as (assumed to be) linker switches; all other switches are assumed to be preprocessor and compiler switches.
cnet performs the rudimentary actions of make(3), compiling and linking files if the required target does not exist or is out-of-date with respect to sourcefiles.