convert InternetNode to Attributes.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 27 Feb 2008 19:44:22 +0100
changeset 2498 e01570293b98
parent 2497 9dfbcd50df64
child 2499 806f6efe1c33
convert InternetNode to Attributes.
src/internet-node/arp-l3-protocol.cc
src/internet-node/arp-l3-protocol.h
src/internet-node/internet-node.cc
src/internet-node/internet-node.h
src/internet-node/ipv4-l3-protocol.cc
src/internet-node/ipv4-l3-protocol.h
src/internet-node/ipv4-l4-demux.cc
src/internet-node/ipv4-l4-demux.h
src/internet-node/ipv4-l4-protocol.cc
src/internet-node/ipv4-l4-protocol.h
src/internet-node/tcp-l4-protocol.cc
src/internet-node/tcp-l4-protocol.h
src/internet-node/udp-l4-protocol.cc
src/internet-node/udp-l4-protocol.h
--- a/src/internet-node/arp-l3-protocol.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/arp-l3-protocol.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -41,12 +41,17 @@
 ArpL3Protocol::GetTypeId (void)
 {
   static TypeId tid = TypeId ("ArpL3Protocol")
-    .SetParent<Object> ();
+    .SetParent<Object> ()
+    .AddAttribute ("Node", "The node to which this protocol is associated.",
+                   TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT,
+                   Ptr<Node> (0),
+                   MakePtrAccessor (&ArpL3Protocol::m_node),
+                   MakePtrChecker<Node> ())
+    ;
   return tid;
 }
 
-ArpL3Protocol::ArpL3Protocol (Ptr<Node> node)
-  : m_node (node)
+ArpL3Protocol::ArpL3Protocol ()
 {
   NS_LOG_FUNCTION;
 }
--- a/src/internet-node/arp-l3-protocol.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/arp-l3-protocol.h	Wed Feb 27 19:44:22 2008 +0100
@@ -46,7 +46,7 @@
    * \brief Constructor
    * \param node The node which this ARP object is associated with
    */
