cnet v2.0.5

home
introduction
simulation model

topology files
cmdline options
the API

FAQ

download

Topology files

cnet accepts (many) command line options to control its execution. However, more important is cnet's use of a topology file to define the attributes and connections in each network simulation. Consider the following topology file which defines a 2 node network. An implementation of the stopandwait protocol is being developed to provide a reliable data-link layer protocol over the single point-to-point link. cnet keywords are presented in bold font.

If necessary, the topology file is first preprocessed by the C-preprocessor, enabling the use of #include, #define and conditional ``compilation'' directives if required. Simple /* C and C++ style comments */ are also supported.


/* A simple 2 node point-to-point network topology */

compile          = "stopandwait.c"

bgimage          = "australia1.gif"
drawframes       = true

messagerate      = 500ms,
propagationdelay = 700ms,
probframecorrupt = 3,

host Perth {
    ostype  = "palm"
    x=100, y=100
    messagerate  = 1000ms,

    link to Melbourne
}

host Melbourne {
    ostype  = "linux"
    east of Perth

    link to Perth
        { probframeloss = 2 }
}

Global attributes may be defined in each topology file and affect the execution of the whole simulation. They may not be redefined on a per-node or per-link basis. In the above topology, the global attributes of bgimage and drawframes are defined.

Node attributes and link attributes declared before any nodes are also considered as 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 following topology defines a single segment Ethernet-based network of 6 nodes. The segment is named Lab1 and will be drawn at the indicated co-ordinates on the topology map. Each node is connected to the segment by its Network Interface Card (NIC); each NIC's address, as a string of hexadecimal characters, introduces each node's connection to the segment. Although not shown in this example, each node could also define its own local node attributes between the { } characters.


/* A simple 6 node Ethernet-based network topology */

compile        = "ethertest.c"

minmessagesize =  100bytes
maxmessagesize = 1000bytes
messagerate    = 1s

ethernet Lab1 {

    x=100, y=200

    nicaddr 00:90:27:62:58:84  host budgie    { }
    nicaddr 00:90:27:41:B0:BE  host kanga     { }
    nicaddr 00:A0:C9:AF:9E:81  host quokka    { }
    nicaddr 00:0A:27:7D:41:C6  host emu       { }
    nicaddr 00:90:27:62:83:F5  host koala     { }
    nicaddr 00:90:27:34:B6:D8  host wombat    { }
}

These two topology examples define small networks, one a simple wide-area network, and the other a single segment Ethernet-based network. cnet permits any combination of wide-area networks and Ethernet segments to be defined in the same topology file. One or more nodes, typically routers of type NT_ROUTER, may have connections to a combination of wide-area networks and IEEE 802.3 Ethernet segments.

line

Compilation strings

Because cnet must dynamically link compiled versions of protocols at run-time, cnet performs all necessary compilation and linking. You neither compile nor link protocols yourself, nor use make(3) to do it for you. Invoking cnet with a valid topology file will perform all necessary compilation and linking before commencing the simulation. 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.

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. The compilation string to compile the ``Central'' layers may also be specified with 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

"-DDEBUG ftp.c tables.c -lm"

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 was written and is maintained by Chris McDonald (chris@csse.uwa.edu.au)