define a TypeId for each Header/Trailer.
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Mon, 17 Mar 2008 13:12:17 -0700
changeset 2643 2a3324f4dabe
parent 2642 a35a68bdcd88
child 2644 b50c3f20ab88
define a TypeId for each Header/Trailer.
samples/main-packet-header.cc
src/common/header.cc
src/common/header.h
src/common/packet-metadata-test.cc
src/common/trailer.cc
src/common/trailer.h
src/devices/wifi/mgt-headers.cc
src/devices/wifi/mgt-headers.h
src/devices/wifi/wifi-mac-header.cc
src/devices/wifi/wifi-mac-header.h
src/devices/wifi/wifi-mac-trailer.cc
src/devices/wifi/wifi-mac-trailer.h
src/internet-node/arp-header.cc
src/internet-node/arp-header.h
src/internet-node/ipv4-header.cc
src/internet-node/ipv4-header.h
src/internet-node/tcp-header.cc
src/internet-node/tcp-header.h
src/internet-node/udp-header.cc
src/internet-node/udp-header.h
src/node/ethernet-header.cc
src/node/ethernet-header.h
src/node/ethernet-trailer.cc
src/node/ethernet-trailer.h
src/node/llc-snap-header.cc
src/node/llc-snap-header.h
src/routing/olsr/olsr-header.cc
src/routing/olsr/olsr-header.h
utils/bench-packets.cc
--- a/samples/main-packet-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/samples/main-packet-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -19,11 +19,13 @@
   void SetData (uint16_t data);
   uint16_t GetData (void) const;
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
-  uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
 private:
   uint16_t m_data;
 };
@@ -36,6 +38,20 @@
 MyHeader::~MyHeader ()
 {}
 
+TypeId 
+MyHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MyHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+MyHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 MyHeader::GetUid (void)
 {
--- a/src/common/header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/common/header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -2,7 +2,18 @@
 
 namespace ns3 {
 
+NS_OBJECT_ENSURE_REGISTERED (Header);
+
 Header::~Header ()
 {}
 
+TypeId 
+Header::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::Header")
+    .SetParent<ObjectBase> ()
+    ;
+  return tid;
+}
+
 } // namespace ns3
--- a/src/common/header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/common/header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -23,6 +23,7 @@
 #define HEADER_H
 
 #include "chunk-registry.h"
+#include "ns3/object-base.h"
 
 /**
  * \relates ns3::Header
@@ -75,9 +76,10 @@
  * Sample code which shows how to create a new type of Header, and how to use it, 
  * is shown in the sample file samples/main-packet-header.cc
  */