-  ArpL3Protocol (Ptr<Node> node);
+  ArpL3Protocol ();
   virtual ~ArpL3Protocol ();
   /**
    * \brief Recieve a packet
--- a/src/internet-node/internet-node.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/internet-node.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -21,7 +21,6 @@
 // Implementation of the InternetNode class for ns3.
 // George F. Riley, Georgia Tech, Fall 2006
 
-#include "ns3/composite-trace-resolver.h"
 #include "ns3/net-device.h"
 #include "ns3/callback.h"
 
@@ -53,8 +52,8 @@
 void
 InternetNode::Construct (void)
 {
-  Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> (this);
-  Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> (this);
+  Ptr<Ipv4L3Protocol> ipv4 = CreateObjectWith<Ipv4L3Protocol> ("Node", Ptr<Node> (this));
+  Ptr<ArpL3Protocol> arp = CreateObjectWith<ArpL3Protocol> ("Node", Ptr<Node> (this));
   // XXX remove the PeekPointer below.
   RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)), 
                            Ipv4L3Protocol::PROT_NUMBER, 0);
@@ -62,9 +61,9 @@
                            ArpL3Protocol::PROT_NUMBER, 0);
 
 
-  Ptr<Ipv4L4Demux> ipv4L4Demux = CreateObject<Ipv4L4Demux> (this);
-  Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> (this);
-  Ptr<TcpL4Protocol> tcp = CreateObject<TcpL4Protocol> (this);
+  Ptr<Ipv4L4Demux> ipv4L4Demux = CreateObjectWith<Ipv4L4Demux> ("Node", Ptr<Node> (this));
+  Ptr<UdpL4Protocol> udp = CreateObjectWith<UdpL4Protocol> ("Node", Ptr<Node> (this));
+  Ptr<TcpL4Protocol> tcp = CreateObjectWith<TcpL4Protocol> ("Node", Ptr<Node> (this));
 
   ipv4L4Demux->Insert (udp);
   ipv4L4Demux->Insert (tcp);
@@ -81,16 +80,6 @@
   Object::AggregateObject (ipv4L4Demux);
 }
 
-Ptr<TraceResolver>
-InternetNode::GetTraceResolver () const
-{
-  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
-  Ptr<Ipv4L3Protocol> ipv4 = GetObject<Ipv4L3Protocol> ();
-  resolver->AddComposite ("ipv4", ipv4);
-  resolver->SetParentResolver (Node::GetTraceResolver ());
-  return resolver;
-}
-
 void 
 InternetNode::DoDispose()
 {
--- a/src/internet-node/internet-node.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/internet-node.h	Wed Feb 27 19:44:22 2008 +0100
@@ -63,7 +63,6 @@
 
 protected:
   virtual void DoDispose(void);
-  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 private:
   void Construct (void);
 };
--- a/src/internet-node/ipv4-l3-protocol.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/ipv4-l3-protocol.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -21,12 +21,14 @@
 
 #include "ns3/packet.h"
 #include "ns3/log.h"
-#include "ns3/composite-trace-resolver.h"
 #include "ns3/callback.h"
 #include "ns3/ipv4-address.h"
 #include "ns3/ipv4-route.h"
 #include "ns3/node.h"
 #include "ns3/net-device.h"
+#include "ns3/uinteger.h"
+#include "ns3/trace-source-accessor.h"
+#include "ns3/object-vector.h"
 
 #include "ipv4-l3-protocol.h"
 #include "ipv4-l4-protocol.h"
@@ -48,123 +50,34 @@
 Ipv4L3Protocol::GetTypeId (void)
 {
   static TypeId tid = TypeId ("Ipv4L3Protocol")
-    .SetParent<Object> ();
+    .SetParent<Object> ()
+    .AddConstructor<Ipv4L3Protocol> ()
+    .AddAttribute ("DefaultTtl", "The TTL value set by default on all outgoing packets generated on this node.",
+                   Uinteger (64),
+                   MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl),
+                   MakeUintegerChecker<uint8_t> ())
+    .AddAttribute ("Node", "The node to which this l3 protocol is attached.",
+                   TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT,
+                   Ptr<Node> (0),
+                   MakePtrAccessor (&Ipv4L3Protocol::m_node),
+                   MakePtrChecker<Node> ())
+    .AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.",
+                   MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace))
+    .AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.",
+                     MakeTraceSourceAccessor (&Ipv4L3Protocol::m_rxTrace))
+    .AddTraceSource ("Drop", "Drop ipv4 packet",
+                     MakeTraceSourceAccessor (&Ipv4L3Protocol::m_dropTrace))
+    .AddAttribute ("Interfaces", "The set of Ipv4 interfaces associated to this Ipv4 stack.",
+                   ObjectVector (),
+                   MakeObjectVectorAccessor (&Ipv4L3Protocol::m_interfaces),
+                   MakeObjectVectorChecker ())
+    ;
   return tid;
 }
 
-Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement ()
-  : m_type (TX)
-{
-  NS_LOG_FUNCTION;
-}
-
-Ipv4L3ProtocolTraceContextElement::Ipv4L3ProtocolTraceContextElement (enum Type type)
-  : m_type (type)
-{
-  NS_LOG_FUNCTION;
-}
-
-bool 
-Ipv4L3ProtocolTraceContextElement::IsTx (void) const
-{
-  NS_LOG_FUNCTION;
-  return m_type == TX;
-}
-
-bool 
-Ipv4L3ProtocolTraceContextElement::IsRx (void) const
-{
-  NS_LOG_FUNCTION;
-  return m_type == RX;
-}
-
-bool 
-Ipv4L3ProtocolTraceContextElement::IsDrop (void) const
-{
-  NS_LOG_FUNCTION;
-  return m_type == DROP;
-}
-
-void 
-Ipv4L3ProtocolTraceContextElement::Print (std::ostream &os) const
-{
-  NS_LOG_FUNCTION;
-  os << "ipv4=";
-  switch (m_type)
-    {
-    case TX:
-      os << "tx";
-      break;
-    case RX:
-      os << "rx";
-      break;
-    case DROP:
-      os << "drop";
-      break;
-    }
-}
-
-uint16_t 
-Ipv4L3ProtocolTraceContextElement::GetUid (void)
-{
-  NS_LOG_FUNCTION;
-  static uint16_t uid = AllocateUid<Ipv4L3ProtocolTraceContextElement> ("Ipv4L3ProtocolTraceContextElement");
-  return uid;
-}
-
-std::string 
-Ipv4L3ProtocolTraceContextElement::GetTypeName (void) const
-{
-  NS_LOG_FUNCTION;
-  return "ns3::Ipv4L3ProtocolTraceContextElement";
-}
-
-Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex ()
-  : m_index (0)
-{
-  NS_LOG_FUNCTION;
-}
-
-Ipv4L3ProtocolInterfaceIndex::Ipv4L3ProtocolInterfaceIndex (uint32_t index)
-  : m_index (index)
-{
-  NS_LOG_FUNCTION;
-}
-
-uint32_t 
-Ipv4L3ProtocolInterfaceIndex::Get (void) const
-{
-  NS_LOG_FUNCTION;
-  return m_index;
-}
-
-void 
-Ipv4L3ProtocolInterfaceIndex::Print (std::ostream &os) const
-{
-  os << "ipv4-interface=" << m_index;
-}
-
-uint16_t 
-Ipv4L3ProtocolInterfaceIndex::GetUid (void)
-{
-  NS_LOG_FUNCTION;
-  static uint16_t uid = AllocateUid<Ipv4L3ProtocolInterfaceIndex> ("Ipv4L3ProtocolInterfaceIndex");
-  return uid;
-}
-
-std::string
-Ipv4L3ProtocolInterfaceIndex::GetTypeName (void) const
-{
-  NS_LOG_FUNCTION;
-  return "ns3::Ipv4L3ProtocolInterfaceIndex";
-}
-
-
-Ipv4L3Protocol::Ipv4L3Protocol(Ptr<Node> node)
+Ipv4L3Protocol::Ipv4L3Protocol()
   : m_nInterfaces (0),
-    m_defaultTtl (64),
-    m_identification (0),
-    m_node (node)
+    m_identification (0)
 {
   NS_LOG_FUNCTION;
   m_staticRouting = CreateObject<Ipv4StaticRouting> ();
@@ -201,32 +114,6 @@
   interface->SetUp ();
 }
 
-Ptr<TraceResolver>
-Ipv4L3Protocol::GetTraceResolver (void) const
-{
-  NS_LOG_FUNCTION;
-
-  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
-  resolver->AddSource ("tx", 
-                       TraceDoc ("send ipv4 packet to outgoing interface",
-                                 "Ptr<const Packet>", "packet sent",
-                                 "uint32_t", "index of output ipv4 interface"),
-                       m_txTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::TX));
-  resolver->AddSource ("rx",
-                       TraceDoc ("receive ipv4 packet from incoming interface",
-                                 "Ptr<const Packet>", "packet received",
-                                 "uint32_t", "index of input ipv4 interface"),
-                       m_rxTrace, Ipv4L3ProtocolTraceContextElement(Ipv4L3ProtocolTraceContextElement::RX));
-  resolver->AddSource ("drop", 
-                       TraceDoc ("drop ipv4 packet",
-                                 "Ptr<const Packet>", "packet dropped"),
-                       m_dropTrace, Ipv4L3ProtocolTraceContextElement (Ipv4L3ProtocolTraceContextElement::DROP));
-  resolver->AddArray ("interfaces", 
-                      m_interfaces.begin (), m_interfaces.end (), 
-                      Ipv4L3ProtocolInterfaceIndex ());
-  return resolver;
-}
-
 void 
 Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl)
 {
--- a/src/internet-node/ipv4-l3-protocol.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/ipv4-l3-protocol.h	Wed Feb 27 19:44:22 2008 +0100
@@ -24,11 +24,10 @@
 
 #include <list>
 #include <stdint.h>
-#include "ns3/callback-trace-source.h"
-#include "ns3/trace-context-element.h"
 #include "ns3/ipv4-address.h"
 #include "ns3/ptr.h"
 #include "ns3/ipv4.h"
+#include "ns3/traced-callback.h"
 #include "ipv4-header.h"
 #include "ipv4-static-routing.h"
 
@@ -41,59 +40,6 @@
 class Ipv4Header;
 class Ipv4Route;
 class Node;
-class TraceResolver;
-class TraceContext;
-
-/**
- * \brief hold in a TraceContext the type of trace source used by this Ipv4L3Protocol
- */
-class Ipv4L3ProtocolTraceContextElement : public TraceContextElement
-{
-public:
-  enum Type {
-    TX,
-    RX,
-    DROP,
-  };
-  Ipv4L3ProtocolTraceContextElement ();
-  Ipv4L3ProtocolTraceContextElement (enum Type type);
-  /**
-   * \returns true if this is a tx event, false otherwise.
-   */
-  bool IsTx (void) const;
-  /**
-   * \returns true if this is a rx event, false otherwise.
-   */
-  bool IsRx (void) const;
-  /**
-   * \returns true if this is a drop event, false otherwise.
-   */
-  bool IsDrop (void) const;
-  void Print (std::ostream &os) const;
-  static uint16_t GetUid (void);
-  std::string GetTypeName (void) const;
-private:
-  enum Type m_type;
-};
-
-/**
- * \brief hold in a TraceContext the index of an Ipv4Interface within the ipv4 stack of a Node
- */
-class Ipv4L3ProtocolInterfaceIndex : public TraceContextElement
-{
-public:
-  Ipv4L3ProtocolInterfaceIndex ();
-  Ipv4L3ProtocolInterfaceIndex (uint32_t index);
-  /**
-   * \returns the index of the Ipv4Interface within a Node.
-   */
-  uint32_t Get (void) const;
-  void Print (std::ostream &os) const;
-  static uint16_t GetUid (void);
-  std::string GetTypeName (void) const;
-private:
-  uint32_t m_index;
-};
 
 
 class Ipv4L3Protocol : public Object
