Add MacPromiscRx, make MacRx non-promisc

This commit is contained in:
Craig Dowell
2009-03-18 23:36:37 -07:00
parent e7b57ecce4
commit 389da6fb21
12 changed files with 87 additions and 21 deletions

View File

@@ -98,8 +98,13 @@ CsmaNetDevice::GetTypeId (void)
.AddTraceSource ("MacTxDrop",
"Trace source indicating a packet has been dropped by the device before transmission",
MakeTraceSourceAccessor (&CsmaNetDevice::m_macTxDropTrace))
.AddTraceSource ("MacPromiscRx",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a promiscuous trace,",
MakeTraceSourceAccessor (&CsmaNetDevice::m_macPromiscRxTrace))
.AddTraceSource ("MacRx",
"Trace source indicating a packet has been received by this device and is being forwarded up the stack",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
MakeTraceSourceAccessor (&CsmaNetDevice::m_macRxTrace))
#if 0
// Not currently implemented in this device
@@ -831,6 +836,7 @@ CsmaNetDevice::Receive (Ptr<Packet> packet, Ptr<CsmaNetDevice> senderDevice)
m_promiscSnifferTrace (originalPacket);
if (!m_promiscRxCallback.IsNull ())
{
m_macPromiscRxTrace (originalPacket);
m_promiscRxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType);
}

View File

@@ -662,7 +662,16 @@ private:
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition).
* transition). This is a promiscuous trace.
*
* \see class CallBackTraceSource
*/
TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition). This is a non-promiscuous trace.
*
* \see class CallBackTraceSource
*/

View File

@@ -110,8 +110,13 @@ EmuNetDevice::GetTypeId (void)
.AddTraceSource ("MacTxDrop",
"Trace source indicating a packet has been dropped by the device before transmission",
MakeTraceSourceAccessor (&EmuNetDevice::m_macTxDropTrace))
.AddTraceSource ("MacPromiscRx",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a promiscuous trace,",
MakeTraceSourceAccessor (&EmuNetDevice::m_macPromiscRxTrace))
.AddTraceSource ("MacRx",
"Trace source indicating a packet has been received by this device and is being forwarded up the stack",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
MakeTraceSourceAccessor (&EmuNetDevice::m_macRxTrace))
#if 0
// Not currently implemented for this device
@@ -646,6 +651,7 @@ EmuNetDevice::ForwardUp (uint8_t *buf, uint32_t len)
if (!m_promiscRxCallback.IsNull ())
{
m_macPromiscRxTrace (originalPacket);
m_promiscRxCallback (this, packet, protocol, header.GetSource (), header.GetDestination (), packetType);
}

View File

@@ -282,7 +282,16 @@ private:
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition).
* transition). This is a promiscuous trace.
*
* \see class CallBackTraceSource
*/
TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition). This is a non-promiscuous trace.
*
* \see class CallBackTraceSource
*/

View File

@@ -88,8 +88,13 @@ PointToPointNetDevice::GetTypeId (void)
.AddTraceSource ("MacTxDrop",
"Trace source indicating a packet has been dropped by the device before transmission",
MakeTraceSourceAccessor (&PointToPointNetDevice::m_macTxDropTrace))
.AddTraceSource ("MacPromiscRx",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a promiscuous trace,",
MakeTraceSourceAccessor (&PointToPointNetDevice::m_macPromiscRxTrace))
.AddTraceSource ("MacRx",
"Trace source indicating a packet has been received by this device and is being forwarded up the stack",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
MakeTraceSourceAccessor (&PointToPointNetDevice::m_macRxTrace))
#if 0
// Not currently implemented for this device
@@ -324,12 +329,12 @@ PointToPointNetDevice::Receive (Ptr<Packet> packet)
{
//
// Hit the trace hooks. All of these hooks are in the same place in this
// device becuase it is so simple, but this is not usually the case.
// device becuase it is so simple, but this is not usually the case in
// more complicated devices.
//
m_snifferTrace (packet);
m_promiscSnifferTrace (packet);
m_phyRxEndTrace (packet);
m_macRxTrace (packet);
//
// Strip off the point-to-point protocol header and forward this packet
@@ -341,9 +346,11 @@ PointToPointNetDevice::Receive (Ptr<Packet> packet)
if (!m_promiscCallback.IsNull ())
{
m_macPromiscRxTrace (packet);
m_promiscCallback (this, packet, protocol, GetRemote (), GetAddress (), NetDevice::PACKET_HOST);
}
m_macRxTrace (packet);
m_rxCallback (this, packet, protocol, GetRemote ());
}
}

View File

@@ -411,7 +411,18 @@ private:
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition).
* transition). This is a promiscuous trace (which doesn't mean a lot here
* in the point-to-point device).
*
* \see class CallBackTraceSource
*/
TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition). This is a non-promiscuous trace (which doesn't mean a lot
* here in the point-to-point device).
*
* \see class CallBackTraceSource
*/

View File

