next up previous contents index
Next: 5.2 Send packet processing Up: 5. Internet Node Previous: 5. Internet Node   Contents   Index


5.1 InternetNode members

The InternetNode::Construct() function (called by the object constructor) describes what makes up an InternetNode.

     from internet-node.cc

     54 void
     55 InternetNode::Construct (void)
     56 {
     57   Ptr<Ipv4L3Protocol> ipv4 = Create<Ipv4L3Protocol> (this);
     58   Ptr<ArpL3Protocol> arp = Create<ArpL3Protocol> (this);
     59   Ptr<UdpL4Protocol> udp = Create<UdpL4Protocol> (this);
     60 
     61   Ptr<L3Demux> l3Demux = Create<L3Demux> (this);
     62   Ptr<Ipv4L4Demux> ipv4L4Demux = Create<Ipv4L4Demux> (this);
     63 
     64   l3Demux->Insert (ipv4);
     65   l3Demux->Insert (arp);
     66   ipv4L4Demux->Insert (udp);
     67 
     68   Ptr<UdpImpl> udpImpl = Create<UdpImpl> (udp);
     69   Ptr<ArpPrivate> arpPrivate = Create<ArpPrivate> (arp);
     70   Ptr<Ipv4Impl> ipv4Impl = Create<Ipv4Impl> (ipv4);
     71   Ptr<Ipv4Private> ipv4Private = Create<Ipv4Private> (ipv4);
     72 
     73   Object::AddInterface (ipv4Private);
     74   Object::AddInterface (ipv4Impl);
     75   Object::AddInterface (arpPrivate);
     76   Object::AddInterface (udpImpl);
     77   Object::AddInterface (l3Demux);
     78   Object::AddInterface (ipv4L4Demux);
     79 }

There are a few things to note in this function. First, lines 57-59 create instances of the layer-3 and layer-4 protocols, and assign their pointers to ns-3 smart pointers. Note the use of the Create method, which is a templated wrapper around operator new. Each of these objects has a back-pointer ("this") to the InternetNode. (Note: This class does not make use yet of the replaceable component system; objects are created with raw Create functions.)

Next, lines 61-62 create demultiplexers (demuxes). These are analogous to ns-2 Classifiers, and they direct packets to the right layer-3 or layer-4 protocol. These demuxes have to be told about what layer-3 protocols are active in a node (line 64-66). If/when we have Tcp and Ipv6 models, those will be added as well.

Lines 68-71 create some private implementation-related objects that make up the Ipv4, Arp, and Udp implementations.

Finally, we want to make interfaces to these objects available to the QueryInterface facility, so we explicitly add these pointers in lines 73-78.

The next two sections graphically depict how the various objects in the src/internet-node directory relate to one another.


next up previous contents index
Next: 5.2 Send packet processing Up: 5. Internet Node Previous: 5. Internet Node   Contents   Index
Tom Henderson 2007-06-17