@@ -102,7 +48,7 @@
   static TypeId GetTypeId (void);
   static const uint16_t PROT_NUMBER;
 
-  Ipv4L3Protocol(Ptr<Node> node);
+  Ipv4L3Protocol();
   virtual ~Ipv4L3Protocol ();
 
   /**
@@ -213,7 +159,6 @@
 protected:
 
   virtual void DoDispose (void);
-  virtual Ptr<TraceResolver> GetTraceResolver (void) const;
 
 private:
   void Lookup (uint32_t ifIndex,
@@ -243,9 +188,9 @@
   uint8_t m_defaultTtl;
   uint16_t m_identification;
   Ptr<Node> m_node;
-  CallbackTraceSource<Ptr<const Packet>, uint32_t> m_txTrace;
-  CallbackTraceSource<Ptr<const Packet>, uint32_t> m_rxTrace;
-  CallbackTraceSource<Ptr<const Packet> > m_dropTrace;
+  TracedCallback<Ptr<const Packet>, uint32_t> m_txTrace;
+  TracedCallback<Ptr<const Packet>, uint32_t> m_rxTrace;
+  TracedCallback<Ptr<const Packet> > m_dropTrace;
 
   Ipv4RoutingProtocolList m_routingProtocols;
 
--- a/src/internet-node/ipv4-l4-demux.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/ipv4-l4-demux.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -23,8 +23,8 @@
 // George F. Riley, Georgia Tech, Fall 2006
 
 #include <sstream>
-#include "ns3/composite-trace-resolver.h"
 #include "ns3/node.h"
+#include "ns3/object-vector.h"
 #include "ipv4-l4-demux.h"
 #include "ipv4-l4-protocol.h"
 
@@ -32,44 +32,24 @@
 
 NS_OBJECT_ENSURE_REGISTERED (Ipv4L4Demux);
 
-Ipv4L4ProtocolTraceContextElement::Ipv4L4ProtocolTraceContextElement ()
-  : m_protocolNumber (0)
-{}
-Ipv4L4ProtocolTraceContextElement::Ipv4L4ProtocolTraceContextElement (int protocolNumber)
-  : m_protocolNumber (protocolNumber)
-{}
-int 
-Ipv4L4ProtocolTraceContextElement::Get (void) const
-{
-  return m_protocolNumber;
-}
-void 
-Ipv4L4ProtocolTraceContextElement::Print (std::ostream &os) const
-{
-  os << "ipv4-protocol=0x" << std::hex << m_protocolNumber << std::dec;
-}
-uint16_t 
-Ipv4L4ProtocolTraceContextElement::GetUid (void)
-{
-  static uint16_t uid = AllocateUid<Ipv4L4ProtocolTraceContextElement> ("Ipv4L4ProtocolTraceContextElement");
-  return uid;
-}
-std::string 
-Ipv4L4ProtocolTraceContextElement::GetTypeName (void) const
-{
-  return "ns3::Ipv4L4ProtocolTraceContextElement";
-}
-
 TypeId 
 Ipv4L4Demux::GetTypeId (void)
 {
   static TypeId tid = TypeId ("Ipv4L4Demux")
-    .SetParent<Object> ();
+    .SetParent<Object> ()
+    .AddAttribute ("Node", "The node to which this object is associated.",
+                   Ptr<Node> (0),
+                   MakePtrAccessor (&Ipv4L4Demux::m_node),
+                   MakePtrChecker<Node> ())
+    .AddAttribute ("Protocols", "The set of protocols registered with this demux.",
+                   ObjectVector (),
+                   MakeObjectVectorAccessor (&Ipv4L4Demux::m_protocols),
+                   MakeObjectVectorChecker ())
+    ;
   return tid;
 }
 
-Ipv4L4Demux::Ipv4L4Demux (Ptr<Node> node)
-  : m_node (node)
+Ipv4L4Demux::Ipv4L4Demux ()
 {}
 
 Ipv4L4Demux::~Ipv4L4Demux()
@@ -88,21 +68,6 @@
   Object::DoDispose ();
 }
 
-Ptr<TraceResolver>
-Ipv4L4Demux::GetTraceResolver (void) const
-{
-  Ptr<CompositeTraceResolver> resolver = Create<CompositeTraceResolver> ();
-  for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i)
-    {
-      Ptr<Ipv4L4Protocol> protocol = *i;
-      std::ostringstream oss;
-      oss << (unsigned int) (*i)->GetProtocolNumber ();
-      Ipv4L4ProtocolTraceContextElement protocolNumber = (*i)->GetProtocolNumber ();
-      resolver->AddComposite (oss.str (), protocol, protocolNumber);
-    }
-  resolver->SetParentResolver (Object::GetTraceResolver ());
-  return resolver;
-}
 void
 Ipv4L4Demux::Insert(Ptr<Ipv4L4Protocol> protocol)
 {
--- a/src/internet-node/ipv4-l4-demux.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/ipv4-l4-demux.h	Wed Feb 27 19:44:22 2008 +0100
@@ -28,42 +28,21 @@
 #include <list>
 #include "ns3/object.h"
 #include "ns3/ptr.h"
-#include "ns3/trace-context-element.h"
 
 namespace ns3 {
 
 class Ipv4L4Protocol;
 class Node;
-class TraceResolver;
 class TraceContext;
 
 /**
- * \brief hold in a TraceContext the protocol number of a L4 Protocol
- */
-class Ipv4L4ProtocolTraceContextElement : public TraceContextElement
-{
-public:
-  Ipv4L4ProtocolTraceContextElement ();
-  Ipv4L4ProtocolTraceContextElement (int protocolNumber);
-  /**
-   * \returns the protocol number as registered in the Ipv4L4Demux.
-   */
-  int Get (void) const;
-  void Print (std::ostream &os) const;
-  static uint16_t GetUid (void);
-  std::string GetTypeName (void) const;
-private:
-  int m_protocolNumber;
-};
-
-/**
  * \brief L4 Ipv4 Demux
  */
 class Ipv4L4Demux : public Object
 {
 public:
   static TypeId GetTypeId (void);
-  Ipv4L4Demux (Ptr<Node> node);
+  Ipv4L4Demux ();
   virtual ~Ipv4L4Demux();
 
   /**
@@ -95,7 +74,6 @@
    */
   void Remove (Ptr<Ipv4L4Protocol> protocol);
 protected:
-  Ptr<TraceResolver> GetTraceResolver (void) const;
   virtual void DoDispose (void);
 private:
   typedef std::list<Ptr<Ipv4L4Protocol> > L4List_t;
--- a/src/internet-node/ipv4-l4-protocol.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/ipv4-l4-protocol.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -23,32 +23,28 @@
 // George F. Riley, Georgia Tech, Spring 2007
 
 #include "ipv4-l4-protocol.h"
+#include "ns3/uinteger.h"
 
 namespace ns3 {
 
+TypeId 
+Ipv4L4Protocol::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("Ipv4L4Protocol")
+    .SetParent<Object> ()
+    .AddAttribute ("ProtocolNumber", "The Ipv4 protocol number.",
+                   Uinteger (0),
+                   MakeUintegerAccessor (&Ipv4L4Protocol::GetProtocolNumber),
+                   MakeUintegerChecker<int> ())
+    .AddAttribute ("Version", "The version of the protocol.",
+                   Uinteger (0),
+                   MakeUintegerAccessor (&Ipv4L4Protocol::GetVersion),
+                   MakeUintegerChecker<int> ())
+    ;
+  return tid;
+}
 
-Ipv4L4Protocol::Ipv4L4Protocol(int protocolNumber, int version)
-  : m_protocolNumber (protocolNumber),
-    m_version (version)
-{}
 Ipv4L4Protocol::~Ipv4L4Protocol ()
 {}
 
-int 
-Ipv4L4Protocol::GetProtocolNumber (void) const
-{
-  return m_protocolNumber;
-}
-int 
-Ipv4L4Protocol::GetVersion() const
-{
-  return m_version;
-}
-
-void 
-Ipv4L4Protocol::DoDispose (void)
-{
-  Object::DoDispose ();
-}
-
 }//namespace ns3