-class Header
+class Header : public ObjectBase
 {
 public:
+  static TypeId GetTypeId (void);
   virtual ~Header ();
   /**
    * \returns the expected size of the header.
--- a/src/common/packet-metadata-test.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/common/packet-metadata-test.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -34,6 +34,8 @@
 class HistoryHeader : public Header
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   HistoryHeader ();
   bool IsOk (void) const;
@@ -47,6 +49,25 @@
 };
 
 template <int N>
+TypeId
+HistoryHeader<N>::GetTypeId (void)
+{
+  std::ostringstream oss;
+  oss << "ns3::HistoryHeader<"<<N<<">";
+  static TypeId tid = TypeId (oss.str ().c_str ())
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+
+template <int N>
+TypeId 
+HistoryHeader<N>::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+template <int N>
 uint32_t
 HistoryHeader<N>::GetUid (void)
 {
@@ -114,6 +135,8 @@
 class HistoryTrailer : public Trailer
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   HistoryTrailer ();
   bool IsOk (void) const;
@@ -126,6 +149,26 @@
   bool m_ok;
 };
 
+
+template <int N>
+TypeId
+HistoryTrailer<N>::GetTypeId (void)
+{
+  std::ostringstream oss;
+  oss << "ns3::HistoryTrailer<"<<N<<">";
+  static TypeId tid = TypeId (oss.str ().c_str ())
+    .SetParent<Trailer> ()
+    ;
+  return tid;
+}
+
+template <int N>
+TypeId 
+HistoryTrailer<N>::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 template <int N>
 uint32_t
 HistoryTrailer<N>::GetUid (void)
--- a/src/common/trailer.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/common/trailer.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -2,7 +2,18 @@
 
 namespace ns3 {
 
+NS_OBJECT_ENSURE_REGISTERED (Trailer);
+
 Trailer::~Trailer ()
 {}
 
+TypeId 
+Trailer::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::Trailer")
+    .SetParent<ObjectBase> ()
+    ;
+  return tid;
+}
+
 } // namespace ns3
--- a/src/common/trailer.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/common/trailer.h	Mon Mar 17 13:12:17 2008 -0700
@@ -22,6 +22,7 @@
 #ifndef TRAILER_H
 #define TRAILER_H
 
+#include "ns3/object-base.h"
 #include "chunk-registry.h"
 #include "buffer.h"
 #include <stdint.h>
@@ -74,9 +75,10 @@
  *     single word as all capitalized letters.
  *
  */
-class Trailer 
+class Trailer : public ObjectBase
 {
 public:
+  static TypeId GetTypeId (void);
   virtual ~Trailer ();
   /**
    * \returns the expected size of the trailer.
--- a/src/devices/wifi/mgt-headers.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/devices/wifi/mgt-headers.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -27,6 +27,8 @@
  *          Probe Request
  ***********************************************************/
 
+NS_OBJECT_ENSURE_REGISTERED (MgtProbeRequestHeader);
+
 MgtProbeRequestHeader::~MgtProbeRequestHeader ()
 {}
 
@@ -59,6 +61,19 @@
   size += m_rates.GetSerializedSize ();
   return size;
 }
+TypeId 
+MgtProbeRequestHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MgtProbeRequestHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+MgtProbeRequestHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 uint32_t
 MgtProbeRequestHeader::GetUid (void)
 {
@@ -97,6 +112,8 @@
  *          Probe Response
  ***********************************************************/
 
+NS_OBJECT_ENSURE_REGISTERED (MgtProbeResponseHeader);
+
 MgtProbeResponseHeader::MgtProbeResponseHeader ()
 {}
 MgtProbeResponseHeader::~MgtProbeResponseHeader ()
@@ -133,6 +150,19 @@
 {
   m_rates = rates;
 }
+TypeId 
+MgtProbeResponseHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MgtProbeResponseHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+MgtProbeResponseHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 uint32_t
 MgtProbeResponseHeader::GetUid (void)
 {
@@ -198,6 +228,11 @@
   return i.GetDistanceFrom (start);
 }
 
+/***********************************************************
+ *          Assoc Request
+ ***********************************************************/
+
+NS_OBJECT_ENSURE_REGISTERED (MgtAssocRequestHeader);
 
 MgtAssocRequestHeader::MgtAssocRequestHeader ()
 {}
@@ -234,6 +269,20 @@
 {
   return m_listenInterval;
 }
+
+TypeId 
+MgtAssocRequestHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MgtAssocRequestHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+MgtAssocRequestHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 uint32_t
 MgtAssocRequestHeader::GetUid (void)
 {
@@ -281,6 +330,12 @@
   return i.GetDistanceFrom (start);
 }
 
+/***********************************************************
+ *          Assoc Response
+ ***********************************************************/
+
+NS_OBJECT_ENSURE_REGISTERED (MgtAssocResponseHeader);
+
 MgtAssocResponseHeader::MgtAssocResponseHeader ()
 {}
 MgtAssocResponseHeader::~MgtAssocResponseHeader ()
@@ -307,6 +362,19 @@
   m_rates = rates;
 }
 
+TypeId 
+MgtAssocResponseHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MgtAssocResponseHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+MgtAssocResponseHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 uint32_t
 MgtAssocResponseHeader::GetUid (void)
 {
--- a/src/devices/wifi/mgt-headers.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/devices/wifi/mgt-headers.h	Mon Mar 17 13:12:17 2008 -0700
@@ -44,12 +44,14 @@
   SupportedRates GetSupportedRates (void) const;
   uint16_t GetListenInterval (void) const;
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 
 private:
   Ssid m_ssid;
@@ -69,12 +71,14 @@
   void SetSupportedRates (SupportedRates rates);
   void SetStatusCode (StatusCode code);
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 
 private:
   SupportedRates m_rates;
@@ -92,12 +96,14 @@
   Ssid GetSsid (void) const;
   SupportedRates GetSupportedRates (void) const;
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 private:
 
   Ssid m_ssid;
@@ -117,12 +123,14 @@
   void SetBeaconIntervalUs (uint64_t us);
   void SetSupportedRates (SupportedRates rates);
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 
 private:
   Ssid m_ssid;
--- a/src/devices/wifi/wifi-mac-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/devices/wifi/wifi-mac-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -34,6 +34,8 @@
 
 namespace ns3 {
 
+NS_OBJECT_ENSURE_REGISTERED (WifiMacHeader);
+
 enum {
   TYPE_MGT = 0,
   TYPE_CTL  = 1,
@@ -766,6 +768,19 @@
   return "BIG_ERROR";
 }
 
+TypeId 
+WifiMacHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::WifiMacHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+WifiMacHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 uint32_t
 WifiMacHeader::GetUid (void)
 {
--- a/src/devices/wifi/wifi-mac-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/devices/wifi/wifi-mac-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -65,14 +65,18 @@
 class WifiMacHeader : public Header 
 {
 public:
+
   WifiMacHeader ();
   ~WifiMacHeader ();
+
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 
 
   void SetAssocReq (void);
--- a/src/devices/wifi/wifi-mac-trailer.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/devices/wifi/wifi-mac-trailer.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -22,12 +22,28 @@
 
 namespace ns3 {
 
+NS_OBJECT_ENSURE_REGISTERED (WifiMacTrailer);
+
 WifiMacTrailer::WifiMacTrailer ()
 {}
 
 WifiMacTrailer::~WifiMacTrailer ()
 {}
 
+TypeId 
+WifiMacTrailer::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::WifiMacTrailer")
+    .SetParent<Trailer> ()
+    ;
+  return tid;
+}
+TypeId 
+WifiMacTrailer::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 WifiMacTrailer::GetUid (void)
 {
--- a/src/devices/wifi/wifi-mac-trailer.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/devices/wifi/wifi-mac-trailer.h	Mon Mar 17 13:12:17 2008 -0700
@@ -31,12 +31,14 @@
   WifiMacTrailer ();
   ~WifiMacTrailer ();
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 };
 
 } // namespace ns3
--- a/src/internet-node/arp-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/arp-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -26,6 +26,21 @@
 namespace ns3 {
 
 NS_HEADER_ENSURE_REGISTERED (ArpHeader);
+NS_OBJECT_ENSURE_REGISTERED (ArpHeader);
+
+TypeId 
+ArpHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::ArpHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+ArpHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 
 uint32_t
 ArpHeader::GetUid (void)
--- a/src/internet-node/arp-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/arp-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -34,6 +34,8 @@
 class ArpHeader : public Header 
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
 
   void SetRequest (Address sourceHardwareAddress,
--- a/src/internet-node/ipv4-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/ipv4-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -29,9 +29,24 @@
 namespace ns3 {
 
 NS_HEADER_ENSURE_REGISTERED (Ipv4Header);
+NS_OBJECT_ENSURE_REGISTERED (Ipv4Header);
 
 bool Ipv4Header::m_calcChecksum = false;
 
+TypeId 
+Ipv4Header::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::Ipv4Header")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+Ipv4Header::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 Ipv4Header::GetUid (void)
 {
--- a/src/internet-node/ipv4-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/ipv4-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -32,6 +32,8 @@
 class Ipv4Header : public Header 
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   /**
    * \brief Construct a null IPv4 header
@@ -142,9 +144,9 @@
 
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 private:
 
   enum FlagsE {
--- a/src/internet-node/tcp-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/tcp-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -27,9 +27,24 @@
 namespace ns3 {
 
 NS_HEADER_ENSURE_REGISTERED (TcpHeader);
+NS_OBJECT_ENSURE_REGISTERED (TcpHeader);
 
 bool TcpHeader::m_calcChecksum = false;
 
+TypeId 
+TcpHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::TcpHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+TcpHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 TcpHeader::GetUid (void)
 {
--- a/src/internet-node/tcp-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/tcp-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -30,8 +30,11 @@
 
 namespace ns3 {
 
-class TcpHeader : public Header {
+class TcpHeader : public Header 
+{
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
 
   TcpHeader ();
@@ -138,9 +141,9 @@
 
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 
 private:
   uint16_t m_sourcePort;
--- a/src/internet-node/udp-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/udp-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -25,9 +25,24 @@
 namespace ns3 {
 
 NS_HEADER_ENSURE_REGISTERED (UdpHeader);
+NS_OBJECT_ENSURE_REGISTERED (UdpHeader);
 
 bool UdpHeader::m_calcChecksum = false;
 
+TypeId 
+UdpHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::UdpHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+UdpHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 UdpHeader::GetUid (void)
 {
--- a/src/internet-node/udp-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/internet-node/udp-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -34,6 +34,8 @@
 class UdpHeader : public Header 
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
 
   /**
@@ -86,9 +88,9 @@
 
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 
 private:
   uint16_t m_sourcePort;
--- a/src/node/ethernet-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/node/ethernet-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -32,6 +32,21 @@
 namespace ns3 {
 
 NS_HEADER_ENSURE_REGISTERED (EthernetHeader);
+NS_OBJECT_ENSURE_REGISTERED (EthernetHeader);
+
+TypeId 
+EthernetHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::EthernetHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+EthernetHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 
 uint32_t
 EthernetHeader::GetUid (void)
--- a/src/node/ethernet-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/node/ethernet-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -49,6 +49,8 @@
 class EthernetHeader : public Header 
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
 
   /**
@@ -105,9 +107,9 @@
 
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 private:
   static const int PREAMBLE_SIZE = 8; /// size of the preamble_sfd header field
   static const int LENGTH_SIZE = 2;   /// size of the length_type header field
--- a/src/node/ethernet-trailer.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/node/ethernet-trailer.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -29,9 +29,24 @@
 namespace ns3 {
 
 NS_TRAILER_ENSURE_REGISTERED (EthernetTrailer);
+NS_OBJECT_ENSURE_REGISTERED (EthernetTrailer);
 
 bool EthernetTrailer::m_calcFcs = false;
 
+TypeId 
+EthernetTrailer::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::EthernetTrailer")
+    .SetParent<Trailer> ()
+    ;
+  return tid;
+}
+TypeId 
+EthernetTrailer::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 EthernetTrailer::GetUid (void)
 {
--- a/src/node/ethernet-trailer.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/node/ethernet-trailer.h	Mon Mar 17 13:12:17 2008 -0700
@@ -39,6 +39,8 @@
 class EthernetTrailer : public Trailer 
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
 
   /**
--- a/src/node/llc-snap-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/node/llc-snap-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -26,6 +26,21 @@
 namespace ns3 {
 
 NS_HEADER_ENSURE_REGISTERED (LlcSnapHeader);
+NS_OBJECT_ENSURE_REGISTERED (LlcSnapHeader);
+
+TypeId 
+LlcSnapHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::LlcSnapHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId 
+LlcSnapHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
 
 uint32_t
 LlcSnapHeader::GetUid (void)
--- a/src/node/llc-snap-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/node/llc-snap-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -31,6 +31,8 @@
 class LlcSnapHeader : public Header 
 {
 public:
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
 
   LlcSnapHeader ();
@@ -40,9 +42,9 @@
 
   std::string GetName (void) const;
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 private:
   uint16_t m_etherType;
 };
--- a/src/routing/olsr/olsr-header.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/routing/olsr/olsr-header.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -33,7 +33,6 @@
 
 NS_LOG_COMPONENT_DEFINE("OlsrHeader");
 
-
 /// Scaling factor used in RFC 3626.
 #define OLSR_C 0.0625
 
@@ -95,12 +94,28 @@
 
 // ---------------- OLSR Packet -------------------------------
 
+NS_OBJECT_ENSURE_REGISTERED (PacketHeader);
+
 PacketHeader::PacketHeader ()
 {}
 
 PacketHeader::~PacketHeader ()
 {}
 
+TypeId
+PacketHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::olsr::PacketHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId
+PacketHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 PacketHeader::GetUid (void)
 {
@@ -141,6 +156,8 @@
 
 // ---------------- OLSR Message -------------------------------
 
+NS_OBJECT_ENSURE_REGISTERED (MessageHeader);
+
 MessageHeader::MessageHeader ()
   : m_messageType (MessageHeader::MessageType (0))
 {}
@@ -148,6 +165,20 @@
 MessageHeader::~MessageHeader ()
 {}
 
+TypeId
+MessageHeader::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::olsr::MessageHeader")
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+TypeId
+MessageHeader::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
 uint32_t
 MessageHeader::GetUid (void)
 {
--- a/src/routing/olsr/olsr-header.h	Mon Mar 17 12:12:17 2008 -0700
+++ b/src/routing/olsr/olsr-header.h	Mon Mar 17 13:12:17 2008 -0700
@@ -95,6 +95,8 @@
   uint16_t m_packetSequenceNumber;
 
 public:  
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   virtual void Print (std::ostream &os) const;
   virtual uint32_t GetSerializedSize (void) const;
@@ -200,6 +202,8 @@
   uint16_t m_messageSize;
 
 public:  
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
   virtual void Print (std::ostream &os) const;
   virtual uint32_t GetSerializedSize (void) const;
--- a/utils/bench-packets.cc	Mon Mar 17 12:12:17 2008 -0700
+++ b/utils/bench-packets.cc	Mon Mar 17 13:12:17 2008 -0700
@@ -33,13 +33,14 @@
   BenchHeader ();
   bool IsOk (void) const;
 
+  static TypeId GetTypeId (void);
+  virtual TypeId GetInstanceTypeId (void) const;
   static uint32_t GetUid (void);
-
   static std::string GetName (void);
   void Print (std::ostream &os) const;
-  uint32_t GetSerializedSize (void) const;
-  void Serialize (Buffer::Iterator start) const;
-  uint32_t Deserialize (Buffer::Iterator start);
+  virtual uint32_t GetSerializedSize (void) const;
+  virtual void Serialize (Buffer::Iterator start) const;
+  virtual uint32_t Deserialize (Buffer::Iterator start);
 private:
   bool m_ok;
 };
@@ -57,6 +58,24 @@
 }
 
 template <int N>
+TypeId 
+BenchHeader<N>::GetTypeId (void)
+{
+  std::ostringstream oss;
+  oss << "ns3::BenchHeader<"<<N<<">";
+  static TypeId tid = TypeId (oss.str ().c_str ())
+    .SetParent<Header> ()
+    ;
+  return tid;
+}
+template <int N>
+TypeId 
+BenchHeader<N>::GetInstanceTypeId (void) const
+{
+  return GetTypeId ();
+}
+
+template <int N>
 uint32_t 
 BenchHeader<N>::GetUid (void)
 {