@@ -235,7 +235,6 @@ AdhocWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
destination->RecordDisassociated ();
}
NotifyTx (packet);
m_dca->Queue (packet, hdr);
}
bool
@@ -248,7 +247,6 @@ void
AdhocWifiMac::ForwardUp (Ptr<Packet> packet, WifiMacHeader const *hdr)
{
NS_LOG_DEBUG ("received size="<<packet->GetSize ()<<", from="<<hdr->GetAddr2 ());
NotifyRx (packet);
m_upCallback (packet, hdr->GetAddr2 (), hdr->GetAddr1 ());
}
Ptr<DcaTxop>

View File

@@ -286,7 +286,6 @@ void
NqapWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
{
NS_LOG_FUNCTION (this << packet << from);
NotifyRx (packet);
m_upCallback (packet, from, to);
}
@@ -302,7 +301,6 @@ NqapWifiMac::ForwardDown (Ptr<const Packet> packet, Mac48Address from, Mac48Addr
hdr.SetDsFrom ();
hdr.SetDsNotTo ();
NotifyTx (packet);
m_dca->Queue (packet, hdr);
}
void

View File

@@ -322,7 +322,6 @@ void
NqstaWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
{
NS_LOG_FUNCTION (this << packet << from << to);
NotifyRx (packet);
m_forwardUp (packet, from, to);
}
void
@@ -481,7 +480,6 @@ NqstaWifiMac::Enqueue (Ptr<const Packet> packet, Mac48Address to)
hdr.SetDsNotFrom ();
hdr.SetDsTo ();
NotifyTx (packet);
m_dca->Queue (packet, hdr);
}

View File

@@ -124,9 +124,13 @@ WifiMac::GetTypeId (void)
.AddTraceSource ("MacTxDrop",
"A packet has been dropped in the MAC layer before being queued for transmission.",
MakeTraceSourceAccessor (&WifiMac::m_macTxDropTrace))
.AddTraceSource ("MacPromiscRx",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack. This is a promiscuous trace,",
MakeTraceSourceAccessor (&WifiMac::m_macPromiscRxTrace))
.AddTraceSource ("MacRx",
"A packet has been received by this device, has been passed up from the physical layer "
"and is being forwarded up the local protocol stack.",
"and is being forwarded up the local protocol stack. This is a non-promiscuous trace,",
MakeTraceSourceAccessor (&WifiMac::m_macRxTrace))
.AddTraceSource ("MacRxDrop",
"A packet has been dropped in the MAC layer after it has been passed up from the physical "
@@ -184,6 +188,12 @@ WifiMac::NotifyRx (Ptr<const Packet> packet)
m_macRxTrace (packet);
}
void
WifiMac::NotifyPromiscRx (Ptr<const Packet> packet)
{
m_macPromiscRxTrace (packet);
}
void
WifiMac::NotifyRxDrop (Ptr<const Packet> packet)
{

View File

@@ -195,6 +195,12 @@ public:
*/
void NotifyRx (Ptr<const Packet> packet);
/**
* Public method used to fire a MacPromiscRx trace. Implemented for encapsulation
* purposes.
*/
void NotifyPromiscRx (Ptr<const Packet> packet);
/**
* Public method used to fire a MacRxDrop trace. Implemented for encapsulation
* purposes.
@@ -231,7 +237,16 @@ private:
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition).
* transition). This is a promiscuous trace.
*
* \see class CallBackTraceSource
*/
TracedCallback<Ptr<const Packet> > m_macPromiscRxTrace;
/**
* The trace source fired for packets successfully received by the device
* immediately before being forwarded up to higher layers (at the L2/L3
* transition). This is a non- promiscuous trace.
*
* \see class CallBackTraceSource
*/

View File

@@ -250,8 +250,7 @@ WifiNetDevice::Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolN
llc.SetType (protocolNumber);
packet->AddHeader (llc);
m_txLogger (packet, realTo);
m_mac->NotifyTx (packet);
m_mac->Enqueue (packet, realTo);
return true;
}
@@ -280,7 +279,6 @@ WifiNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
void
WifiNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
{
m_rxLogger (packet, from);
LlcSnapHeader llc;
packet->RemoveHeader (llc);
enum NetDevice::PacketType type;
@@ -303,11 +301,13 @@ WifiNetDevice::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to
if (type != NetDevice::PACKET_OTHERHOST)
{
m_mac->NotifyRx (packet);
m_forwardUp (this, packet, llc.GetType (), from);
}
if (!m_promiscRx.IsNull ())
{
m_mac->NotifyPromiscRx (packet);
m_promiscRx (this, packet, llc.GetType (), from, to, type);
}
}
@@ -344,8 +344,7 @@ WifiNetDevice::SendFrom (Ptr<Packet> packet, const Address& source, const Addres
llc.SetType (protocolNumber);
packet->AddHeader (llc);
m_txLogger (packet, realTo);
m_mac->NotifyTx (packet);
m_mac->Enqueue (packet, realTo, realFrom);
return true;