--- a/src/internet-node/ipv4-l4-protocol.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/ipv4-l4-protocol.h	Wed Feb 27 19:44:22 2008 +0100
@@ -44,17 +44,18 @@
 class Ipv4L4Protocol : public Object
 {
 public:
-  Ipv4L4Protocol(int protocolNumber, int version);
+  static TypeId GetTypeId (void);
+
   virtual ~Ipv4L4Protocol ();
 
   /**
    * \returns the protocol number of this protocol.
    */
-  int GetProtocolNumber (void) const;
+  virtual int GetProtocolNumber (void) const = 0;
   /**
    * \returns the version number of this protocol.
    */
-  int GetVersion() const;
+  virtual int GetVersion (void) const = 0;
 
   /**
    * \param p packet to forward up
@@ -69,11 +70,6 @@
                        Ipv4Address const &source,
                        Ipv4Address const &destination,
                        Ptr<Ipv4Interface> incomingInterface) = 0;
-protected:
-  virtual void DoDispose (void);
-private:
-  int m_protocolNumber;
-  int m_version;
 };
 
 } // Namespace ns3
--- a/src/internet-node/tcp-l4-protocol.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/tcp-l4-protocol.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -309,20 +309,42 @@
 /* see http://www.iana.org/assignments/protocol-numbers */
 const uint8_t TcpL4Protocol::PROT_NUMBER = 6;
 
-TcpL4Protocol::TcpL4Protocol (Ptr<Node> node)
-  : Ipv4L4Protocol (PROT_NUMBER, 2),
-    m_node (node),
-    m_endPoints (new Ipv4EndPointDemux ())
+TypeId 
+TcpL4Protocol::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("TcpL4Protocol")
+    .SetParent<Ipv4L4Protocol> ()
+    .AddAttribute ("Node", "The node to which this protocol is associated",
+                   TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT,
+                   Ptr<Node> (0),
+                   MakePtrAccessor (&TcpL4Protocol::m_node),
+                   MakePtrChecker<Node> ())
+    ;
+  return tid;
+}
+
+TcpL4Protocol::TcpL4Protocol ()
+  : m_endPoints (new Ipv4EndPointDemux ())
 {
   NS_LOG_FUNCTION;
-  NS_LOG_PARAMS (this << node);
   NS_LOG_LOGIC("Made a TcpL4Protocol "<<this);
 }
 
 TcpL4Protocol::~TcpL4Protocol ()
 {
   NS_LOG_FUNCTION;
- }
+}
+
+int 
+TcpL4Protocol::GetProtocolNumber (void) const
+{
+  return PROT_NUMBER;
+}
+int 
+TcpL4Protocol::GetVersion (void) const
+{
+  return 2;
+}
 
 void
 TcpL4Protocol::DoDispose (void)
