A key node object is class NetDevice, which represents a physical interface on a node (such as an Ethernet interface). We discuss also in this section the class Channel, which is closely coupled to the attached NetDevices.
The basic idea is to mimic the Linux architecture at the boundary between device-independent sublayer of the network device layer and the IP layer (figure 3.2). The top interface of NetDevice approximates the point in the Linux kernel where dev_queue_xmit() is called. The data members of NetDevice are similar to those found in Linux struct net_device. The IPv4 or IPv6 portion of a device (struct in_device) is modeled by a separate object on top of NetDevice (not discussed in this section).
Figure 3.2 illustrates some of the main objects and actions involving sending a packet up and down the stack. First, there is an abstract class NetDevice that implements a Node pointer, MacAddress, string name (e.g., "eth0"), MTU, and has a flag for setting the state to be up or down. Two callbacks are included; the first allows a higher-layer protocol to register a function to be used to send the packet up the stack; this callback is present to decouple the NetDevice from the higher layer protocol above (typically layer-3 but may also be something like a bridging layer), as described in the previous section. Another callback allows the NetDevice to notify listeners of a change in state. Finally, there is a method provided to return a base class Channel pointer, which is forwarded to a NetDevice subclass that actually has the pointer.
NetDevices in use in the simulation will all subclass from this
base class; an example is in
src/devices/p2p-net-device.cc,h.
These subclasses are matched to a particular corresponding
channel type. That is, for example, a PointToPointNetDevice
is attached to a PointToPointChannel. This convention provides
type-safety in avoiding the connection of incompatible Channel and
NetDevice types. The subclass (denoted *NetDevice in the
figure) also
provides a Receive() method to allow packets to be sent to it
from the Channel; e.g. PointToPointChannel calls
PointToPointNetDevice::Receive(). Any queue implementations
are stored in these subclasses.
Packets traversing the stack in the outbound direction call the base class NetDevice::Send() which forwards the packet to the appropriate subclass method. Packets traversing the stack in the inbound direction will call the callback registered with m_receiveCallback when the NetDevice is done processing the packet and wants to hand it to the higher layer.