cnet v2.0.5

home
introduction
simulation model

topology files
cmdline options
the API

FAQ

download

cnet's IEEE 802.3 Ethernet segments

As of version 2.0, cnet supports IEEE 802.3 Ethernet segments as well as its traditional point-to-point links. Each segment consists of two or more Network Interface Cards (NICs) that connect host or router nodes to the segment. Most of the information on this page also appears on other pages, but it is all presented here for convenience.

Defining topologies containing Ethernet segments

An example 9-node Ethernet segment is defined in the following topology file. Each node's connection to the segment named ``CSSE'' is introduced by the node's NIC address, in the 6-byte hexadecimal format of traditional Ethernets. When developing protocols in C cnet provides access to each NIC's address as a field of the standard linkinfo structure. The CnetNicaddr datatype that is used to store each NIC address as an array of LEN_NICADDR (=6) unsigned characters. cnet also provides the functions CNET_parse_nicaddr and CNET_format_nicaddr to convert between character strings and the CnetNicaddr datatype.


compile        = "ethertest.c"

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

ethernet CSSE {
    nicaddr 00:90:27:62:58:84   host budgie   { }
    nicaddr 00:90:27:41:D7:42   host dibbler  { }
    nicaddr 00:02:B3:3C:34:C5   host dunnart  { }
    nicaddr 00:0A:27:7D:41:C6   host emu      { }
    nicaddr 00:D0:B7:83:97:E7   host galah    { }
    nicaddr 00:90:27:41:B0:BE   host kanga    { }
    nicaddr 00:AA:00:BC:C0:73   host kidna    { }
    nicaddr 00:90:27:62:83:F5   host koala    { }
    nicaddr 00:90:27:34:B6:D8   host wombat   { }
}

cnet checks and warns if two NIC addresses in a topology files are the same, but does not demand their uniqueness. This permits some snooping/sniffing protocols to be developed on nodes that use CNET_set_nicaddr to ``steal'' packets destined for other nodes. Of course, such packets will also arrive at the intended destination node.

Each NIC address is followed by a standard host or router definition, as with the definition of wide-area point-to-point topologies. In this example, nothing appears in the (mandatory) curly brackets after each node's name, but standard node and link attributes, such as the node's message rate or even point-to-point links to other nodes, may be defined here. The resulting ``network map'' appears below:

Large networks may be constructed by joining multiple Ethernet segments via gateway nodes and wide-area point-to-point links. Consider the following (abbreviated) topology file consisting of 3 Ethernet segments and one point-to-point link. Each named segment has a few nodes, each connected via its NIC. The router named Gateway1 is directly connected to segment Lab1 and segment Lab2 via Ethernet NICs, and also connects to Gateway2 via a point-to-point link.

 ........
ethernet Lab1 {
    nicaddr 00:90:27:62:58:84   host budgie     { }
    nicaddr 00:90:27:34:B6:D8   host wombat     { }
    nicaddr 00:90:27:34:B6:D1   host birdie     { }
    nicaddr 00:90:27:34:B6:A0   router gateway1 { }
}

ethernet Lab2 {
    nicaddr 00:90:27:34:B6:A1   host pent301    { }
    nicaddr 00:90:27:34:B6:A2   host pent302    { }
    nicaddr 00:90:27:34:B6:A3   host pent303    { }
    nicaddr 00:90:27:34:B6:A7   router gateway1 { }
}

ethernet Lab3 {
    nicaddr 00:90:27:34:B6:A4   host pent304    { }
    nicaddr 00:90:27:34:B6:A5   router gateway2 { link to gateway1 }
    nicaddr 00:90:27:34:B6:A6   host pent306    { }
}

Although no nodes or segments have explicitly given their x,y coordinates, cnet does a modest job of drawing the network (though don't expect miracles for complex networks): To present a reasonable looking display, you should provide x,y coordinates for the left-hand end of a segment, or the coordinates for any node. Segments are first positioned (all horizontally) and separated, and then nodes are drawn on the segments. Any missing node coordinates are determined from known points.

Reading and writing data via Ethernets

Frames written to Ethernet links are expected to carry the address of their destination Network Interface Card (NIC) at the very beginning of the frame. cnet interprets the leading LEN_NICADDR bytes of each frame on an Ethernet segment to be an address. The special address, whose string representation is ff:ff:ff:ff:ff:ff, is interpreted as the Ethernet broadcast address. Any frame carrying the broadcast address as its destination address will be delivered to all NICs on the Ethernet segment, except the sender. cnet does not support multicast or group addressing. Consider the following example function, used to write data to an Ethernet segment:


typedef struct {
    CnetNicaddr    dest;
    CnetNicaddr    src;
    char           type[2];
    char           data[ETH_MAXDATA];
} ETHERPACKET;

#define LEN_ETHERHEADER (2*sizeof(CnetNicaddr) + 2)

static void write_to_ethernet(CnetNicaddr dest, int link, char *buf, int len)
{
    ETHERPACKET packet;
    short int   twobytes;

    memcpy(packet.dest, dest,                   sizeof(CnetNicaddr));
    memcpy(packet.src,  linkinfo[link].nicaddr, sizeof(CnetNicaddr));

    twobytes = len;              /* type carries the data's true length */
    memcpy(packet.type, &twobytes, 2);
    memcpy(packet.data, buf, len);

    len  += LEN_ETHERHEADER;
    if(len < ETH_MINPACKET)      /* pad short packets to minimum length */
        len = ETH_MINPACKET;
    CHECK(CNET_write_physical(link, (char *)&packet, &len));
    ......
}

This naive function assumes that the data's length is not too long for Ethernet (<= ETH_MAXDATA (=1500) bytes). The required destination's NIC address is first copied to the destination address field, and then the address of the local NIC used is copied to the source address field. Notice that because the CnetNicaddr type is actually an array of characters, we do not use the & operator in the calls to memcpy. The data's true length is copied into the packet's two-byte type field, the provided data copied to the packet's data. After ensuring that the packet to be written is at least ETH_MINPACKET (=64) bytes long, the packet is written to the link. Again, cnet does not enforce (nor understand) the use of our ETHERPACKET data type, but does assume that the first LEN_NICADDR bytes of each packet provides the destination NIC address.

Limitations

cnet's simulation of Ethernets is reasonable, but not perfect. cnet supports a fixed transmission rate of 10Mbps, a slot-time of 52usecs, broadcast addressing, collision detection, jamming, and binary exponential backoff. It does not support sub-microsecond timing, jitter control, nor multicast addressing. Each segment is considered to be a full 2.5km long, and all nodes on a segment are considered to be equally spaced along the segment.

You are not encouraged to use cnet as a tool to design an Ethernet-based network against explicit capacity carrying objectives.

cnet was written and is maintained by Chris McDonald (chris@csse.uwa.edu.au)