cnet's IEEE 802.3 Ethernet segmentsAs 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 segmentsAn 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.
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.
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 EthernetsFrames 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:
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.
Limitationscnet'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 (email@example.com)|