--- a/src/internet-node/tcp-l4-protocol.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/tcp-l4-protocol.h	Wed Feb 27 19:44:22 2008 +0100
@@ -45,14 +45,17 @@
  */
 class TcpL4Protocol : public Ipv4L4Protocol {
 public:
+  static TypeId GetTypeId (void);
   static const uint8_t PROT_NUMBER;
   /**
    * \brief Constructor
-   * \param node The node this protocol is associated with
    */
-  TcpL4Protocol (Ptr<Node> node);
+  TcpL4Protocol ();
   virtual ~TcpL4Protocol ();
 
+  virtual int GetProtocolNumber (void) const;
+  virtual int GetVersion (void) const;
+
   /**
    * \return A smart Socket pointer to a TcpSocket, allocated by this instance
    * of the TCP protocol
--- a/src/internet-node/udp-l4-protocol.cc	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/udp-l4-protocol.cc	Wed Feb 27 19:44:22 2008 +0100
@@ -38,10 +38,23 @@
 /* see http://www.iana.org/assignments/protocol-numbers */
 const uint8_t UdpL4Protocol::PROT_NUMBER = 17;
 
-UdpL4Protocol::UdpL4Protocol (Ptr<Node> node)
-  : Ipv4L4Protocol (PROT_NUMBER, 2),
-    m_node (node),
-    m_endPoints (new Ipv4EndPointDemux ())
+TypeId 
+UdpL4Protocol::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("UdpL4Protocol")
+    .SetParent<Ipv4L4Protocol> ()
+    .AddConstructor<UdpL4Protocol> ()
+    .AddAttribute ("Node", "The node which contains this protocol.",
+                   TypeId::ATTR_GET | TypeId::ATTR_CONSTRUCT,
+                   Ptr<Node> (0),
+                   MakePtrAccessor (&UdpL4Protocol::m_node),
+                   MakePtrChecker<Node> ())
+    ;
+  return tid;
+}
+
+UdpL4Protocol::UdpL4Protocol ()
+  : m_endPoints (new Ipv4EndPointDemux ())
 {
   NS_LOG_FUNCTION;
 }
@@ -51,6 +64,18 @@
   NS_LOG_FUNCTION;
 }
 
+int 
+UdpL4Protocol::GetProtocolNumber (void) const
+{
+  return PROT_NUMBER;
+}
+int 
+UdpL4Protocol::GetVersion (void) const
+{
+  return 2;
+}
+
+
 void
 UdpL4Protocol::DoDispose (void)
 {
--- a/src/internet-node/udp-l4-protocol.h	Wed Feb 27 19:36:03 2008 +0100
+++ b/src/internet-node/udp-l4-protocol.h	Wed Feb 27 19:44:22 2008 +0100
@@ -41,14 +41,18 @@
  */
 class UdpL4Protocol : public Ipv4L4Protocol {
 public:
+  static TypeId GetTypeId (void);
   static const uint8_t PROT_NUMBER;
   /**
    * \brief Constructor
    * \param node The node this protocol is associated with
    */
-  UdpL4Protocol (Ptr<Node> node);
+  UdpL4Protocol ();
   virtual ~UdpL4Protocol ();
 
+  virtual int GetProtocolNumber (void) const;
+  virtual int GetVersion (void) const;
+
   /**
    * \return A smart Socket pointer to a UdpSocket, allocated by this instance
    * of the UDP protocol