diff -r b4c6f109d50d src/devices/uan/model/uan-net-device.cc --- a/src/devices/uan/model/uan-net-device.cc Wed Oct 06 16:30:08 2010 +0200 +++ b/src/devices/uan/model/uan-net-device.cc Wed Oct 06 19:42:13 2010 +0200 @@ -389,5 +389,11 @@ m_mac->SetAddress (UanAddress::ConvertFrom (address)); } +void +UanNetDevice::SetSleepMode (bool sleep) +{ + m_phy->SetSleepMode (sleep); +} + } // namespace ns3 diff -r b4c6f109d50d src/devices/uan/model/uan-net-device.h --- a/src/devices/uan/model/uan-net-device.h Wed Oct 06 16:30:08 2010 +0200 +++ b/src/devices/uan/model/uan-net-device.h Wed Oct 06 19:42:13 2010 +0200 @@ -95,6 +95,8 @@ */ void Clear (void); + void SetSleepMode (bool sleep); + // Purely virtual functions from base class virtual void SetIfIndex (const uint32_t index); virtual uint32_t GetIfIndex (void) const; diff -r b4c6f109d50d src/devices/uan/model/uan-phy-dual.h --- a/src/devices/uan/model/uan-phy-dual.h Wed Oct 06 16:30:08 2010 +0200 +++ b/src/devices/uan/model/uan-phy-dual.h Wed Oct 06 19:42:13 2010 +0200 @@ -247,6 +247,11 @@ */ void SetSinrModelPhy2 (Ptr calcSinr); + virtual void SetSleepMode (bool sleep) + { + //TODO This method has to be implemented + } + /** * \returns Packet currently being received on Phy1 (Null Ptr if none) */ diff -r b4c6f109d50d src/devices/uan/model/uan-phy-gen.cc --- a/src/devices/uan/model/uan-phy-gen.cc Wed Oct 06 16:30:08 2010 +0200 +++ b/src/devices/uan/model/uan-phy-gen.cc Wed Oct 06 19:42:13 2010 +0200 @@ -525,6 +525,11 @@ NS_LOG_DEBUG ("PHY requested to TX while already Transmitting. Dropping packet."); return; } + else if (m_state == SLEEP) + { + NS_LOG_DEBUG ("PHY requested to TX while sleeping. Dropping packet."); + return; + } UanTxMode txMode = GetMode (modeNum); @@ -547,6 +552,12 @@ void UanPhyGen::TxEndEvent () { + if (m_state == SLEEP || m_disabled == true) + { + NS_LOG_DEBUG ("Transmission ended but node sleeping or dead"); + return; + } + NS_ASSERT (m_state == TX); if (GetInterferenceDb ( (Ptr) 0) > m_ccaThreshDb) { @@ -632,7 +643,7 @@ } break; case SLEEP: - NS_FATAL_ERROR ("SLEEP state handling not yet implemented!"); + NS_LOG_DEBUG ("Sleep mode. Dropping packet."); break; } @@ -652,6 +663,13 @@ return; } + if (m_disabled || m_state == SLEEP) + { + NS_LOG_DEBUG ("Sleep mode or dead. Dropping packet"); + m_pktRx = 0; + return; + } + if (GetInterferenceDb ( (Ptr) 0) > m_ccaThreshDb) { m_state = CCABUSY; @@ -817,6 +835,26 @@ m_transducer->AddPhy (this); } +void +UanPhyGen::SetSleepMode (bool sleep) +{ + if (sleep) + { + m_state = SLEEP; + if (!m_energyCallback.IsNull ()) + { + m_energyCallback (SLEEP); + } + } + else + { + m_state = IDLE; + if (!m_energyCallback.IsNull ()) + { + m_energyCallback (IDLE); + } + } +} void UanPhyGen::NotifyTransStartTx (Ptr packet, double txPowerDb, UanTxMode txMode) diff -r b4c6f109d50d src/devices/uan/model/uan-phy-gen.h --- a/src/devices/uan/model/uan-phy-gen.h Wed Oct 06 16:30:08 2010 +0200 +++ b/src/devices/uan/model/uan-phy-gen.h Wed Oct 06 19:42:13 2010 +0200 @@ -203,6 +203,8 @@ virtual Ptr GetPacketRx (void) const; virtual void Clear (void); + virtual void SetSleepMode (bool sleep); + private: typedef std::list ListenerList; diff -r b4c6f109d50d src/devices/uan/model/uan-phy.h --- a/src/devices/uan/model/uan-phy.h Wed Oct 06 16:30:08 2010 +0200 +++ b/src/devices/uan/model/uan-phy.h Wed Oct 06 19:42:13 2010 +0200 @@ -373,6 +373,8 @@ * Clears all pointer references */ virtual void Clear (void) = 0; + + virtual void SetSleepMode (bool sleep) = 0; }; }