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

  Ptr<Ipv4L3Protocol> ipv4 = Create<Ipv4L3Protocol> (this);
  Ptr<ArpL3Protocol> arp = Create<ArpL3Protocol> (this);
  RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, 
    PeekPointer (ipv4)), Ipv4L3Protocol::PROT_NUMBER, 0);
  RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, 
    PeekPointer (arp)), ArpL3Protocol::PROT_NUMBER, 0);

  Ptr<Ipv4L4Demux> ipv4L4Demux = Create<Ipv4L4Demux> (this);
  Ptr<UdpL4Protocol> udp = Create<UdpL4Protocol> (this);
  ipv4L4Demux->Insert (udp);

  Ptr<UdpImpl> udpImpl = Create<UdpImpl> (udp);
  Ptr<Ipv4Impl> ipv4Impl = Create<Ipv4Impl> (ipv4);

  Object::AddInterface (ipv4);
  Object::AddInterface (arp);
  Object::AddInterface (ipv4Impl);
  Object::AddInterface (udpImpl);
  Object::AddInterface (ipv4L4Demux);

There are a few things to note in this function. First, several lines 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.)

A callback-based demultiplexer is used for demultiplexing packets from layer 2 to layer 3; the Receive function of two layer 3 protocols (ARP and Ipv4) are presently registered. An Ipv4L4Demux is also created to allow multiple transport protocols to be demultiplexed from IPv4. These are functionally analogous to ns-2 Classifiers, and they direct packets to the right layer-3 or layer-4 protocol. When we later have Tcp and Ipv6 models, those will be added as well to the demultiplexers as well.

The lines prefaced by "Object::" create objects whose interfaces are aggregated to the node and are available to the QueryInterface facility.

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-08-15