diff --git a/SConstruct b/SConstruct index f7d6b2ed8..1c7ba13fb 100644 --- a/SConstruct +++ b/SConstruct @@ -243,6 +243,7 @@ ns3.add (inode) inode.add_deps (['node']) inode.add_sources ([ 'internet-node.cc', + 'i-node-impl.cc', 'l3-demux.cc', 'l3-protocol.cc', 'ipv4-l4-demux.cc', @@ -296,7 +297,8 @@ inode.add_headers ([ 'ipv4-header.h', 'udp-header.h', 'ipv4-interface.h', - 'sgi-hashmap.h' + 'sgi-hashmap.h', + 'i-node-impl.h', ]) inode.add_inst_headers ([ 'internet-node.h', diff --git a/examples/simple-p2p.cc b/examples/simple-p2p.cc index 28028aeca..c206bbf51 100644 --- a/examples/simple-p2p.cc +++ b/examples/simple-p2p.cc @@ -100,10 +100,10 @@ int main (int argc, char *argv[]) // Here, we will explicitly create four nodes. In more sophisticated // topologies, we could configure a node factory. - Ptr n0 = MakeNewObject (); - Ptr n1 = MakeNewObject (); - Ptr n2 = MakeNewObject (); - Ptr n3 = MakeNewObject (); + Ptr n0 = MakeInternetNode (); + Ptr n1 = MakeInternetNode (); + Ptr n2 = MakeInternetNode (); + Ptr n3 = MakeInternetNode (); // We create the channels first without any IP addressing information Ptr channel0 = diff --git a/samples/main-simple.cc b/samples/main-simple.cc index 186035b97..98beb4a56 100644 --- a/samples/main-simple.cc +++ b/samples/main-simple.cc @@ -38,7 +38,7 @@ PrintTraffic (Ptr socket) void RunSimulation (void) { - Ptr a = MakeNewObject (); + Ptr a = MakeInternetNode (); Ptr udp = a->QueryInterface (IUdp::iid); diff --git a/src/internet-node/internet-node.cc b/src/internet-node/i-node-impl.cc similarity index 95% rename from src/internet-node/internet-node.cc rename to src/internet-node/i-node-impl.cc index bcda19190..b5b81390e 100644 --- a/src/internet-node/internet-node.cc +++ b/src/internet-node/i-node-impl.cc @@ -26,7 +26,7 @@ #include "l3-demux.h" #include "ipv4-l4-demux.h" -#include "internet-node.h" +#include "i-node-impl.h" #include "udp.h" #include "ipv4.h" #include "arp.h" @@ -39,6 +39,20 @@ namespace ns3 { InternetNode::InternetNode() +{ + Construct (); +} + +InternetNode::InternetNode(uint32_t systemId) +{ + Construct (); +} + +InternetNode::~InternetNode () +{} + +void +InternetNode::Construct (void) { Ptr ipv4 = MakeNewObject (this); Ptr arp = MakeNewObject (this); @@ -64,9 +78,6 @@ InternetNode::InternetNode() Interface::AddInterface (ipv4L4Demux); } -InternetNode::~InternetNode () -{} - void InternetNode::SetName (std::string name) { diff --git a/src/internet-node/internet-node.h b/src/internet-node/i-node-impl.h similarity index 92% rename from src/internet-node/internet-node.h rename to src/internet-node/i-node-impl.h index 51905a938..0784d872d 100644 --- a/src/internet-node/internet-node.h +++ b/src/internet-node/i-node-impl.h @@ -21,8 +21,8 @@ // Define a basic "Internet" node, with a protocol stack (l3 and l4), // network device list, process list, and routing. -#ifndef INTERNET_NODE_H -#define INTERNET_NODE_H +#ifndef I_NODE_IMPL_H +#define I_NODE_IMPL_H #include #include @@ -40,6 +40,7 @@ public: IPV4, }; InternetNode(); + InternetNode(uint32_t systemId); virtual ~InternetNode (); void SetName(std::string name); @@ -49,9 +50,10 @@ private: virtual void DoAddDevice (Ptr device) const; virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context); bool ReceiveFromDevice (Ptr device, const Packet &p, uint16_t protocolNumber) const; + void Construct (void); std::string m_name; }; }//namespace ns3 -#endif /* INTERNET_NODE_H */ +#endif /* I_NODE_IMPL_H */ diff --git a/src/node/i-node.h b/src/node/i-node.h index d8d5ffecc..b96fa632f 100644 --- a/src/node/i-node.h +++ b/src/node/i-node.h @@ -22,8 +22,8 @@ // Define the basic Node object for ns3. // George F. Riley, Georgia Tech, Fall 2006 -#ifndef __NODE_H__ -#define __NODE_H__ +#ifndef I_NODE_H +#define I_NODE_H #include @@ -169,4 +169,5 @@ private: }; } //namespace ns3 -#endif + +#endif /* I_NODE_H */