diff --git a/src/internet-node/internet-node.cc b/src/internet-node/internet-node.cc index d91504336..02b296065 100644 --- a/src/internet-node/internet-node.cc +++ b/src/internet-node/internet-node.cc @@ -23,77 +23,16 @@ #include "ns3/net-device.h" #include "ns3/callback.h" - -#include "ipv4-l4-demux.h" #include "internet-node.h" -#include "udp-l4-protocol.h" -#include "tcp-l4-protocol.h" -#include "ipv4-l3-protocol.h" -#include "arp-l3-protocol.h" -#include "udp-impl.h" -#include "tcp-impl.h" -#include "ipv4-impl.h" +#include "internet-stack.h" + namespace ns3 { InternetNode::InternetNode() { - Construct (); + AddInternetStack (this); } -InternetNode::InternetNode(uint32_t systemId) -{ - Construct (); -} - -InternetNode::~InternetNode () -{} - -void -InternetNode::Construct (void) -{ - Ptr ipv4 = CreateObject (); - Ptr arp = CreateObject (); - ipv4->SetNode (this); - arp->SetNode (this); - // XXX remove the PeekPointer below. - RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), - Ipv4L3Protocol::PROT_NUMBER, 0); - RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)), - ArpL3Protocol::PROT_NUMBER, 0); - - - Ptr ipv4L4Demux = CreateObject (); - Ptr udp = CreateObject (); - Ptr tcp = CreateObject (); - - ipv4L4Demux->SetNode (this); - udp->SetNode (this); - tcp->SetNode (this); - - ipv4L4Demux->Insert (udp); - ipv4L4Demux->Insert (tcp); - - Ptr udpImpl = CreateObject (); - Ptr tcpImpl = CreateObject (); - Ptr ipv4Impl = CreateObject (); - - udpImpl->SetUdp (udp); - tcpImpl->SetTcp (tcp); - ipv4Impl->SetIpv4 (ipv4); - - Object::AggregateObject (ipv4); - Object::AggregateObject (arp); - Object::AggregateObject (ipv4Impl); - Object::AggregateObject (udpImpl); - Object::AggregateObject (tcpImpl); - Object::AggregateObject (ipv4L4Demux); -} - -void -InternetNode::DoDispose() -{ - Node::DoDispose (); -} }//namespace ns3 diff --git a/src/internet-node/internet-node.h b/src/internet-node/internet-node.h index 20f743543..85ca02a84 100644 --- a/src/internet-node/internet-node.h +++ b/src/internet-node/internet-node.h @@ -58,13 +58,6 @@ class InternetNode : public Node { public: InternetNode(); - InternetNode(uint32_t systemId); - virtual ~InternetNode (); - -protected: - virtual void DoDispose(void); -private: - void Construct (void); }; }//namespace ns3 diff --git a/src/internet-node/internet-stack.cc b/src/internet-node/internet-stack.cc new file mode 100644 index 000000000..b427243dd --- /dev/null +++ b/src/internet-node/internet-stack.cc @@ -0,0 +1,78 @@ +// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- +// +// Copyright (c) 2006 Georgia Tech Research Corporation +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// Author: George F. Riley +// + +#include "ns3/net-device.h" +#include "ns3/callback.h" + +#include "ipv4-l4-demux.h" +#include "internet-node.h" +#include "udp-l4-protocol.h" +#include "tcp-l4-protocol.h" +#include "ipv4-l3-protocol.h" +#include "arp-l3-protocol.h" +#include "udp-impl.h" +#include "tcp-impl.h" +#include "ipv4-impl.h" + +namespace ns3 { + +void +AddInternetStack (Ptr node) +{ + Ptr ipv4 = CreateObject (); + Ptr arp = CreateObject (); + ipv4->SetNode (node); + arp->SetNode (node); + // XXX remove the PeekPointer below. + node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), + Ipv4L3Protocol::PROT_NUMBER, 0); + node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)), + ArpL3Protocol::PROT_NUMBER, 0); + + + Ptr ipv4L4Demux = CreateObject (); + Ptr udp = CreateObject (); + Ptr tcp = CreateObject (); + + ipv4L4Demux->SetNode (node); + udp->SetNode (node); + tcp->SetNode (node); + + ipv4L4Demux->Insert (udp); + ipv4L4Demux->Insert (tcp); + + Ptr udpImpl = CreateObject (); + Ptr tcpImpl = CreateObject (); + Ptr ipv4Impl = CreateObject (); + + udpImpl->SetUdp (udp); + tcpImpl->SetTcp (tcp); + ipv4Impl->SetIpv4 (ipv4); + + node->AggregateObject (ipv4); + node->AggregateObject (arp); + node->AggregateObject (ipv4Impl); + node->AggregateObject (udpImpl); + node->AggregateObject (tcpImpl); + node->AggregateObject (ipv4L4Demux); +} + +}//namespace ns3 diff --git a/src/internet-node/internet-stack.h b/src/internet-node/internet-stack.h new file mode 100644 index 000000000..e5d8c9191 --- /dev/null +++ b/src/internet-node/internet-stack.h @@ -0,0 +1,34 @@ +// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- +// +// Copyright (c) 2006 Georgia Tech Research Corporation +// All rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// Author: George F. Riley + +#ifndef INTERNET_STACK_H +#define INTERNET_STACK_H + +#include "ns3/ptr.h" + +namespace ns3 { + +class Node; + +void AddInternetStack (Ptr node); + +}//namespace ns3 + +#endif /* INTERNET_STACK_H */ diff --git a/src/internet-node/wscript b/src/internet-node/wscript index 15b0336a8..c48d3910d 100644 --- a/src/internet-node/wscript +++ b/src/internet-node/wscript @@ -5,6 +5,7 @@ def build(bld): obj = bld.create_ns3_module('internet-node', ['node']) obj.source = [ 'internet-node.cc', + 'internet-stack.cc', 'ipv4-l4-demux.cc', 'ipv4-l4-protocol.cc', 'ipv4-header.cc', @@ -39,6 +40,7 @@ def build(bld): headers.module = 'internet-node' headers.source = [ 'internet-node.h', + 'internet-stack.h', 'ascii-trace.h', 'pcap-trace.h', 'ipv4-header.h',