This commit is contained in:
Gustavo J. A. M. Carneiro
2008-08-26 12:25:59 +01:00
32 changed files with 220 additions and 138 deletions

View File

@@ -61,12 +61,38 @@ mostly for internal use.
<h2>changes to existing API:</h2>
<ul>
<li>25-08-2008; changeset
<a href="http://code.nsnam.org/ns-3-dev/rev/e5ab96db540e">e5ab96db540e</a></li>
<ul>
<li>
bug 273: constify packet pointers.<br>
The normal and the promiscuous receive callbacks of the NetDevice API
have been changed from:
<pre>
Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &>
Callback<bool,Ptr<NetDevice>, Ptr<Packet>, uint16_t,
const Address &, const Address &, enum PacketType >
</pre>
to:
<pre>
Callback<bool,Ptr<NetDevice>,Ptr<const Packet>,uint16_t,const Address &>
Callback<bool,Ptr<NetDevice>, Ptr<const Packet>, uint16_t,
const Address &, const Address &, enum PacketType >
</pre>
to avoid the kind of bugs reported in
<a href="http://www.nsnam.org/bugzilla/show_bug.cgi?id=273">bug 273</a>.
Users who implement a subclass of the NetDevice base class need to change the signature
of their SetReceiveCallback and SetPromiscReceiveCallback methods.
</li>
</ul>
</li>
<li>04-08-2008; changeset
<a href="http://code.nsnam.org/ns-3-dev/rev/cba7b2b80fe8">cba7b2b80fe8</a></li>
<ul>
<li>
Cleanup of MTU confusion and initialization in CsmaNetDevice
<pre>
Cleanup of MTU confusion and initialization in CsmaNetDevice<br>
The MTU of the CsmaNetDevice defaulted to 65535. This did not correspond with
the expected MTU found in Ethernet-like devices. Also there was not clear
documentation regarding which MTU was being set. There are two MTU here, one
@@ -77,13 +103,11 @@ MAC level MTU at 1492 by default. We allow users to now set the encapsulation
mode, MAC MTU and PHY MTU while keeping the three values consistent. See the
Doxygen of CsmaNetDevice::SetMaxPayloadLength for a detailed description of the
issues and solution.
</pre>
</li>
</ul>
</li>
</ul>
<ul>
<li>21-07-2008; changeset
<a href="
http://code.nsnam.org/ns-3-dev/rev/99698bc858e8">99698bc858e8</a></li>
@@ -112,9 +136,8 @@ when the m_promiscRxCallback is called.
</li>
</ul>
</li>
</ul>
<ul>
<li>03-07-2008; changeset
<a href="http://code.nsnam.org/ns-3-dev/rev/d5f8e5fae1c6">d5f8e5fae1c6</a></li>
<ul>
@@ -144,9 +167,8 @@ ApplicationContainer Install (NodeContainer c);
</li>
</ul>
</li>
</ul>
<ul>
<li>03-07-2008; changeset
<a href="
http://code.nsnam.org/ns-3-dev/rev/3cdd9d60f7c7">3cdd9d60f7c7</a></li>
@@ -181,7 +203,7 @@ instability in neighbor detection.
</ul>
</li>
</ul>
</li>
</body>
</html>

View File

@@ -173,12 +173,12 @@ def register_Ns3BridgeNetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## 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]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
[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')],
is_virtual=True)
## bridge-net-device.h: bool ns3::BridgeNetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',

View File

@@ -387,12 +387,12 @@ def register_Ns3CsmaNetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## 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]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
[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')],
is_virtual=True)
## csma-net-device.h: bool ns3::CsmaNetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',

View File

