merge
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Tue Aug 26 12:25:59 2008 +0100 (17 months ago)
changeset 3574bfea2a4da368
parent 3566 6d041a5be1db
parent 3573 065488d0420c
child 3576 acd6d5b9c40d
merge
src/devices/bridge/bridge-net-device.h
     1.1 --- a/CHANGES.html	Tue Aug 26 12:25:08 2008 +0100
     1.2 +++ b/CHANGES.html	Tue Aug 26 12:25:59 2008 +0100
     1.3 @@ -61,12 +61,38 @@
     1.4  <h2>changes to existing API:</h2>
     1.5  
     1.6  <ul>
     1.7 +<li>25-08-2008; changeset 
     1.8 +<a href="http://code.nsnam.org/ns-3-dev/rev/e5ab96db540e">e5ab96db540e</a></li>
     1.9 +<ul>
    1.10 +<li>
    1.11 +bug 273: constify packet pointers.<br>
    1.12 +The normal and the promiscuous receive callbacks of the NetDevice API
    1.13 +have been changed from:
    1.14 +<pre>
    1.15 +Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &>
    1.16 +Callback<bool,Ptr<NetDevice>, Ptr<Packet>, uint16_t,
    1.17 +         const Address &, const Address &, enum PacketType >
    1.18 +</pre>
    1.19 +to:
    1.20 +<pre>
    1.21 +Callback<bool,Ptr<NetDevice>,Ptr<const Packet>,uint16_t,const Address &>
    1.22 +Callback<bool,Ptr<NetDevice>, Ptr<const Packet>, uint16_t,
    1.23 +         const Address &, const Address &, enum PacketType >
    1.24 +</pre>
    1.25 +to avoid the kind of bugs reported in 
    1.26 +<a href="http://www.nsnam.org/bugzilla/show_bug.cgi?id=273">bug 273</a>.
    1.27 +Users who implement a subclass of the NetDevice base class need to change the signature
    1.28 +of their SetReceiveCallback and SetPromiscReceiveCallback methods.
    1.29 +</li>
    1.30 +</ul>
    1.31 +</li>
    1.32 +
    1.33 +
    1.34  <li>04-08-2008; changeset 
    1.35  <a href="http://code.nsnam.org/ns-3-dev/rev/cba7b2b80fe8">cba7b2b80fe8</a></li>
    1.36  <ul>
    1.37  <li>
    1.38 -Cleanup of MTU confusion and initialization in CsmaNetDevice
    1.39 -<pre>
    1.40 +Cleanup of MTU confusion and initialization in CsmaNetDevice<br>
    1.41  The MTU of the CsmaNetDevice defaulted to 65535.  This did not correspond with
    1.42  the expected MTU found in Ethernet-like devices.  Also there was not clear 
    1.43  documentation regarding which MTU was being set.  There are two MTU here, one
    1.44 @@ -77,13 +103,11 @@
    1.45  mode, MAC MTU and PHY MTU while keeping the three values consistent.  See the
    1.46  Doxygen of CsmaNetDevice::SetMaxPayloadLength for a detailed description of the
    1.47  issues and solution.
    1.48 -</pre>
    1.49  </li>
    1.50  </ul>
    1.51  </li>
    1.52 -</ul>
    1.53  
    1.54 -<ul>
    1.55 +
    1.56  <li>21-07-2008; changeset 
    1.57  <a href="
    1.58  http://code.nsnam.org/ns-3-dev/rev/99698bc858e8">99698bc858e8</a></li>
    1.59 @@ -112,9 +136,8 @@
    1.60  </li>
    1.61  </ul>
    1.62  </li>
    1.63 -</ul>
    1.64  
    1.65 -<ul>
    1.66 +
    1.67  <li>03-07-2008; changeset 
    1.68  <a href="http://code.nsnam.org/ns-3-dev/rev/d5f8e5fae1c6">d5f8e5fae1c6</a></li>
    1.69  <ul>
    1.70 @@ -144,9 +167,8 @@
    1.71  </li>
    1.72  </ul>
    1.73  </li>
    1.74 -</ul>
    1.75  
    1.76 -<ul>
    1.77 +
    1.78  <li>03-07-2008; changeset 
    1.79  <a href="
    1.80  http://code.nsnam.org/ns-3-dev/rev/3cdd9d60f7c7">3cdd9d60f7c7</a></li>
    1.81 @@ -181,7 +203,7 @@
    1.82  </ul>
    1.83  </li>
    1.84  </ul>
    1.85 -</li>
    1.86 +
    1.87  
    1.88  </body>
    1.89  </html>
     2.1 --- a/bindings/python/ns3_module_bridge.py	Tue Aug 26 12:25:08 2008 +0100
     2.2 +++ b/bindings/python/ns3_module_bridge.py	Tue Aug 26 12:25:59 2008 +0100
     2.3 @@ -173,12 +173,12 @@
     2.4      ## bridge-net-device.h: void ns3::BridgeNetDevice::SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty> cb) [member function]
     2.5      cls.add_method('SetReceiveCallback', 
     2.6                     'void', 
     2.7 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     2.8 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     2.9                     is_virtual=True)
    2.10      ## bridge-net-device.h: void ns3::BridgeNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
    2.11      cls.add_method('SetPromiscReceiveCallback', 
    2.12                     'void', 
    2.13 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    2.14 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    2.15                     is_virtual=True)
    2.16      ## bridge-net-device.h: bool ns3::BridgeNetDevice::SupportsPromiscuous() const [member function]
    2.17      cls.add_method('SupportsPromiscuous', 
     3.1 --- a/bindings/python/ns3_module_csma.py	Tue Aug 26 12:25:08 2008 +0100
     3.2 +++ b/bindings/python/ns3_module_csma.py	Tue Aug 26 12:25:59 2008 +0100
     3.3 @@ -387,12 +387,12 @@
     3.4      ## csma-net-device.h: void ns3::CsmaNetDevice::SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty> cb) [member function]
     3.5      cls.add_method('SetReceiveCallback', 
     3.6                     'void', 
     3.7 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     3.8 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     3.9                     is_virtual=True)
    3.10      ## csma-net-device.h: void ns3::CsmaNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
    3.11      cls.add_method('SetPromiscReceiveCallback', 
    3.12                     'void', 
    3.13 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    3.14 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    3.15                     is_virtual=True)
    3.16      ## csma-net-device.h: bool ns3::CsmaNetDevice::SupportsPromiscuous() const [member function]
    3.17      cls.add_method('SupportsPromiscuous', 
     4.1 --- a/bindings/python/ns3_module_node.py	Tue Aug 26 12:25:08 2008 +0100
     4.2 +++ b/bindings/python/ns3_module_node.py	Tue Aug 26 12:25:59 2008 +0100
     4.3 @@ -1574,12 +1574,12 @@
     4.4      ## net-device.h: void ns3::NetDevice::SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty> cb) [member function]
     4.5      cls.add_method('SetReceiveCallback', 
     4.6                     'void', 
     4.7 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     4.8 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     4.9                     is_pure_virtual=True, is_virtual=True)
    4.10      ## net-device.h: void ns3::NetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
    4.11      cls.add_method('SetPromiscReceiveCallback', 
    4.12                     'void', 
    4.13 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    4.14 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    4.15                     is_pure_virtual=True, is_virtual=True)
    4.16      ## net-device.h: bool ns3::NetDevice::SupportsPromiscuous() const [member function]
    4.17      cls.add_method('SupportsPromiscuous', 
    4.18 @@ -1699,11 +1699,11 @@
    4.19      ## node.h: void ns3::Node::RegisterProtocolHandler(ns3::Callback<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> handler, uint16_t protocolType, ns3::Ptr<ns3::NetDevice> device, bool promiscuous=false) [member function]
    4.20      cls.add_method('RegisterProtocolHandler', 
    4.21                     'void', 
    4.22 -                   [param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'handler'), param('uint16_t', 'protocolType'), param('ns3::Ptr< ns3::NetDevice >', 'device'), param('bool', 'promiscuous', default_value='false')])
    4.23 +                   [param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'handler'), param('uint16_t', 'protocolType'), param('ns3::Ptr< ns3::NetDevice >', 'device'), param('bool', 'promiscuous', default_value='false')])
    4.24      ## node.h: void ns3::Node::UnregisterProtocolHandler(ns3::Callback<void, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> handler) [member function]
    4.25      cls.add_method('UnregisterProtocolHandler', 
    4.26                     'void', 
    4.27 -                   [param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'handler')])
    4.28 +                   [param('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'handler')])
    4.29      ## node.h: void ns3::Node::DoDispose() [member function]
    4.30      cls.add_method('DoDispose', 
    4.31                     'void', 
    4.32 @@ -2469,12 +2469,12 @@
    4.33      ## simple-net-device.h: void ns3::SimpleNetDevice::SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty> cb) [member function]
    4.34      cls.add_method('SetReceiveCallback', 
    4.35                     'void', 
    4.36 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
    4.37 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
    4.38                     is_virtual=True)
    4.39      ## simple-net-device.h: void ns3::SimpleNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
    4.40      cls.add_method('SetPromiscReceiveCallback', 
    4.41                     'void', 
    4.42 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    4.43 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    4.44                     is_virtual=True)
    4.45      ## simple-net-device.h: bool ns3::SimpleNetDevice::SupportsPromiscuous() const [member function]
    4.46      cls.add_method('SupportsPromiscuous', 
     5.1 --- a/bindings/python/ns3_module_point_to_point.py	Tue Aug 26 12:25:08 2008 +0100
     5.2 +++ b/bindings/python/ns3_module_point_to_point.py	Tue Aug 26 12:25:59 2008 +0100
     5.3 @@ -231,12 +231,12 @@
     5.4      ## point-to-point-net-device.h: void ns3::PointToPointNetDevice::SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty> cb) [member function]
     5.5      cls.add_method('SetReceiveCallback', 
     5.6                     'void', 
     5.7 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     5.8 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     5.9                     is_virtual=True)
    5.10      ## point-to-point-net-device.h: void ns3::PointToPointNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
    5.11      cls.add_method('SetPromiscReceiveCallback', 
    5.12                     'void', 
    5.13 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    5.14 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    5.15                     is_virtual=True)
    5.16      ## point-to-point-net-device.h: bool ns3::PointToPointNetDevice::SupportsPromiscuous() const [member function]
    5.17      cls.add_method('SupportsPromiscuous', 
     6.1 --- a/bindings/python/ns3_module_wifi.py	Tue Aug 26 12:25:08 2008 +0100
     6.2 +++ b/bindings/python/ns3_module_wifi.py	Tue Aug 26 12:25:59 2008 +0100
     6.3 @@ -2179,7 +2179,7 @@
     6.4      ## wifi-net-device.h: void ns3::WifiNetDevice::SetReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::empty, ns3::empty> cb) [member function]
     6.5      cls.add_method('SetReceiveCallback', 
     6.6                     'void', 
     6.7 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     6.8 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')], 
     6.9                     is_virtual=True)
    6.10      ## wifi-net-device.h: bool ns3::WifiNetDevice::SendFrom(ns3::Ptr<ns3::Packet> packet, ns3::Address const & source, ns3::Address const & dest, uint16_t protocolNumber) [member function]
    6.11      cls.add_method('SendFrom', 
    6.12 @@ -2189,7 +2189,7 @@
    6.13      ## wifi-net-device.h: void ns3::WifiNetDevice::SetPromiscReceiveCallback(ns3::Callback<bool, ns3::Ptr<ns3::NetDevice>, ns3::Ptr<ns3::Packet>, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType> cb) [member function]
    6.14      cls.add_method('SetPromiscReceiveCallback', 
    6.15                     'void', 
    6.16 -                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    6.17 +                   [param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')], 
    6.18                     is_virtual=True)
    6.19      ## wifi-net-device.h: bool ns3::WifiNetDevice::SupportsPromiscuous() const [member function]
    6.20      cls.add_method('SupportsPromiscuous', 
     7.1 --- a/examples/wifi-ap.cc	Tue Aug 26 12:25:08 2008 +0100
     7.2 +++ b/examples/wifi-ap.cc	Tue Aug 26 12:25:59 2008 +0100
     7.3 @@ -110,7 +110,7 @@
     7.4  
     7.5  int main (int argc, char *argv[])
     7.6  {
     7.7 -  Packet::EnableMetadata ();
     7.8 +  Packet::EnablePrinting ();
     7.9  
    7.10    // enable rts cts all the time.
    7.11    Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));
     8.1 --- a/src/common/packet-metadata.cc	Tue Aug 26 12:25:08 2008 +0100
     8.2 +++ b/src/common/packet-metadata.cc	Tue Aug 26 12:25:59 2008 +0100
     8.3 @@ -32,6 +32,7 @@
     8.4  namespace ns3 {
     8.5  
     8.6  bool PacketMetadata::m_enable = false;
     8.7 +bool PacketMetadata::m_enableChecking = false;
     8.8  bool PacketMetadata::m_metadataSkipped = false;
     8.9  uint32_t PacketMetadata::m_maxSize = 0;
    8.10  uint16_t PacketMetadata::m_chunkUid = 0;
    8.11 @@ -59,6 +60,13 @@
    8.12    m_enable = true;
    8.13  }
    8.14  
    8.15 +void 
    8.16 +PacketMetadata::EnableChecking (void)
    8.17 +{
    8.18 +  Enable ();
    8.19 +  m_enableChecking = true;
    8.20 +}
    8.21 +
    8.22  void
    8.23  PacketMetadata::ReserveCopy (uint32_t size)
    8.24  {
    8.25 @@ -630,13 +638,21 @@
    8.26    if ((item.typeUid & 0xfffffffe) != uid ||
    8.27        item.size != size)
    8.28      {
    8.29 -      NS_FATAL_ERROR ("Removing unexpected header.");
    8.30 +      if (m_enableChecking)
    8.31 +        {
    8.32 +          NS_FATAL_ERROR ("Removing unexpected header.");
    8.33 +        }
    8.34 +      return;
    8.35      }
    8.36    else if (item.typeUid != uid &&
    8.37             (extraItem.fragmentStart != 0 ||
    8.38              extraItem.fragmentEnd != size))
    8.39      {
    8.40 -      NS_FATAL_ERROR ("Removing incomplete header.");
    8.41 +      if (m_enableChecking)
    8.42 +        {
    8.43 +          NS_FATAL_ERROR ("Removing incomplete header.");
    8.44 +        }
    8.45 +      return;
    8.46      }
    8.47    if (m_head + read == m_used)
    8.48      {
    8.49 @@ -688,13 +704,21 @@
    8.50    if ((item.typeUid & 0xfffffffe) != uid ||
    8.51        item.size != size)
    8.52      {
    8.53 -      NS_FATAL_ERROR ("Removing unexpected trailer.");
    8.54 +      if (m_enableChecking)
    8.55 +        {
    8.56 +          NS_FATAL_ERROR ("Removing unexpected trailer.");
    8.57 +        }
    8.58 +      return;
    8.59      }
    8.60    else if (item.typeUid != uid &&
    8.61             (extraItem.fragmentStart != 0 ||
    8.62              extraItem.fragmentEnd != size))
    8.63      {
    8.64 -      NS_FATAL_ERROR ("Removing incomplete trailer.");
    8.65 +      if (m_enableChecking)
    8.66 +        {
    8.67 +          NS_FATAL_ERROR ("Removing incomplete trailer.");
    8.68 +        }
    8.69 +      return;
    8.70      }
    8.71    if (m_tail + read == m_used)
    8.72      {
     9.1 --- a/src/common/packet-metadata.h	Tue Aug 26 12:25:08 2008 +0100
     9.2 +++ b/src/common/packet-metadata.h	Tue Aug 26 12:25:59 2008 +0100
     9.3 @@ -125,6 +125,7 @@
     9.4    };
     9.5  
     9.6    static void Enable (void);
     9.7 +  static void EnableChecking (void);
     9.8  
     9.9    inline PacketMetadata (uint32_t uid, uint32_t size);
    9.10    inline PacketMetadata (PacketMetadata const &o);
    9.11 @@ -279,6 +280,7 @@
    9.12    
    9.13    static DataFreeList m_freeList;
    9.14    static bool m_enable;
    9.15 +  static bool m_enableChecking;
    9.16  
    9.17    // set to true when adding metadata to a packet is skipped because
    9.18    // m_enable is false; used to detect enabling of metadata in the
    10.1 --- a/src/common/packet.cc	Tue Aug 26 12:25:08 2008 +0100
    10.2 +++ b/src/common/packet.cc	Tue Aug 26 12:25:59 2008 +0100
    10.3 @@ -459,9 +459,23 @@
    10.4  Packet::EnableMetadata (void)
    10.5  {
    10.6    NS_LOG_FUNCTION_NOARGS ();
    10.7 +  EnableChecking ();
    10.8 +}
    10.9 +
   10.10 +void
   10.11 +Packet::EnablePrinting (void)
   10.12 +{
   10.13 +  NS_LOG_FUNCTION_NOARGS ();
   10.14    PacketMetadata::Enable ();
   10.15  }
   10.16  
   10.17 +void
   10.18 +Packet::EnableChecking (void)
   10.19 +{
   10.20 +  NS_LOG_FUNCTION_NOARGS ();
   10.21 +  PacketMetadata::EnableChecking ();
   10.22 +}
   10.23 +
   10.24  Buffer 
   10.25  Packet::Serialize (void) const
   10.26  {
    11.1 --- a/src/common/packet.h	Tue Aug 26 12:25:08 2008 +0100
    11.2 +++ b/src/common/packet.h	Tue Aug 26 12:25:59 2008 +0100
    11.3 @@ -30,6 +30,7 @@
    11.4  #include "ns3/callback.h"
    11.5  #include "ns3/assert.h"
    11.6  #include "ns3/ptr.h"
    11.7 +#include "ns3/deprecated.h"
    11.8  
    11.9  namespace ns3 {
   11.10  
   11.11 @@ -310,13 +311,17 @@
   11.12  
   11.13    PacketMetadata::ItemIterator BeginItem (void) const;
   11.14  
   11.15 +  static void EnableMetadata (void) NS_DEPRECATED;
   11.16 +
   11.17    /**
   11.18     * By default, packets do not keep around enough metadata to
   11.19     * perform the operations requested by the Print methods. If you
   11.20     * want to be able to invoke any of the two ::Print methods, 
   11.21     * you need to invoke this method at least once during the 
   11.22     * simulation setup and before any packet is created.
   11.23 -   *
   11.24 +   */
   11.25 +  static void EnablePrinting (void);
   11.26 +  /**
   11.27     * The packet metadata is also used to perform extensive
   11.28     * sanity checks at runtime when performing operations on a 
   11.29     * Packet. For example, this metadata is used to verify that
   11.30 @@ -324,7 +329,7 @@
   11.31     * was actually present at the front of the packet. These
   11.32     * errors will be detected and will abort the program.
   11.33     */
   11.34 -  static void EnableMetadata (void);
   11.35 +  static void EnableChecking (void);
   11.36  
   11.37    /**
   11.38     * \returns a byte buffer
    12.1 --- a/src/devices/bridge/bridge-net-device.cc	Tue Aug 26 12:25:08 2008 +0100
    12.2 +++ b/src/devices/bridge/bridge-net-device.cc	Tue Aug 26 12:25:59 2008 +0100
    12.3 @@ -61,7 +61,7 @@
    12.4  }
    12.5  
    12.6  void
    12.7 -BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<Packet> packet, uint16_t protocol,
    12.8 +BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol,
    12.9                                      Address const &src, Address const &dst, PacketType packetType)
   12.10  {
   12.11    NS_LOG_FUNCTION_NOARGS ();
   12.12 @@ -97,7 +97,7 @@
   12.13  }
   12.14  
   12.15  void
   12.16 -BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
   12.17 +BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
   12.18                                   uint16_t protocol, Mac48Address src, Mac48Address dst)
   12.19  {
   12.20    NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
   12.21 @@ -130,7 +130,7 @@
   12.22  }
   12.23  
   12.24  void
   12.25 -BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
   12.26 +BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
   12.27                                          uint16_t protocol, Mac48Address src, Mac48Address dst)
   12.28  {
   12.29    NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
    13.1 --- a/src/devices/bridge/bridge-net-device.h	Tue Aug 26 12:25:08 2008 +0100
    13.2 +++ b/src/devices/bridge/bridge-net-device.h	Tue Aug 26 12:25:59 2008 +0100
    13.3 @@ -111,11 +111,11 @@
    13.4  protected:
    13.5    virtual void DoDispose (void);
    13.6  
    13.7 -  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
    13.8 +  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
    13.9                            Address const &source, Address const &destination, PacketType packetType);
   13.10 -  void ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
   13.11 +  void ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
   13.12                         uint16_t protocol, Mac48Address src, Mac48Address dst);
   13.13 -  void ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
   13.14 +  void ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
   13.15                           uint16_t protocol, Mac48Address src, Mac48Address dst);
   13.16    void Learn (Mac48Address source, Ptr<NetDevice> port);
   13.17    Ptr<NetDevice> GetLearnedState (Mac48Address source);
    14.1 --- a/src/devices/csma/csma-net-device.cc	Tue Aug 26 12:25:08 2008 +0100
    14.2 +++ b/src/devices/csma/csma-net-device.cc	Tue Aug 26 12:25:59 2008 +0100
    14.3 @@ -670,27 +670,6 @@
    14.4    NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
    14.5    NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
    14.6  
    14.7 -  //
    14.8 -  // An IP host group address is mapped to an Ethernet multicast address
    14.9 -  // by placing the low-order 23-bits of the IP address into the low-order
   14.10 -  // 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex).
   14.11 -  //
   14.12 -  // We are going to receive all packets destined to any multicast address,
   14.13 -  // which means clearing the low-order 23 bits the header destination 
   14.14 -  //
   14.15 -  Mac48Address mcDest;
   14.16 -  uint8_t      mcBuf[6];
   14.17 -
   14.18 -  header.GetDestination ().CopyTo (mcBuf);
   14.19 -  mcBuf[3] &= 0x80;
   14.20 -  mcBuf[4] = 0;
   14.21 -  mcBuf[5] = 0;
   14.22 -  mcDest.CopyFrom (mcBuf);
   14.23 -
   14.24 -  Mac48Address multicast = Mac48Address::ConvertFrom (GetMulticast ());
   14.25 -  Mac48Address broadcast = Mac48Address::ConvertFrom (GetBroadcast ());
   14.26 -  Mac48Address destination = Mac48Address::ConvertFrom (GetAddress ());
   14.27 -
   14.28    if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
   14.29      {
   14.30        NS_LOG_LOGIC ("Dropping pkt due to error model ");
   14.31 @@ -723,17 +702,17 @@
   14.32  
   14.33        PacketType packetType;
   14.34        
   14.35 -      if (header.GetDestination () == broadcast)
   14.36 +      if (header.GetDestination ().IsBroadcast ())
   14.37          {
   14.38            packetType = PACKET_BROADCAST;
   14.39            m_rxTrace (originalPacket);
   14.40          }
   14.41 -      else if (mcDest == multicast)
   14.42 +      else if (header.GetDestination ().IsMulticast ())
   14.43          {
   14.44            packetType = PACKET_MULTICAST;          
   14.45            m_rxTrace (originalPacket);
   14.46          }
   14.47 -      else if (header.GetDestination () == destination)
   14.48 +      else if (header.GetDestination () == m_address)
   14.49          {
   14.50            packetType = PACKET_HOST;
   14.51            m_rxTrace (originalPacket);
   14.52 @@ -855,65 +834,24 @@
   14.53  CsmaNetDevice::GetMulticast (void) const
   14.54  {
   14.55    NS_LOG_FUNCTION_NOARGS ();
   14.56 -  return Mac48Address ("01:00:5e:00:00:00");
   14.57 +  return Mac48Address::GetMulticastPrefix ();
   14.58  }
   14.59  
   14.60    Address 
   14.61  CsmaNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
   14.62  {
   14.63    NS_LOG_FUNCTION (multicastGroup);
   14.64 -  //
   14.65 -  // First, get the generic multicast address.
   14.66 -  //
   14.67 -  Address hardwareDestination = GetMulticast ();
   14.68  
   14.69 -  NS_LOG_LOGIC ("Device multicast address: " << hardwareDestination);
   14.70 -
   14.71 -  //
   14.72 -  // It's our address, and we know we're playing with an EUI-48 address here
   14.73 -  // primarily since we know that by construction, but also since the parameter
   14.74 -  // is an Ipv4Address.
   14.75 -  //
   14.76 -  Mac48Address etherAddr = Mac48Address::ConvertFrom (hardwareDestination);
   14.77 -
   14.78 -  //
   14.79 -  // We now have the multicast address in an abstract 48-bit container.  We 
   14.80 -  // need to pull it out so we can play with it.  When we're done, we have the 
   14.81 -  // high order bits in etherBuffer[0], etc.
   14.82 -  //
   14.83 -  uint8_t etherBuffer[6];
   14.84 -  etherAddr.CopyTo (etherBuffer);
   14.85 -
   14.86 -  //
   14.87 -  // Now we need to pull the raw bits out of the Ipv4 destination address.
   14.88 -  //
   14.89 -  uint8_t ipBuffer[4];
   14.90 -  multicastGroup.Serialize (ipBuffer);
   14.91 -
   14.92 -  //
   14.93 -  // RFC 1112 says that an Ipv4 host group address is mapped to an EUI-48
   14.94 -  // multicast address by placing the low-order 23-bits of the IP address into 
   14.95 -  // the low-order 23 bits of the Ethernet multicast address 
   14.96 -  // 01-00-5E-00-00-00 (hex). 
   14.97 -  //
   14.98 -  etherBuffer[3] |= ipBuffer[1] & 0x7f;
   14.99 -  etherBuffer[4] = ipBuffer[2];
  14.100 -  etherBuffer[5] = ipBuffer[3];
  14.101 -
  14.102 -  //
  14.103 -  // Now, etherBuffer has the desired ethernet multicast address.  We have to
  14.104 -  // suck these bits back into the Mac48Address,
  14.105 -  //
  14.106 -  etherAddr.CopyFrom (etherBuffer);
  14.107 +  Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
  14.108  
  14.109    //
  14.110    // Implicit conversion (operator Address ()) is defined for Mac48Address, so
  14.111    // use it by just returning the EUI-48 address which is automagically converted
  14.112    // to an Address.
  14.113    //
  14.114 -  NS_LOG_LOGIC ("multicast address is " << etherAddr);
  14.115 +  NS_LOG_LOGIC ("multicast address is " << ad);
  14.116  
  14.117 -  return etherAddr;
  14.118 +  return ad;
  14.119  }
  14.120  
  14.121    bool 
    15.1 --- a/src/devices/wifi/wifi-net-device.cc	Tue Aug 26 12:25:08 2008 +0100
    15.2 +++ b/src/devices/wifi/wifi-net-device.cc	Tue Aug 26 12:25:59 2008 +0100
    15.3 @@ -255,12 +255,12 @@
    15.4  Address 
    15.5  WifiNetDevice::GetMulticast (void) const
    15.6  {
    15.7 -  return Mac48Address ("01:00:5e:00:00:00");
    15.8 +  return Mac48Address::GetMulticastPrefix ();
    15.9  }
   15.10  Address 
   15.11  WifiNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
   15.12  {
   15.13 -  return GetMulticast ();
   15.14 +  return Mac48Address::GetMulticast (multicastGroup);
   15.15  }
   15.16  bool 
   15.17  WifiNetDevice::IsPointToPoint (void) const
    16.1 --- a/src/helper/csma-helper.cc	Tue Aug 26 12:25:08 2008 +0100
    16.2 +++ b/src/helper/csma-helper.cc	Tue Aug 26 12:25:59 2008 +0100
    16.3 @@ -122,7 +122,7 @@
    16.4  void 
    16.5  CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
    16.6  {
    16.7 -  Packet::EnableMetadata ();
    16.8 +  Packet::EnablePrinting ();
    16.9    std::ostringstream oss;
   16.10    oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
   16.11    Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));
    17.1 --- a/src/helper/point-to-point-helper.cc	Tue Aug 26 12:25:08 2008 +0100
    17.2 +++ b/src/helper/point-to-point-helper.cc	Tue Aug 26 12:25:59 2008 +0100
    17.3 @@ -122,7 +122,7 @@
    17.4  void 
    17.5  PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
    17.6  {
    17.7 -  Packet::EnableMetadata ();
    17.8 +  Packet::EnablePrinting ();
    17.9    std::ostringstream oss;
   17.10    oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
   17.11    Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));
    18.1 --- a/src/helper/wifi-helper.cc	Tue Aug 26 12:25:08 2008 +0100
    18.2 +++ b/src/helper/wifi-helper.cc	Tue Aug 26 12:25:59 2008 +0100
    18.3 @@ -193,7 +193,7 @@
    18.4  void 
    18.5  WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
    18.6  {
    18.7 -    Packet::EnableMetadata ();
    18.8 +  Packet::EnablePrinting ();
    18.9    std::ostringstream oss;
   18.10    oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
   18.11    Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));
    19.1 --- a/src/internet-stack/arp-l3-protocol.cc	Tue Aug 26 12:25:08 2008 +0100
    19.2 +++ b/src/internet-stack/arp-l3-protocol.cc	Tue Aug 26 12:25:59 2008 +0100
    19.3 @@ -117,11 +117,13 @@
    19.4  }
    19.5  
    19.6  void 
    19.7 -ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
    19.8 +ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
    19.9                         const Address &to, NetDevice::PacketType packetType)
   19.10  {
   19.11    NS_LOG_FUNCTION_NOARGS ();
   19.12  
   19.13 +  Ptr<Packet> packet = p->Copy ();
   19.14 +
   19.15    Ptr<ArpCache> cache = FindCache (device);
   19.16    ArpHeader arp;
   19.17    packet->RemoveHeader (arp);
    20.1 --- a/src/internet-stack/arp-l3-protocol.h	Tue Aug 26 12:25:08 2008 +0100
    20.2 +++ b/src/internet-stack/arp-l3-protocol.h	Tue Aug 26 12:25:59 2008 +0100
    20.3 @@ -54,7 +54,7 @@
    20.4    /**
    20.5     * \brief Receive a packet
    20.6     */
    20.7 -  void Receive(Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from, const Address &to,
    20.8 +  void Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
    20.9                 NetDevice::PacketType packetType);
   20.10    /**
   20.11     * \brief Perform an ARP lookup
    21.1 --- a/src/internet-stack/ipv4-l3-protocol.cc	Tue Aug 26 12:25:08 2008 +0100
    21.2 +++ b/src/internet-stack/ipv4-l3-protocol.cc	Tue Aug 26 12:25:59 2008 +0100
    21.3 @@ -449,13 +449,15 @@
    21.4  }  
    21.5  
    21.6  void 
    21.7 -Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
    21.8 +Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
    21.9                           const Address &to, NetDevice::PacketType packetType)
   21.10  {
   21.11 -  NS_LOG_FUNCTION (this << &device << packet << protocol <<  from);
   21.12 +  NS_LOG_FUNCTION (this << &device << p << protocol <<  from);
   21.13  
   21.14    NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ());
   21.15  
   21.16 +  Ptr<Packet> packet = p->Copy ();
   21.17 +
   21.18    uint32_t index = 0;
   21.19    Ptr<Ipv4Interface> ipv4Interface;
   21.20    for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); 
    22.1 --- a/src/internet-stack/ipv4-l3-protocol.h	Tue Aug 26 12:25:08 2008 +0100
    22.2 +++ b/src/internet-stack/ipv4-l3-protocol.h	Tue Aug 26 12:25:59 2008 +0100
    22.3 @@ -83,7 +83,7 @@
    22.4     *    - implement a per-NetDevice ARP cache
    22.5     *    - send back arp replies on the right device
    22.6     */
    22.7 -  void Receive( Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from,
    22.8 +  void Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
    22.9                  const Address &to, NetDevice::PacketType packetType);
   22.10  
   22.11    /**
    23.1 --- a/src/node/mac48-address.cc	Tue Aug 26 12:25:08 2008 +0100
    23.2 +++ b/src/node/mac48-address.cc	Tue Aug 26 12:25:59 2008 +0100
    23.3 @@ -144,6 +144,18 @@
    23.4  bool 
    23.5  Mac48Address::IsMulticast (void) const
    23.6  {
    23.7 +  uint8_t mcBuf[6];
    23.8 +  CopyTo (mcBuf);
    23.9 +  mcBuf[3] &= 0x80;
   23.10 +  mcBuf[4] = 0;
   23.11 +  mcBuf[5] = 0;
   23.12 +  Mac48Address prefix;
   23.13 +  prefix.CopyFrom (mcBuf);
   23.14 +  return prefix == Mac48Address::GetMulticastPrefix ();
   23.15 +}
   23.16 +bool 
   23.17 +Mac48Address::IsGroup (void) const
   23.18 +{
   23.19    return (m_address[0] & 0x01) == 0x01;
   23.20  }
   23.21  Mac48Address
   23.22 @@ -152,6 +164,48 @@
   23.23    static Mac48Address broadcast = Mac48Address ("ff:ff:ff:ff:ff:ff");
   23.24    return broadcast;
   23.25  }
   23.26 +Mac48Address 
   23.27 +Mac48Address::GetMulticastPrefix (void)
   23.28 +{
   23.29 +  static Mac48Address multicast = Mac48Address ("01:00:5e:00:00:00");
   23.30 +  return multicast;
   23.31 +}
   23.32 +Mac48Address 
   23.33 +Mac48Address::GetMulticast (Ipv4Address multicastGroup)
   23.34 +{
   23.35 +  Mac48Address etherAddr = Mac48Address::GetMulticastPrefix ();
   23.36 +  //
   23.37 +  // We now have the multicast address in an abstract 48-bit container.  We 
   23.38 +  // need to pull it out so we can play with it.  When we're done, we have the 
   23.39 +  // high order bits in etherBuffer[0], etc.
   23.40 +  //
   23.41 +  uint8_t etherBuffer[6];
   23.42 +  etherAddr.CopyTo (etherBuffer);
   23.43 +
   23.44 +  //
   23.45 +  // Now we need to pull the raw bits out of the Ipv4 destination address.
   23.46 +  //
   23.47 +  uint8_t ipBuffer[4];
   23.48 +  multicastGroup.Serialize (ipBuffer);
   23.49 +
   23.50 +  //
   23.51 +  // RFC 1112 says that an Ipv4 host group address is mapped to an EUI-48
   23.52 +  // multicast address by placing the low-order 23-bits of the IP address into 
   23.53 +  // the low-order 23 bits of the Ethernet multicast address 
   23.54 +  // 01-00-5E-00-00-00 (hex). 
   23.55 +  //
   23.56 +  etherBuffer[3] |= ipBuffer[1] & 0x7f;
   23.57 +  etherBuffer[4] = ipBuffer[2];
   23.58 +  etherBuffer[5] = ipBuffer[3];
   23.59 +
   23.60 +  //
   23.61 +  // Now, etherBuffer has the desired ethernet multicast address.  We have to
   23.62 +  // suck these bits back into the Mac48Address,
   23.63 +  //
   23.64 +  Mac48Address result;
   23.65 +  result.CopyFrom (etherBuffer);
   23.66 +  return result;
   23.67 +}
   23.68  
   23.69  bool operator == (const Mac48Address &a, const Mac48Address &b)
   23.70  {
    24.1 --- a/src/node/mac48-address.h	Tue Aug 26 12:25:08 2008 +0100
    24.2 +++ b/src/node/mac48-address.h	Tue Aug 26 12:25:59 2008 +0100
    24.3 @@ -24,6 +24,7 @@
    24.4  #include <ostream>
    24.5  #include "ns3/attribute.h"
    24.6  #include "ns3/attribute-helper.h"
    24.7 +#include "ipv4-address.h"
    24.8  
    24.9  namespace ns3 {
   24.10  
   24.11 @@ -92,12 +93,25 @@
   24.12     * \returns true if this is a multicast address, false otherwise.
   24.13     */
   24.14    bool IsMulticast (void) const;
   24.15 +  /**
   24.16 +   * \returns true if the group bit is set, false otherwise.
   24.17 +   */
   24.18 +  bool IsGroup (void) const;
   24.19  
   24.20    /**
   24.21     * \returns the broadcast address
   24.22     */
   24.23    static Mac48Address GetBroadcast (void);
   24.24  
   24.25 +  /**
   24.26 +   * \returns a multicast address
   24.27 +   */
   24.28 +  static Mac48Address GetMulticast (Ipv4Address address);
   24.29 +
   24.30 +  /**
   24.31 +   * \returns the multicast prefix (01:00:5e:00:00:00).
   24.32 +   */
   24.33 +  static Mac48Address GetMulticastPrefix (void);
   24.34  private:
   24.35    /**
   24.36     * \returns a new Address instance
    25.1 --- a/src/node/net-device.cc	Tue Aug 26 12:25:08 2008 +0100
    25.2 +++ b/src/node/net-device.cc	Tue Aug 26 12:25:59 2008 +0100
    25.3 @@ -20,6 +20,7 @@
    25.4  
    25.5  #include "ns3/object.h"
    25.6  #include "ns3/log.h"
    25.7 +#include "ns3/uinteger.h"
    25.8  #include "net-device.h"
    25.9  
   25.10  NS_LOG_COMPONENT_DEFINE ("NetDevice");
   25.11 @@ -31,7 +32,15 @@
   25.12  TypeId NetDevice::GetTypeId (void)
   25.13  {
   25.14    static TypeId tid = TypeId ("ns3::NetDevice")
   25.15 -    .SetParent<Object> ();
   25.16 +    .SetParent<Object> ()
   25.17 +    .AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
   25.18 +                   TypeId::ATTR_SET | TypeId::ATTR_GET,
   25.19 +                   UintegerValue (0xffff),
   25.20 +                   MakeUintegerAccessor (&NetDevice::SetMtu,
   25.21 +                                         &NetDevice::GetMtu),
   25.22 +                   MakeUintegerChecker<uint16_t> ())
   25.23 +                   
   25.24 +    ;
   25.25    return tid;
   25.26  }
   25.27  
    26.1 --- a/src/node/net-device.h	Tue Aug 26 12:25:08 2008 +0100
    26.2 +++ b/src/node/net-device.h	Tue Aug 26 12:25:59 2008 +0100
    26.3 @@ -274,7 +274,7 @@
    26.4     * \returns true if the callback could handle the packet successfully, false
    26.5     *          otherwise.
    26.6     */
    26.7 -  typedef Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &> ReceiveCallback;
    26.8 +  typedef Callback<bool,Ptr<NetDevice>,Ptr<const Packet>,uint16_t,const Address &> ReceiveCallback;
    26.9  
   26.10    /**
   26.11     * \param cb callback to invoke whenever a packet has been received and must
   26.12 @@ -296,8 +296,8 @@
   26.13     * \returns true if the callback could handle the packet successfully, false
   26.14     *          otherwise.
   26.15     */
   26.16 -  typedef Callback< bool, Ptr<NetDevice>, Ptr<Packet>, uint16_t,
   26.17 -                    const Address &, const Address &, PacketType > PromiscReceiveCallback;
   26.18 +  typedef Callback< bool, Ptr<NetDevice>, Ptr<const Packet>, uint16_t,
   26.19 +                    const Address &, const Address &, enum PacketType > PromiscReceiveCallback;
   26.20  
   26.21    /**
   26.22     * \param cb callback to invoke whenever a packet has been received in promiscuous mode and must
    27.1 --- a/src/node/node.cc	Tue Aug 26 12:25:08 2008 +0100
    27.2 +++ b/src/node/node.cc	Tue Aug 26 12:25:59 2008 +0100
    27.3 @@ -222,7 +222,7 @@
    27.4  }
    27.5  
    27.6  bool
    27.7 -Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
    27.8 +Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
    27.9                                  const Address &from, const Address &to, NetDevice::PacketType packetType)
   27.10  {
   27.11    NS_LOG_FUNCTION(device->GetName ());
   27.12 @@ -230,7 +230,7 @@
   27.13  }
   27.14  
   27.15  bool
   27.16 -Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
   27.17 +Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
   27.18                                     const Address &from)
   27.19  {
   27.20    NS_LOG_FUNCTION(device->GetName ());
   27.21 @@ -238,15 +238,11 @@
   27.22  }
   27.23  
   27.24  bool
   27.25 -Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
   27.26 +Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
   27.27                           const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous)
   27.28  {
   27.29    NS_LOG_FUNCTION(device->GetName ());
   27.30    bool found = false;
   27.31 -  // if there are (potentially) multiple handlers, we need to copy the
   27.32 -  // packet before passing it to each handler, because handlers may
   27.33 -  // modify it.
   27.34 -  bool copyNeeded = (m_handlers.size () > 1);
   27.35  
   27.36    for (ProtocolHandlerList::iterator i = m_handlers.begin ();
   27.37         i != m_handlers.end (); i++)
   27.38 @@ -259,7 +255,7 @@
   27.39              {
   27.40                if (promiscuous == i->promiscuous)
   27.41                  {
   27.42 -                  i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, packetType);
   27.43 +                  i->handler (device, packet->Copy (), protocol, from, to, packetType);
   27.44                    found = true;
   27.45                  }
   27.46              }
    28.1 --- a/src/node/node.h	Tue Aug 26 12:25:08 2008 +0100
    28.2 +++ b/src/node/node.h	Tue Aug 26 12:25:59 2008 +0100
    28.3 @@ -145,7 +145,7 @@
    28.4     *                   this value is only valid for promiscuous mode
    28.5     *                   protocol handlers.
    28.6     */
    28.7 -  typedef Callback<void,Ptr<NetDevice>, Ptr<Packet>,uint16_t,const Address &,
    28.8 +  typedef Callback<void,Ptr<NetDevice>, Ptr<const Packet>,uint16_t,const Address &,
    28.9                     const Address &, NetDevice::PacketType> ProtocolHandler;
   28.10    /**
   28.11     * \param handler the handler to register
   28.12 @@ -189,10 +189,10 @@
   28.13     */
   28.14    virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
   28.15  
   28.16 -  bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol, const Address &from);
   28.17 -  bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
   28.18 +  bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol, const Address &from);
   28.19 +  bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
   28.20                                   const Address &from, const Address &to, NetDevice::PacketType packetType);
   28.21 -  bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
   28.22 +  bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
   28.23                            const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc);
   28.24  
   28.25    void Construct (void);
    29.1 --- a/src/node/packet-socket.cc	Tue Aug 26 12:25:08 2008 +0100
    29.2 +++ b/src/node/packet-socket.cc	Tue Aug 26 12:25:59 2008 +0100
    29.3 @@ -344,7 +344,7 @@
    29.4  }
    29.5  
    29.6  void 
    29.7 -PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, 
    29.8 +PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet, 
    29.9                           uint16_t protocol, const Address &from,
   29.10                           const Address &to, NetDevice::PacketType packetType)
   29.11  {
   29.12 @@ -369,7 +369,7 @@
   29.13        SocketAddressTag tag;
   29.14        tag.SetAddress (address);
   29.15        packet->AddTag (tag);
   29.16 -      m_deliveryQueue.push (packet);
   29.17 +      m_deliveryQueue.push (packet->Copy ());
   29.18        m_rxAvailable += packet->GetSize ();
   29.19        NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this);
   29.20        NotifyDataRecv ();
    30.1 --- a/src/node/packet-socket.h	Tue Aug 26 12:25:08 2008 +0100
    30.2 +++ b/src/node/packet-socket.h	Tue Aug 26 12:25:59 2008 +0100
    30.3 @@ -103,7 +103,7 @@
    30.4      Address &fromAddress);
    30.5  
    30.6  private:
    30.7 -  void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, 
    30.8 +  void ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet, 
    30.9                    uint16_t protocol, const Address &from, const Address &to,
   30.10                    NetDevice::PacketType packetType);
   30.11    int DoBind (const PacketSocketAddress &address);
    31.1 --- a/src/node/simple-net-device.cc	Tue Aug 26 12:25:08 2008 +0100
    31.2 +++ b/src/node/simple-net-device.cc	Tue Aug 26 12:25:59 2008 +0100
    31.3 @@ -142,12 +142,12 @@
    31.4  Address 
    31.5  SimpleNetDevice::GetMulticast (void) const
    31.6  {
    31.7 -  return Mac48Address ("01:00:5e:00:00:00");
    31.8 +  return Mac48Address::GetMulticastPrefix ();
    31.9  }
   31.10  Address 
   31.11  SimpleNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
   31.12  {
   31.13 -  return Mac48Address ("01:00:5e:00:00:00");
   31.14 +  return Mac48Address::GetMulticast (multicastGroup);
   31.15  }
   31.16  bool 
   31.17  SimpleNetDevice::IsPointToPoint (void) const
    32.1 --- a/utils/bench-packets.cc	Tue Aug 26 12:25:08 2008 +0100
    32.2 +++ b/utils/bench-packets.cc	Tue Aug 26 12:25:59 2008 +0100
    32.3 @@ -282,7 +282,7 @@
    32.4    runBench (&benchC, n, "c");
    32.5    runBench (&benchD, n, "d");
    32.6  
    32.7 -  Packet::EnableMetadata ();
    32.8 +  Packet::EnablePrinting ();
    32.9    runBench (&benchA, n, "meta-a");
   32.10    runBench (&benchB, n, "meta-b");
   32.11    runBench (&benchC, n, "meta-c");