Renaming WifiPhy state SYNC to RX to avoid confusion with "synchronizing".
--- a/examples/wireless/wifi-ap.cc Mon Nov 30 18:20:30 2009 +0100
+++ b/examples/wireless/wifi-ap.cc Mon Nov 30 18:40:35 2009 +0100
@@ -79,25 +79,7 @@
{
if (g_verbose)
{
- std::cout << " state=";
- switch (state) {
- case WifiPhy::SWITCHING:
- std::cout << "switchng";
- break;
- case WifiPhy::TX:
- std::cout << "tx ";
- break;
- case WifiPhy::SYNC:
- std::cout << "sync ";
- break;
- case WifiPhy::CCA_BUSY:
- std::cout << "cca-busy";
- break;
- case WifiPhy::IDLE:
- std::cout << "idle ";
- break;
- }
- std::cout << " start="<<start<<" duration="<<duration<<std::endl;
+ std::cout << " state=" << state << " start=" << start << " duration=" << duration << std::endl;
}
}
--- a/src/devices/wifi/wifi-phy-state-helper.cc Mon Nov 30 18:20:30 2009 +0100
+++ b/src/devices/wifi/wifi-phy-state-helper.cc Mon Nov 30 18:40:35 2009 +0100
@@ -50,13 +50,13 @@
}
WifiPhyStateHelper::WifiPhyStateHelper ()
- : m_syncing (false),
+ : m_rxing (false),
m_endTx (Seconds (0)),
- m_endSync (Seconds (0)),
+ m_endRx (Seconds (0)),
m_endCcaBusy (Seconds (0)),
m_endSwitching (Seconds (0)),
m_startTx (Seconds (0)),
- m_startSync (Seconds (0)),
+ m_startRx (Seconds (0)),
m_startCcaBusy (Seconds (0)),
m_startSwitching (Seconds (0)),
m_previousStateChangeTime (Seconds (0))
@@ -65,14 +65,14 @@
}
void
-WifiPhyStateHelper::SetReceiveOkCallback (WifiPhy::SyncOkCallback callback)
+WifiPhyStateHelper::SetReceiveOkCallback (WifiPhy::RxOkCallback callback)
{
- m_syncOkCallback = callback;
+ m_rxOkCallback = callback;
}
void
-WifiPhyStateHelper::SetReceiveErrorCallback (WifiPhy::SyncErrorCallback callback)
+WifiPhyStateHelper::SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback)
{
- m_syncErrorCallback = callback;
+ m_rxErrorCallback = callback;
}
void
WifiPhyStateHelper::RegisterListener (WifiPhyListener *listener)
@@ -81,12 +81,6 @@
}
bool
-WifiPhyStateHelper::IsStateCcaBusy (void)
-{
- return GetState () == WifiPhy::CCA_BUSY;
-}
-
-bool
WifiPhyStateHelper::IsStateIdle (void)
{
return (GetState () == WifiPhy::IDLE);
@@ -97,9 +91,14 @@
return (GetState () != WifiPhy::IDLE);
}
bool
-WifiPhyStateHelper::IsStateSync (void)
+WifiPhyStateHelper::IsStateCcaBusy (void)
{
- return (GetState () == WifiPhy::SYNC);
+ return (GetState () == WifiPhy::CCA_BUSY);
+}
+bool
+WifiPhyStateHelper::IsStateRx (void)
+{
+ return (GetState () == WifiPhy::RX);
}
bool
WifiPhyStateHelper::IsStateTx (void)
@@ -126,8 +125,8 @@
Time retval;
switch (GetState ()) {
- case WifiPhy::SYNC:
- retval = m_endSync - Simulator::Now ();
+ case WifiPhy::RX:
+ retval = m_endRx - Simulator::Now ();
break;
case WifiPhy::TX:
retval = m_endTx - Simulator::Now ();
@@ -142,8 +141,7 @@
retval = Seconds (0);
break;
default:
- NS_ASSERT (false);
- // NOTREACHED
+ NS_FATAL_ERROR ("Invalid WifiPhy state.");
retval = Seconds (0);
break;
}
@@ -154,34 +152,7 @@
Time
WifiPhyStateHelper::GetLastRxStartTime (void) const
{
- return m_startSync;
-}
-
-const char *
-WifiPhyStateHelper::StateToString (enum WifiPhy::State state)
-{
- switch (state) {
- case WifiPhy::TX:
- return "TX";
- break;
- case WifiPhy::CCA_BUSY:
- return "CCA_BUSY";
- break;
- case WifiPhy::IDLE:
- return "IDLE";
- break;
- case WifiPhy::SYNC:
- return "SYNC";
- break;
- case WifiPhy::SWITCHING:
- return "SWITCHING";
- break;
- default:
- NS_ASSERT (false);
- // quiet compiler
- return "INVALID";
- break;
- }
+ return m_startRx;
}
enum WifiPhy::State
@@ -191,9 +162,9 @@
{
return WifiPhy::TX;
}
- else if (m_syncing)
+ else if (m_rxing)
{
- return WifiPhy::SYNC;
+ return WifiPhy::RX;
}
else if (m_endSwitching > Simulator::Now ())
{
@@ -218,21 +189,21 @@
}
}
void
-WifiPhyStateHelper::NotifySyncStart (Time duration)
+WifiPhyStateHelper::NotifyRxStart (Time duration)
{
for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++) {
(*i)->NotifyRxStart (duration);
}
}
void
-WifiPhyStateHelper::NotifySyncEndOk (void)
+WifiPhyStateHelper::NotifyRxEndOk (void)
{
for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++) {
(*i)->NotifyRxEndOk ();
}
}
void
-WifiPhyStateHelper::NotifySyncEndError (void)
+WifiPhyStateHelper::NotifyRxEndError (void)
{
for (Listeners::const_iterator i = m_listeners.begin (); i != m_listeners.end (); i++) {
(*i)->NotifyRxEndError ();
@@ -257,14 +228,14 @@
WifiPhyStateHelper::LogPreviousIdleAndCcaBusyStates (void)
{
Time now = Simulator::Now ();
- Time idleStart = Max (m_endCcaBusy, m_endSync);
+ Time idleStart = Max (m_endCcaBusy, m_endRx);
idleStart = Max (idleStart, m_endTx);
idleStart = Max (idleStart, m_endSwitching);
NS_ASSERT (idleStart <= now);
- if (m_endCcaBusy > m_endSync &&
+ if (m_endCcaBusy > m_endRx &&
m_endCcaBusy > m_endSwitching &&
m_endCcaBusy > m_endTx) {
- Time ccaBusyStart = Max (m_endTx, m_endSync);
+ Time ccaBusyStart = Max (m_endTx, m_endRx);
ccaBusyStart = Max (ccaBusyStart, m_startCcaBusy);
ccaBusyStart = Max (ccaBusyStart, m_endSwitching);
m_stateLogger (ccaBusyStart, idleStart - ccaBusyStart, WifiPhy::CCA_BUSY);
@@ -280,16 +251,16 @@
NotifyTxStart (txDuration);
Time now = Simulator::Now ();
switch (GetState ()) {
- case WifiPhy::SYNC:
+ case WifiPhy::RX:
/* The packet which is being received as well
- * as its endSync event are cancelled by the caller.
+ * as its endRx event are cancelled by the caller.
*/
- m_syncing = false;
- m_stateLogger (m_startSync, now - m_startSync, WifiPhy::SYNC);
- m_endSync = now;
+ m_rxing = false;
+ m_stateLogger (m_startRx, now - m_startRx, WifiPhy::RX);
+ m_endRx = now;
break;
case WifiPhy::CCA_BUSY: {
- Time ccaStart = Max (m_endSync, m_endTx);
+ Time ccaStart = Max (m_endRx, m_endTx);
ccaStart = Max (ccaStart, m_startCcaBusy);
ccaStart = Max (ccaStart, m_endSwitching);
m_stateLogger (ccaStart, now - ccaStart, WifiPhy::CCA_BUSY);
@@ -299,7 +270,7 @@
break;
case WifiPhy::SWITCHING:
default:
- NS_ASSERT (false);
+ NS_FATAL_ERROR ("Invalid WifiPhy state.");
break;
}
m_stateLogger (now, txDuration, WifiPhy::TX);
@@ -308,33 +279,33 @@
m_startTx = now;
}
void
-WifiPhyStateHelper::SwitchToSync (Time rxDuration)
+WifiPhyStateHelper::SwitchToRx (Time rxDuration)
{
NS_ASSERT (IsStateIdle () || IsStateCcaBusy ());
- NS_ASSERT (!m_syncing);
- NotifySyncStart (rxDuration);
+ NS_ASSERT (!m_rxing);
+ NotifyRxStart (rxDuration);
Time now = Simulator::Now ();
switch (GetState ()) {
case WifiPhy::IDLE:
LogPreviousIdleAndCcaBusyStates ();
break;
case WifiPhy::CCA_BUSY: {
- Time ccaStart = Max (m_endSync, m_endTx);
+ Time ccaStart = Max (m_endRx, m_endTx);
ccaStart = Max (ccaStart, m_startCcaBusy);
ccaStart = Max (ccaStart, m_endSwitching);
m_stateLogger (ccaStart, now - ccaStart, WifiPhy::CCA_BUSY);
} break;
case WifiPhy::SWITCHING:
- case WifiPhy::SYNC:
+ case WifiPhy::RX:
case WifiPhy::TX:
- NS_ASSERT (false);
+ NS_FATAL_ERROR ("Invalid WifiPhy state.");
break;
}
m_previousStateChangeTime = now;
- m_syncing = true;
- m_startSync = now;
- m_endSync = now + rxDuration;
- NS_ASSERT (IsStateSync ());
+ m_rxing = true;
+ m_startRx = now;
+ m_endRx = now + rxDuration;
+ NS_ASSERT (IsStateRx ());
}
void
@@ -343,16 +314,16 @@
NotifySwitchingStart (switchingDuration);
Time now = Simulator::Now ();
switch (GetState ()) {
- case WifiPhy::SYNC:
+ case WifiPhy::RX:
/* The packet which is being received as well
- * as its endSync event are cancelled by the caller.
+ * as its endRx event are cancelled by the caller.
*/
- m_syncing = false;
- m_stateLogger (m_startSync, now - m_startSync, WifiPhy::SYNC);
- m_endSync = now;
+ m_rxing = false;
+ m_stateLogger (m_startRx, now - m_startRx, WifiPhy::RX);
+ m_endRx = now;
break;
case WifiPhy::CCA_BUSY: {
- Time ccaStart = Max (m_endSync, m_endTx);
+ Time ccaStart = Max (m_endRx, m_endTx);
ccaStart = Max (ccaStart, m_startCcaBusy);
ccaStart = Max (ccaStart, m_endSwitching);
m_stateLogger (ccaStart, now - ccaStart, WifiPhy::CCA_BUSY);
@@ -363,7 +334,7 @@
case WifiPhy::TX:
case WifiPhy::SWITCHING:
default:
- NS_ASSERT (false);
+ NS_FATAL_ERROR ("Invalid WifiPhy state.");
break;
}
@@ -380,39 +351,39 @@
}
void
-WifiPhyStateHelper::SwitchFromSyncEndOk (Ptr<Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
+WifiPhyStateHelper::SwitchFromRxEndOk (Ptr<Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
{
m_rxOkTrace (packet, snr, mode, preamble);
- NotifySyncEndOk ();
- DoSwitchFromSync ();
- if (!m_syncOkCallback.IsNull ())
+ NotifyRxEndOk ();
+ DoSwitchFromRx ();
+ if (!m_rxOkCallback.IsNull ())
{
- m_syncOkCallback (packet, snr, mode, preamble);
+ m_rxOkCallback (packet, snr, mode, preamble);
}
}
void
-WifiPhyStateHelper::SwitchFromSyncEndError (Ptr<const Packet> packet, double snr)
+WifiPhyStateHelper::SwitchFromRxEndError (Ptr<const Packet> packet, double snr)
{
m_rxErrorTrace (packet, snr);
- NotifySyncEndError ();
- DoSwitchFromSync ();
- if (!m_syncErrorCallback.IsNull ())
+ NotifyRxEndError ();
+ DoSwitchFromRx ();
+ if (!m_rxErrorCallback.IsNull ())
{
- m_syncErrorCallback (packet, snr);
+ m_rxErrorCallback (packet, snr);
}
}
void
-WifiPhyStateHelper::DoSwitchFromSync (void)
+WifiPhyStateHelper::DoSwitchFromRx (void)
{
- NS_ASSERT (IsStateSync ());
- NS_ASSERT (m_syncing);
+ NS_ASSERT (IsStateRx ());
+ NS_ASSERT (m_rxing);
Time now = Simulator::Now ();
- m_stateLogger (m_startSync, now - m_startSync, WifiPhy::SYNC);
+ m_stateLogger (m_startRx, now - m_startRx, WifiPhy::RX);
m_previousStateChangeTime = now;
- m_syncing = false;
+ m_rxing = false;
NS_ASSERT (IsStateIdle () || IsStateCcaBusy ());
}
@@ -429,7 +400,7 @@
break;
case WifiPhy::CCA_BUSY:
break;
- case WifiPhy::SYNC:
+ case WifiPhy::RX:
break;
case WifiPhy::TX:
break;
--- a/src/devices/wifi/wifi-phy-state-helper.h Mon Nov 30 18:20:30 2009 +0100
+++ b/src/devices/wifi/wifi-phy-state-helper.h Mon Nov 30 18:40:35 2009 +0100
@@ -34,14 +34,14 @@
WifiPhyStateHelper ();
- void SetReceiveOkCallback (WifiPhy::SyncOkCallback callback);
- void SetReceiveErrorCallback (WifiPhy::SyncErrorCallback callback);
+ void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
+ void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
void RegisterListener (WifiPhyListener *listener);
enum WifiPhy::State GetState (void);
bool IsStateCcaBusy (void);
bool IsStateIdle (void);
bool IsStateBusy (void);
- bool IsStateSync (void);
+ bool IsStateRx (void);
bool IsStateTx (void);
bool IsStateSwitching (void);
Time GetStateDuration (void);
@@ -49,35 +49,34 @@
Time GetLastRxStartTime (void) const;
void SwitchToTx (Time txDuration, Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower);
- void SwitchToSync (Time syncDuration);
+ void SwitchToRx (Time rxDuration);
void SwitchToChannelSwitching (Time switchingDuration);
- void SwitchFromSyncEndOk (Ptr<Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble);
- void SwitchFromSyncEndError (Ptr<const Packet> packet, double snr);
+ void SwitchFromRxEndOk (Ptr<Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble);
+ void SwitchFromRxEndError (Ptr<const Packet> packet, double snr);
void SwitchMaybeToCcaBusy (Time duration);
TracedCallback<Time,Time,enum WifiPhy::State> m_stateLogger;
private:
typedef std::vector<WifiPhyListener *> Listeners;
- const char *StateToString (enum WifiPhy::State state);
void LogPreviousIdleAndCcaBusyStates (void);
void NotifyTxStart (Time duration);
void NotifyWakeup (void);
- void NotifySyncStart (Time duration);
- void NotifySyncEndOk (void);
- void NotifySyncEndError (void);
+ void NotifyRxStart (Time duration);
+ void NotifyRxEndOk (void);
+ void NotifyRxEndError (void);
void NotifyMaybeCcaBusyStart (Time duration);
void NotifySwitchingStart (Time duration);
- void DoSwitchFromSync (void);
+ void DoSwitchFromRx (void);
- bool m_syncing;
+ bool m_rxing;
Time m_endTx;
- Time m_endSync;
+ Time m_endRx;
Time m_endCcaBusy;
Time m_endSwitching;
Time m_startTx;
- Time m_startSync;
+ Time m_startRx;
Time m_startCcaBusy;
Time m_startSwitching;
Time m_previousStateChangeTime;
@@ -86,8 +85,8 @@
TracedCallback<Ptr<const Packet>, double, WifiMode, enum WifiPreamble> m_rxOkTrace;
TracedCallback<Ptr<const Packet>, double> m_rxErrorTrace;
TracedCallback<Ptr<const Packet>,WifiMode,WifiPreamble,uint8_t> m_txTrace;
- WifiPhy::SyncOkCallback m_syncOkCallback;
- WifiPhy::SyncErrorCallback m_syncErrorCallback;
+ WifiPhy::RxOkCallback m_rxOkCallback;
+ WifiPhy::RxErrorCallback m_rxErrorCallback;
};
} // namespace ns3
--- a/src/devices/wifi/wifi-phy.cc Mon Nov 30 18:20:30 2009 +0100
+++ b/src/devices/wifi/wifi-phy.cc Mon Nov 30 18:40:35 2009 +0100
@@ -416,6 +416,24 @@
return mode;
}
+std::ostream& operator<< (std::ostream& os, enum WifiPhy::State state)
+{
+ switch (state) {
+ case WifiPhy::IDLE:
+ return (os << "IDLE");
+ case WifiPhy::CCA_BUSY:
+ return (os << "CCA_BUSY");
+ case WifiPhy::TX:
+ return (os << "TX");
+ case WifiPhy::RX:
+ return (os << "RX");
+ case WifiPhy::SWITCHING:
+ return (os << "SWITCHING");
+ default:
+ NS_FATAL_ERROR ("Invalid WifiPhy state");
+ return (os << "INVALID");
+ }
+}
} // namespace ns3
--- a/src/devices/wifi/wifi-phy.h Mon Nov 30 18:20:30 2009 +0100
+++ b/src/devices/wifi/wifi-phy.h Mon Nov 30 18:40:35 2009 +0100
@@ -120,39 +120,39 @@
*/
enum State {
/**
- * The PHY layer is synchronized upon a packet.
+ * The PHY layer is IDLE.
*/
- SYNC,
+ IDLE,
+ /**
+ * The PHY layer has sense the medium busy through the CCA mechanism
+ */
+ CCA_BUSY,
/**
* The PHY layer is sending a packet.
*/
TX,
/**
- * The PHY layer has sense the medium busy through
- * the CCA mechanism
+ * The PHY layer is receiving a packet.
*/
- CCA_BUSY,
- /**
- * The PHY layer is IDLE.
- */
- IDLE,
+ RX,
/**
* The PHY layer is switching to other channel.
*/
SWITCHING
};
+
/**
* arg1: packet received successfully
* arg2: snr of packet
* arg3: mode of packet
* arg4: type of preamble used for packet.
*/
- typedef Callback<void,Ptr<Packet>, double, WifiMode, enum WifiPreamble> SyncOkCallback;
+ typedef Callback<void,Ptr<Packet>, double, WifiMode, enum WifiPreamble> RxOkCallback;
/**
* arg1: packet received unsuccessfully
* arg2: snr of packet
*/
- typedef Callback<void,Ptr<const Packet>, double> SyncErrorCallback;
+ typedef Callback<void,Ptr<const Packet>, double> RxErrorCallback;
static TypeId GetTypeId (void);
@@ -170,12 +170,12 @@
* \param callback the callback to invoke
* upon successful packet reception.
*/
- virtual void SetReceiveOkCallback (SyncOkCallback callback) = 0;
+ virtual void SetReceiveOkCallback (RxOkCallback callback) = 0;
/**
* \param callback the callback to invoke
* upon erronous packet reception.
*/
- virtual void SetReceiveErrorCallback (SyncErrorCallback callback) = 0;
+ virtual void SetReceiveErrorCallback (RxErrorCallback callback) = 0;
/**
* \param packet the packet to send
@@ -195,26 +195,30 @@
virtual void RegisterListener (WifiPhyListener *listener) = 0;
/**
+ * \returns true of the current state of the PHY layer is WifiPhy::IDLE, false otherwise.
+ */
+ virtual bool IsStateIdle (void) = 0;
+ /**
* \returns true of the current state of the PHY layer is WifiPhy::CCA_BUSY, false otherwise.
*/
virtual bool IsStateCcaBusy (void) = 0;
/**
- * \returns true of the current state of the PHY layer is WifiPhy::IDLE, false otherwise.
- */
- virtual bool IsStateIdle (void) = 0;
- /**
* \returns true of the current state of the PHY layer is not WifiPhy::IDLE, false otherwise.
*/
virtual bool IsStateBusy (void) = 0;
/**
- * \returns true of the current state of the PHY layer is WifiPhy::SYNC, false otherwise.
+ * \returns true of the current state of the PHY layer is WifiPhy::RX, false otherwise.
*/
- virtual bool IsStateSync (void) = 0;
+ virtual bool IsStateRx (void) = 0;
/**
* \returns true of the current state of the PHY layer is WifiPhy::TX, false otherwise.
*/
virtual bool IsStateTx (void) = 0;
/**
+ * \returns true of the current state of the PHY layer is WifiPhy::SWITCHING, false otherwise.
+ */
+ virtual bool IsStateSwitching (void) = 0;
+ /**
* \returns the amount of time since the current state has started.
*/
virtual Time GetStateDuration (void) = 0;
@@ -253,7 +257,7 @@
* the requested ber for the specified transmission mode. (W/W)
*/
virtual double CalculateSnr (WifiMode txMode, double ber) const = 0;
-
+
/**
* \brief Set channel number.
*
@@ -449,7 +453,12 @@
};
+/**
+ * \param os output stream
+ * \param state wifi state to stringify
+ */
+std::ostream& operator<< (std::ostream& os, enum WifiPhy::State state);
+
} // namespace ns3
-
#endif /* WIFI_PHY_H */
--- a/src/devices/wifi/yans-wifi-phy.cc Mon Nov 30 18:20:30 2009 +0100
+++ b/src/devices/wifi/yans-wifi-phy.cc Mon Nov 30 18:40:35 2009 +0100
@@ -127,7 +127,7 @@
YansWifiPhy::YansWifiPhy ()
: m_channelNumber (1),
- m_endSyncEvent (),
+ m_endRxEvent (),
m_random (0.0, 1.0),
m_channelStartingFrequency (0)
{
@@ -333,9 +333,9 @@
NS_ASSERT (!IsStateSwitching());
switch (m_state->GetState ()) {
- case YansWifiPhy::SYNC:
+ case YansWifiPhy::RX:
NS_LOG_DEBUG ("drop packet because of channel switching while reception");
- m_endSyncEvent.Cancel();
+ m_endRxEvent.Cancel();
goto switchChannel;
break;
case YansWifiPhy::TX:
@@ -381,12 +381,12 @@
}
void
-YansWifiPhy::SetReceiveOkCallback (SyncOkCallback callback)
+YansWifiPhy::SetReceiveOkCallback (RxOkCallback callback)
{
m_state->SetReceiveOkCallback (callback);
}
void
-YansWifiPhy::SetReceiveErrorCallback (SyncErrorCallback callback)
+YansWifiPhy::SetReceiveErrorCallback (RxErrorCallback callback)
{
m_state->SetReceiveErrorCallback (callback);
}
@@ -428,8 +428,8 @@
goto maybeCcaBusy;
}
break;
- case YansWifiPhy::SYNC:
- NS_LOG_DEBUG ("drop packet because already in Sync (power="<<
+ case YansWifiPhy::RX:
+ NS_LOG_DEBUG ("drop packet because already in Rx (power="<<
rxPowerW<<"W)");
NotifyRxDrop (packet);
if (endRx > Simulator::Now () + m_state->GetDelayUntilIdle ())
@@ -454,14 +454,14 @@
case YansWifiPhy::IDLE:
if (rxPowerW > m_edThresholdW)
{
- NS_LOG_DEBUG ("sync (power="<<rxPowerW<<"W)");
+ NS_LOG_DEBUG ("sync to signal (power="<<rxPowerW<<"W)");
// sync to signal
- m_state->SwitchToSync (rxDuration);
- NS_ASSERT (m_endSyncEvent.IsExpired ());
+ m_state->SwitchToRx (rxDuration);
+ NS_ASSERT (m_endRxEvent.IsExpired ());
NotifyRxBegin (packet);
- m_endSyncEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndSync, this,
- packet,
- event);
+ m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this,
+ packet,
+ event);
}
else
{
@@ -501,9 +501,9 @@
NS_ASSERT (!m_state->IsStateTx () && !m_state->IsStateSwitching ());
Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble);
- if (m_state->IsStateSync ())
+ if (m_state->IsStateRx ())
{
- m_endSyncEvent.Cancel ();
+ m_endRxEvent.Cancel ();
}
NotifyTxBegin (packet);
uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;
@@ -651,9 +651,9 @@
return m_state->IsStateBusy ();
}
bool
-YansWifiPhy::IsStateSync (void)
+YansWifiPhy::IsStateRx (void)
{
- return m_state->IsStateSync ();
+ return m_state->IsStateRx ();
}
bool
YansWifiPhy::IsStateTx (void)
@@ -731,10 +731,10 @@
}
void
-YansWifiPhy::EndSync (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
+YansWifiPhy::EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
{
NS_LOG_FUNCTION (this << packet << event);
- NS_ASSERT (IsStateSync ());
+ NS_ASSERT (IsStateRx ());
NS_ASSERT (event->GetEndTime () == Simulator::Now ());
struct InterferenceHelper::SnrPer snrPer;
@@ -750,13 +750,13 @@
double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
- m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
+ m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
}
else
{
/* failure. */
NotifyRxDrop (packet);
- m_state->SwitchFromSyncEndError (packet, snrPer.snr);
+ m_state->SwitchFromRxEndError (packet, snrPer.snr);
}
}
} // namespace ns3
--- a/src/devices/wifi/yans-wifi-phy.h Mon Nov 30 18:20:30 2009 +0100
+++ b/src/devices/wifi/yans-wifi-phy.h Mon Nov 30 18:40:35 2009 +0100
@@ -82,8 +82,8 @@
* has a private attribute m_channelNumber that identifies the channel the
* PHY operates on. Channel switching cannot interrupt an ongoing transmission.
* When PHY is in TX state, the channel switching is postponed until the end
- * of the current transmission. When the PHY is in SYNC state, the channel
- * switching causes the drop of the sync packet.
+ * of the current transmission. When the PHY is in RX state, the channel
+ * switching causes the drop of the synchronized packet.
*/
void SetChannelNumber (uint16_t id);
/// Return current channel number, see SetChannelNumber()
@@ -122,14 +122,14 @@
virtual double GetTxPowerStart (void) const;
virtual double GetTxPowerEnd (void) const;
virtual uint32_t GetNTxPower (void) const;
- virtual void SetReceiveOkCallback (WifiPhy::SyncOkCallback callback);
- virtual void SetReceiveErrorCallback (WifiPhy::SyncErrorCallback callback);
+ virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
+ virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
virtual void RegisterListener (WifiPhyListener *listener);
virtual bool IsStateCcaBusy (void);
virtual bool IsStateIdle (void);
virtual bool IsStateBusy (void);
- virtual bool IsStateSync (void);
+ virtual bool IsStateRx (void);
virtual bool IsStateTx (void);
virtual bool IsStateSwitching (void);
virtual Time GetStateDuration (void);
@@ -161,7 +161,7 @@
double WToDbm (double w) const;
double RatioToDb (double ratio) const;
double GetPowerDbm (uint8_t power) const;
- void EndSync (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
+ void EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
private:
double m_edThresholdW;
@@ -177,7 +177,7 @@
Ptr<Object> m_device;
Ptr<Object> m_mobility;
Modes m_modes;
- EventId m_endSyncEvent;
+ EventId m_endRxEvent;
UniformVariable m_random;
/// Standard-dependent center frequency of 0-th channel, MHz
double m_channelStartingFrequency;