--- a/src/devices/wifi/adhoc-wifi-mac.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/adhoc-wifi-mac.cc Fri Nov 07 17:18:10 2008 +0000 @@ -18,6 +18,10 @@ * Author: Mathieu Lacage */ +#define NS_LOG_APPEND_CONTEXT if (m_netdevice) { std::clog << "[node " << \ + (m_netdevice->GetNode ()? m_netdevice->GetNode ()->GetId () : -1) \ + << " dev " << m_netdevice->GetIfIndex () << "] "; } + #include "adhoc-wifi-mac.h" #include "dca-txop.h" #include "mac-low.h" @@ -26,6 +30,7 @@ #include "dcf-manager.h" #include "ns3/packet.h" #include "ns3/log.h" +#include "ns3/node.h" NS_LOG_COMPONENT_DEFINE ("AdhocWifiMac"); @@ -74,6 +79,13 @@ m_dca = 0; m_stationManager = 0; WifiMac::DoDispose (); +} + +void +AdhocWifiMac::SetNetDevice (Ptr netdevice) +{ + WifiMac::SetNetDevice (netdevice); + m_low->SetNetDevice (netdevice); } void --- a/src/devices/wifi/adhoc-wifi-mac.h Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/adhoc-wifi-mac.h Fri Nov 07 17:18:10 2008 +0000 @@ -78,6 +78,7 @@ virtual void SetAddress (Mac48Address address); virtual void SetSsid (Ssid ssid); virtual Mac48Address GetBssid (void) const; + virtual void SetNetDevice (Ptr netdevice); private: // inherited from Object base class. --- a/src/devices/wifi/mac-low.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/mac-low.cc Fri Nov 07 17:18:10 2008 +0000 @@ -17,6 +17,10 @@ * * Author: Mathieu Lacage */ + +#define NS_LOG_APPEND_CONTEXT if (m_netdevice) { std::clog << "[node " << \ + (m_netdevice->GetNode ()? m_netdevice->GetNode ()->GetId () : -1) \ + << " dev " << m_netdevice->GetIfIndex () << "] "; } #include "ns3/assert.h" #include "ns3/packet.h" @@ -330,6 +334,12 @@ m_listener->Cancel (); m_listener = 0; } +} + +void +MacLow::SetNetDevice (Ptr netdevice) +{ + m_netdevice = netdevice; } void --- a/src/devices/wifi/mac-low.h Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/mac-low.h Fri Nov 07 17:18:10 2008 +0000 @@ -33,6 +33,7 @@ #include "ns3/event-id.h" #include "ns3/packet.h" #include "ns3/nstime.h" +#include "ns3/net-device.h" namespace ns3 { @@ -288,6 +289,7 @@ void SetSlotTime (Time slotTime); void SetPifs (Time pifs); void SetBssid (Mac48Address ad); + void SetNetDevice (Ptr netdevice); Mac48Address GetAddress (void) const; Time GetAckTimeout (void) const; Time GetCtsTimeout (void) const; @@ -427,6 +429,8 @@ Time m_lastNavStart; Time m_lastNavDuration; + + Ptr m_netdevice; }; } // namespace ns3 --- a/src/devices/wifi/nqap-wifi-mac.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/nqap-wifi-mac.cc Fri Nov 07 17:18:10 2008 +0000 @@ -17,6 +17,11 @@ * * Author: Mathieu Lacage */ + +#define NS_LOG_APPEND_CONTEXT if (m_netdevice) { std::clog << "[node " << \ + (m_netdevice->GetNode ()? m_netdevice->GetNode ()->GetId () : -1) \ + << " dev " << m_netdevice->GetIfIndex () << "] "; } + #include "ns3/assert.h" #include "ns3/log.h" #include "ns3/simulator.h" @@ -98,6 +103,13 @@ m_beaconDca = 0; m_beaconEvent.Cancel (); WifiMac::DoDispose (); +} + +void +NqapWifiMac::SetNetDevice (Ptr netdevice) +{ + WifiMac::SetNetDevice (netdevice); + m_low->SetNetDevice (netdevice); } void --- a/src/devices/wifi/nqap-wifi-mac.h Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/nqap-wifi-mac.h Fri Nov 07 17:18:10 2008 +0000 @@ -84,6 +84,7 @@ virtual void SetAddress (Mac48Address address); virtual void SetSsid (Ssid ssid); virtual Mac48Address GetBssid (void) const; + virtual void SetNetDevice (Ptr netdevice); /** * \param interval the interval between two beacon transmissions. --- a/src/devices/wifi/nqsta-wifi-mac.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/nqsta-wifi-mac.cc Fri Nov 07 17:18:10 2008 +0000 @@ -18,6 +18,11 @@ * Author: Mathieu Lacage */ +#define NS_LOG_APPEND_CONTEXT if (m_netdevice) { std::clog << "[node " << \ + (m_netdevice->GetNode ()? m_netdevice->GetNode ()->GetId () : -1) \ + << " dev " << m_netdevice->GetIfIndex () << "] "; } + + #include "ns3/packet.h" #include "ns3/simulator.h" #include "ns3/assert.h" @@ -36,6 +41,7 @@ #include "mac-rx-middle.h" NS_LOG_COMPONENT_DEFINE ("NqstaWifiMac"); + /* * The state machine for this NQSTA is: @@ -131,6 +137,13 @@ m_phy = 0; m_dca = 0; WifiMac::DoDispose (); +} + +void +NqstaWifiMac::SetNetDevice (Ptr netdevice) +{ + WifiMac::SetNetDevice (netdevice); + m_low->SetNetDevice (netdevice); } void --- a/src/devices/wifi/nqsta-wifi-mac.h Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/nqsta-wifi-mac.h Fri Nov 07 17:18:10 2008 +0000 @@ -86,6 +86,7 @@ virtual void SetAddress (Mac48Address address); virtual void SetSsid (Ssid ssid); virtual Mac48Address GetBssid (void) const; + virtual void SetNetDevice (Ptr netdevice); /** * \param missed the number of beacons which must be missed --- a/src/devices/wifi/wifi-mac-header.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/wifi-mac-header.cc Fri Nov 07 17:18:10 2008 +0000 @@ -779,9 +779,9 @@ void WifiMacHeader::PrintFrameControl (std::ostream &os) const { - os << "ToDS=" << m_ctrlToDs << ", FromDS=" << m_ctrlFromDs - << ", MoreFrag=" << m_ctrlMoreFrag << ", Retry=" << m_ctrlRetry - << ", MoreData=" << m_ctrlMoreData + os << "ToDS=" << int (m_ctrlToDs) << ", FromDS=" << int (m_ctrlFromDs) + << ", MoreFrag=" << int (m_ctrlMoreFrag) << ", Retry=" << int (m_ctrlRetry) + << ", MoreData=" << int (m_ctrlMoreData) ; } @@ -818,8 +818,8 @@ PrintFrameControl (os); os << " Duration/ID=" << m_duration << "us" << ", DA=" << m_addr1 << ", SA=" << m_addr2 - << ", BSSID=" << m_addr3 << ", FragNumber=" << m_seqFrag - << ", SeqNumber=" << m_seqSeq; + << ", BSSID=" << m_addr3 << ", FragNumber=" << int (m_seqFrag) + << ", SeqNumber=" << int (m_seqSeq); break; case WIFI_MAC_DATA: PrintFrameControl (os); @@ -844,8 +844,8 @@ { NS_ASSERT (false); } - os << ", FragNumber=" << m_seqFrag - << ", SeqNumber=" << m_seqSeq; + os << ", FragNumber=" << int (m_seqFrag) + << ", SeqNumber=" << int (m_seqSeq); break; case WIFI_MAC_DATA_CFACK: case WIFI_MAC_DATA_CFPOLL: --- a/src/devices/wifi/wifi-mac.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/wifi-mac.cc Fri Nov 07 17:18:10 2008 +0000 @@ -23,6 +23,12 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (WifiMac); + +void +WifiMac::SetNetDevice (Ptr netdevice) +{ + m_netdevice = netdevice; +} Time WifiMac::GetDefaultMaxPropagationDelay (void) --- a/src/devices/wifi/wifi-mac.h Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/wifi-mac.h Fri Nov 07 17:18:10 2008 +0000 @@ -22,6 +22,7 @@ #include "ns3/packet.h" #include "ns3/mac48-address.h" +#include "ns3/net-device.h" #include "ns3/wifi-channel.h" #include "wifi-phy.h" @@ -37,10 +38,12 @@ * DCA, EDCA, etc) and all the high-level MAC functionality * (association/disassociation state machines). * - */ +*/ class WifiMac : public Object { public: + + virtual void SetNetDevice (Ptr netdevice); struct ScanningEntry { @@ -149,6 +152,9 @@ ScanningCallback callback, Ptr netdevice); +protected: + Ptr m_netdevice; + private: friend class WifiNetDevice; /** --- a/src/devices/wifi/wifi-net-device.cc Thu Nov 06 18:36:01 2008 +0000 +++ a/src/devices/wifi/wifi-net-device.cc Fri Nov 07 17:18:10 2008 +0000 @@ -107,6 +107,7 @@ m_mac->SetForwardUpCallback (MakeCallback (&WifiNetDevice::ForwardUp, this)); m_mac->SetLinkUpCallback (MakeCallback (&WifiNetDevice::LinkUp, this)); m_mac->SetLinkDownCallback (MakeCallback (&WifiNetDevice::LinkDown, this)); + m_mac->SetNetDevice (this); } } void