@@ -1574,12 +1574,12 @@ def register_Ns3NetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_pure_virtual=True, is_virtual=True)
## 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]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
[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')],
is_pure_virtual=True, is_virtual=True)
## net-device.h: bool ns3::NetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',
@@ -1699,11 +1699,11 @@ def register_Ns3Node_methods(root_module, cls):
## 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]
cls.add_method('RegisterProtocolHandler',
'void',
[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')])
[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')])
## 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]
cls.add_method('UnregisterProtocolHandler',
'void',
[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('ns3::Callback< void, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'handler')])
## node.h: void ns3::Node::DoDispose() [member function]
cls.add_method('DoDispose',
'void',
@@ -2469,12 +2469,12 @@ def register_Ns3SimpleNetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## 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]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
[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')],
is_virtual=True)
## simple-net-device.h: bool ns3::SimpleNetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',

View File

@@ -231,12 +231,12 @@ def register_Ns3PointToPointNetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## 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]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
[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')],
is_virtual=True)
## point-to-point-net-device.h: bool ns3::PointToPointNetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',

View File

@@ -2179,7 +2179,7 @@ def register_Ns3WifiNetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr<const ns3::Packet >, unsigned short, ns3::Address const&, ns3::empty, ns3::empty >', 'cb')],
is_virtual=True)
## 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]
cls.add_method('SendFrom',
@@ -2189,7 +2189,7 @@ def register_Ns3WifiNetDevice_methods(root_module, cls):
## 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]
cls.add_method('SetPromiscReceiveCallback',
'void',
[param('ns3::Callback< bool, ns3::Ptr< ns3::NetDevice >, ns3::Ptr< ns3::Packet >, unsigned short, ns3::Address const&, ns3::Address const&, ns3::NetDevice::PacketType >', 'cb')],
[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')],
is_virtual=True)
## wifi-net-device.h: bool ns3::WifiNetDevice::SupportsPromiscuous() const [member function]
cls.add_method('SupportsPromiscuous',

View File

@@ -110,7 +110,7 @@ AdvancePosition (Ptr<Node> node)
int main (int argc, char *argv[])
{
Packet::EnableMetadata ();
Packet::EnablePrinting ();
// enable rts cts all the time.
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("0"));

View File

@@ -32,6 +32,7 @@ NS_LOG_COMPONENT_DEFINE ("PacketMetadata");
namespace ns3 {
bool PacketMetadata::m_enable = false;
bool PacketMetadata::m_enableChecking = false;
bool PacketMetadata::m_metadataSkipped = false;
uint32_t PacketMetadata::m_maxSize = 0;
uint16_t PacketMetadata::m_chunkUid = 0;
@@ -59,6 +60,13 @@ PacketMetadata::Enable (void)
m_enable = true;
}
void
PacketMetadata::EnableChecking (void)
{
Enable ();
m_enableChecking = true;
}
void
PacketMetadata::ReserveCopy (uint32_t size)
{
@@ -630,13 +638,21 @@ PacketMetadata::RemoveHeader (const Header &header, uint32_t size)
if ((item.typeUid & 0xfffffffe) != uid ||
item.size != size)
{
NS_FATAL_ERROR ("Removing unexpected header.");
if (m_enableChecking)
{
NS_FATAL_ERROR ("Removing unexpected header.");
}
return;
}
else if (item.typeUid != uid &&
(extraItem.fragmentStart != 0 ||
extraItem.fragmentEnd != size))
{
NS_FATAL_ERROR ("Removing incomplete header.");
if (m_enableChecking)
{
NS_FATAL_ERROR ("Removing incomplete header.");
}
return;
}
if (m_head + read == m_used)
{
@@ -688,13 +704,21 @@ PacketMetadata::RemoveTrailer (const Trailer &trailer, uint32_t size)
if ((item.typeUid & 0xfffffffe) != uid ||
item.size != size)
{
NS_FATAL_ERROR ("Removing unexpected trailer.");
if (m_enableChecking)
{
NS_FATAL_ERROR ("Removing unexpected trailer.");
}
return;
}
else if (item.typeUid != uid &&
(extraItem.fragmentStart != 0 ||
extraItem.fragmentEnd != size))
{
NS_FATAL_ERROR ("Removing incomplete trailer.");
if (m_enableChecking)
{
NS_FATAL_ERROR ("Removing incomplete trailer.");
}
return;
}
if (m_tail + read == m_used)
{

View File

@@ -125,6 +125,7 @@ public:
};
static void Enable (void);
static void EnableChecking (void);
inline PacketMetadata (uint32_t uid, uint32_t size);
inline PacketMetadata (PacketMetadata const &o);
@@ -279,6 +280,7 @@ private:
static DataFreeList m_freeList;
static bool m_enable;
static bool m_enableChecking;
// set to true when adding metadata to a packet is skipped because
// m_enable is false; used to detect enabling of metadata in the

View File

@@ -457,11 +457,25 @@ Packet::BeginItem (void) const
void
Packet::EnableMetadata (void)
{
NS_LOG_FUNCTION_NOARGS ();
EnableChecking ();
}
void
Packet::EnablePrinting (void)
{
NS_LOG_FUNCTION_NOARGS ();
PacketMetadata::Enable ();
}
void
Packet::EnableChecking (void)
{
NS_LOG_FUNCTION_NOARGS ();
PacketMetadata::EnableChecking ();
}
Buffer
Packet::Serialize (void) const
{

View File

@@ -30,6 +30,7 @@
#include "ns3/callback.h"
#include "ns3/assert.h"
#include "ns3/ptr.h"
#include "ns3/deprecated.h"
namespace ns3 {
@@ -310,13 +311,17 @@ public:
PacketMetadata::ItemIterator BeginItem (void) const;
static void EnableMetadata (void) NS_DEPRECATED;
/**
* By default, packets do not keep around enough metadata to
* perform the operations requested by the Print methods. If you
* want to be able to invoke any of the two ::Print methods,
* you need to invoke this method at least once during the
* simulation setup and before any packet is created.
*
*/
static void EnablePrinting (void);
/**
* The packet metadata is also used to perform extensive
* sanity checks at runtime when performing operations on a
* Packet. For example, this metadata is used to verify that
@@ -324,7 +329,7 @@ public:
* was actually present at the front of the packet. These
* errors will be detected and will abort the program.
*/
static void EnableMetadata (void);
static void EnableChecking (void);
/**
* \returns a byte buffer

View File

@@ -61,7 +61,7 @@ BridgeNetDevice::BridgeNetDevice ()
}
void
BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<Packet> packet, uint16_t protocol,
BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol,
Address const &src, Address const &dst, PacketType packetType)
{
NS_LOG_FUNCTION_NOARGS ();
@@ -97,7 +97,7 @@ BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<Packet> pac
}
void
BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
uint16_t protocol, Mac48Address src, Mac48Address dst)
{
NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
@@ -130,7 +130,7 @@ BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet
}
void
BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
uint16_t protocol, Mac48Address src, Mac48Address dst)
{
NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()

View File

@@ -111,11 +111,11 @@ public:
protected:
virtual void DoDispose (void);
void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
Address const &source, Address const &destination, PacketType packetType);
void ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
void ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
uint16_t protocol, Mac48Address src, Mac48Address dst);
void ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
void ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
uint16_t protocol, Mac48Address src, Mac48Address dst);
void Learn (Mac48Address source, Ptr<NetDevice> port);
Ptr<NetDevice> GetLearnedState (Mac48Address source);

View File

@@ -670,27 +670,6 @@ CsmaNetDevice::Receive (Ptr<Packet> packet, Ptr<CsmaNetDevice> senderDevice)
NS_LOG_LOGIC ("Pkt source is " << header.GetSource ());
NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
//
// An IP host group address is mapped to an Ethernet multicast address
// by placing the low-order 23-bits of the IP address into the low-order
// 23 bits of the Ethernet multicast address 01-00-5E-00-00-00 (hex).
//
// We are going to receive all packets destined to any multicast address,
// which means clearing the low-order 23 bits the header destination
//
Mac48Address mcDest;
uint8_t mcBuf[6];
header.GetDestination ().CopyTo (mcBuf);
mcBuf[3] &= 0x80;
mcBuf[4] = 0;
mcBuf[5] = 0;
mcDest.CopyFrom (mcBuf);
Mac48Address multicast = Mac48Address::ConvertFrom (GetMulticast ());
Mac48Address broadcast = Mac48Address::ConvertFrom (GetBroadcast ());
Mac48Address destination = Mac48Address::ConvertFrom (GetAddress ());
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
{
NS_LOG_LOGIC ("Dropping pkt due to error model ");
@@ -723,17 +702,17 @@ CsmaNetDevice::Receive (Ptr<Packet> packet, Ptr<CsmaNetDevice> senderDevice)
PacketType packetType;
if (header.GetDestination () == broadcast)
if (header.GetDestination ().IsBroadcast ())
{
packetType = PACKET_BROADCAST;
m_rxTrace (originalPacket);
}
else if (mcDest == multicast)
else if (header.GetDestination ().IsMulticast ())
{
packetType = PACKET_MULTICAST;
m_rxTrace (originalPacket);
}
else if (header.GetDestination () == destination)
else if (header.GetDestination () == m_address)
{
packetType = PACKET_HOST;
m_rxTrace (originalPacket);
@@ -855,65 +834,24 @@ CsmaNetDevice::IsMulticast (void) const
CsmaNetDevice::GetMulticast (void) const
{
NS_LOG_FUNCTION_NOARGS ();
return Mac48Address ("01:00:5e:00:00:00");
return Mac48Address::GetMulticastPrefix ();
}
Address
CsmaNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
{
NS_LOG_FUNCTION (multicastGroup);
//
// First, get the generic multicast address.
//
Address hardwareDestination = GetMulticast ();
NS_LOG_LOGIC ("Device multicast address: " << hardwareDestination);
//
// It's our address, and we know we're playing with an EUI-48 address here
// primarily since we know that by construction, but also since the parameter
// is an Ipv4Address.
//
Mac48Address etherAddr = Mac48Address::ConvertFrom (hardwareDestination);
//
// We now have the multicast address in an abstract 48-bit container. We
// need to pull it out so we can play with it. When we're done, we have the
// high order bits in etherBuffer[0], etc.
//
uint8_t etherBuffer[6];
etherAddr.CopyTo (etherBuffer);
//
// Now we need to pull the raw bits out of the Ipv4 destination address.
//
uint8_t ipBuffer[4];
multicastGroup.Serialize (ipBuffer);
//
// RFC 1112 says that an Ipv4 host group address is mapped to an EUI-48
// multicast address by placing the low-order 23-bits of the IP address into
// the low-order 23 bits of the Ethernet multicast address
// 01-00-5E-00-00-00 (hex).
//
etherBuffer[3] |= ipBuffer[1] & 0x7f;
etherBuffer[4] = ipBuffer[2];
etherBuffer[5] = ipBuffer[3];
//
// Now, etherBuffer has the desired ethernet multicast address. We have to
// suck these bits back into the Mac48Address,
//
etherAddr.CopyFrom (etherBuffer);
Mac48Address ad = Mac48Address::GetMulticast (multicastGroup);
//
// Implicit conversion (operator Address ()) is defined for Mac48Address, so
// use it by just returning the EUI-48 address which is automagically converted
// to an Address.
//
NS_LOG_LOGIC ("multicast address is " << etherAddr);
NS_LOG_LOGIC ("multicast address is " << ad);
return etherAddr;
return ad;
}
bool

View File

@@ -255,12 +255,12 @@ WifiNetDevice::IsMulticast (void) const
Address
WifiNetDevice::GetMulticast (void) const
{
return Mac48Address ("01:00:5e:00:00:00");
return Mac48Address::GetMulticastPrefix ();
}
Address
WifiNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
{
return GetMulticast ();
return Mac48Address::GetMulticast (multicastGroup);
}
bool
WifiNetDevice::IsPointToPoint (void) const

View File

@@ -122,7 +122,7 @@ CsmaHelper::EnablePcapAll (std::string filename)
void
CsmaHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
{
Packet::EnableMetadata ();
Packet::EnablePrinting ();
std::ostringstream oss;
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::CsmaNetDevice/Rx";
Config::Connect (oss.str (), MakeBoundCallback (&CsmaHelper::AsciiRxEvent, &os));

View File

@@ -122,7 +122,7 @@ PointToPointHelper::EnablePcapAll (std::string filename)
void
PointToPointHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
{
Packet::EnableMetadata ();
Packet::EnablePrinting ();
std::ostringstream oss;
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::PointToPointNetDevice/Rx";
Config::Connect (oss.str (), MakeBoundCallback (&PointToPointHelper::AsciiRxEvent, &os));

View File

@@ -193,7 +193,7 @@ WifiHelper::EnablePcapAll (std::string filename)
void
WifiHelper::EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid)
{
Packet::EnableMetadata ();
Packet::EnablePrinting ();
std::ostringstream oss;
oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/RxOk";
Config::Connect (oss.str (), MakeBoundCallback (&AsciiPhyRxOkEvent, &os));

View File

@@ -117,11 +117,13 @@ ArpL3Protocol::FindCache (Ptr<NetDevice> device)
}
void
ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION_NOARGS ();
Ptr<Packet> packet = p->Copy ();
Ptr<ArpCache> cache = FindCache (device);
ArpHeader arp;
packet->RemoveHeader (arp);

View File

@@ -54,7 +54,7 @@ public:
/**
* \brief Receive a packet
*/
void Receive(Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from, const Address &to,
void Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
NetDevice::PacketType packetType);
/**
* \brief Perform an ARP lookup

View File

@@ -449,13 +449,15 @@ Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
}
void
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION (this << &device << packet << protocol << from);
NS_LOG_FUNCTION (this << &device << p << protocol << from);
NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ());
Ptr<Packet> packet = p->Copy ();
uint32_t index = 0;
Ptr<Ipv4Interface> ipv4Interface;
for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();

View File

@@ -83,7 +83,7 @@ public:
* - implement a per-NetDevice ARP cache
* - send back arp replies on the right device
*/
void Receive( Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from,
void Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType);
/**

View File

@@ -143,6 +143,18 @@ Mac48Address::IsBroadcast (void) const
}
bool
Mac48Address::IsMulticast (void) const
{
uint8_t mcBuf[6];
CopyTo (mcBuf);
mcBuf[3] &= 0x80;
mcBuf[4] = 0;
mcBuf[5] = 0;
Mac48Address prefix;
prefix.CopyFrom (mcBuf);
return prefix == Mac48Address::GetMulticastPrefix ();
}
bool
Mac48Address::IsGroup (void) const
{
return (m_address[0] & 0x01) == 0x01;
}
@@ -152,6 +164,48 @@ Mac48Address::GetBroadcast (void)
static Mac48Address broadcast = Mac48Address ("ff:ff:ff:ff:ff:ff");
return broadcast;
}
Mac48Address
Mac48Address::GetMulticastPrefix (void)
{
static Mac48Address multicast = Mac48Address ("01:00:5e:00:00:00");
return multicast;
}
Mac48Address
Mac48Address::GetMulticast (Ipv4Address multicastGroup)
{
Mac48Address etherAddr = Mac48Address::GetMulticastPrefix ();
//
// We now have the multicast address in an abstract 48-bit container. We
// need to pull it out so we can play with it. When we're done, we have the
// high order bits in etherBuffer[0], etc.
//
uint8_t etherBuffer[6];
etherAddr.CopyTo (etherBuffer);
//
// Now we need to pull the raw bits out of the Ipv4 destination address.
//
uint8_t ipBuffer[4];
multicastGroup.Serialize (ipBuffer);
//
// RFC 1112 says that an Ipv4 host group address is mapped to an EUI-48
// multicast address by placing the low-order 23-bits of the IP address into
// the low-order 23 bits of the Ethernet multicast address
// 01-00-5E-00-00-00 (hex).
//
etherBuffer[3] |= ipBuffer[1] & 0x7f;
etherBuffer[4] = ipBuffer[2];
etherBuffer[5] = ipBuffer[3];
//
// Now, etherBuffer has the desired ethernet multicast address. We have to
// suck these bits back into the Mac48Address,
//
Mac48Address result;
result.CopyFrom (etherBuffer);
return result;
}
bool operator == (const Mac48Address &a, const Mac48Address &b)
{

View File

@@ -24,6 +24,7 @@
#include <ostream>
#include "ns3/attribute.h"
#include "ns3/attribute-helper.h"
#include "ipv4-address.h"
namespace ns3 {
@@ -92,12 +93,25 @@ public:
* \returns true if this is a multicast address, false otherwise.
*/
bool IsMulticast (void) const;
/**
* \returns true if the group bit is set, false otherwise.
*/
bool IsGroup (void) const;
/**
* \returns the broadcast address
*/
static Mac48Address GetBroadcast (void);
/**
* \returns a multicast address
*/
static Mac48Address GetMulticast (Ipv4Address address);
/**
* \returns the multicast prefix (01:00:5e:00:00:00).
*/
static Mac48Address GetMulticastPrefix (void);
private:
/**
* \returns a new Address instance

View File

@@ -20,6 +20,7 @@
#include "ns3/object.h"
#include "ns3/log.h"
#include "ns3/uinteger.h"
#include "net-device.h"
NS_LOG_COMPONENT_DEFINE ("NetDevice");
@@ -31,7 +32,15 @@ NS_OBJECT_ENSURE_REGISTERED (NetDevice);
TypeId NetDevice::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::NetDevice")
.SetParent<Object> ();
.SetParent<Object> ()
.AddAttribute ("Mtu", "The MAC-level Maximum Transmission Unit",
TypeId::ATTR_SET | TypeId::ATTR_GET,
UintegerValue (0xffff),
MakeUintegerAccessor (&NetDevice::SetMtu,
&NetDevice::GetMtu),
MakeUintegerChecker<uint16_t> ())
;
return tid;
}

View File

@@ -274,7 +274,7 @@ public:
* \returns true if the callback could handle the packet successfully, false
* otherwise.
*/
typedef Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &> ReceiveCallback;
typedef Callback<bool,Ptr<NetDevice>,Ptr<const Packet>,uint16_t,const Address &> ReceiveCallback;
/**
* \param cb callback to invoke whenever a packet has been received and must
@@ -296,8 +296,8 @@ public:
* \returns true if the callback could handle the packet successfully, false
* otherwise.
*/
typedef Callback< bool, Ptr<NetDevice>, Ptr<Packet>, uint16_t,
const Address &, const Address &, PacketType > PromiscReceiveCallback;
typedef Callback< bool, Ptr<NetDevice>, Ptr<const Packet>, uint16_t,
const Address &, const Address &, enum PacketType > PromiscReceiveCallback;
/**
* \param cb callback to invoke whenever a packet has been received in promiscuous mode and must

View File

@@ -222,7 +222,7 @@ Node::UnregisterProtocolHandler (ProtocolHandler handler)
}
bool
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
const Address &from, const Address &to, NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION(device->GetName ());
@@ -230,7 +230,7 @@ Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint1
}
bool
Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
const Address &from)
{
NS_LOG_FUNCTION(device->GetName ());
@@ -238,15 +238,11 @@ Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, ui
}
bool
Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous)
{
NS_LOG_FUNCTION(device->GetName ());
bool found = false;
// if there are (potentially) multiple handlers, we need to copy the
// packet before passing it to each handler, because handlers may
// modify it.
bool copyNeeded = (m_handlers.size () > 1);
for (ProtocolHandlerList::iterator i = m_handlers.begin ();
i != m_handlers.end (); i++)
@@ -259,7 +255,7 @@ Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t pro
{
if (promiscuous == i->promiscuous)
{
i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, packetType);
i->handler (device, packet->Copy (), protocol, from, to, packetType);
found = true;
}
}

View File

@@ -145,7 +145,7 @@ public:
* this value is only valid for promiscuous mode
* protocol handlers.
*/
typedef Callback<void,Ptr<NetDevice>, Ptr<Packet>,uint16_t,const Address &,
typedef Callback<void,Ptr<NetDevice>, Ptr<const Packet>,uint16_t,const Address &,
const Address &, NetDevice::PacketType> ProtocolHandler;
/**
* \param handler the handler to register
@@ -189,10 +189,10 @@ private:
*/
virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol, const Address &from);
bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol, const Address &from);
bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
const Address &from, const Address &to, NetDevice::PacketType packetType);
bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc);
void Construct (void);

View File

@@ -344,7 +344,7 @@ PacketSocket::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address)
}
void
PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet,
PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet,
uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType)
{
@@ -369,7 +369,7 @@ PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet,
SocketAddressTag tag;
tag.SetAddress (address);
packet->AddTag (tag);
m_deliveryQueue.push (packet);
m_deliveryQueue.push (packet->Copy ());
m_rxAvailable += packet->GetSize ();
NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this);
NotifyDataRecv ();

View File

@@ -103,7 +103,7 @@ public:
Address &fromAddress);
private:
void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet,
void ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet,
uint16_t protocol, const Address &from, const Address &to,
NetDevice::PacketType packetType);
int DoBind (const PacketSocketAddress &address);

View File

@@ -142,12 +142,12 @@ SimpleNetDevice::IsMulticast (void) const
Address
SimpleNetDevice::GetMulticast (void) const
{
return Mac48Address ("01:00:5e:00:00:00");
return Mac48Address::GetMulticastPrefix ();
}
Address
SimpleNetDevice::MakeMulticastAddress (Ipv4Address multicastGroup) const
{
return Mac48Address ("01:00:5e:00:00:00");
return Mac48Address::GetMulticast (multicastGroup);
}
bool
SimpleNetDevice::IsPointToPoint (void) const

View File

@@ -282,7 +282,7 @@ int main (int argc, char *argv[])
runBench (&benchC, n, "c");
runBench (&benchD, n, "d");
Packet::EnableMetadata ();
Packet::EnablePrinting ();
runBench (&benchA, n, "meta-a");
runBench (&benchB, n, "meta-b");
runBench (&benchC, n, "meta-c");