From f286cbaff4dbb63bad244a75e7e9c60263ba2742 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Tue, 9 Oct 2007 10:21:46 +0200 Subject: [PATCH] remove extra WifiPhy::SendPacket argument. Add header mode support --- src/devices/wifi/mac-parameters.cc | 4 ++-- src/devices/wifi/wifi-channel.cc | 11 +++++------ src/devices/wifi/wifi-channel.h | 7 +++---- src/devices/wifi/wifi-phy.cc | 22 ++++++++++------------ src/devices/wifi/wifi-phy.h | 11 +++++------ 5 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/devices/wifi/mac-parameters.cc b/src/devices/wifi/mac-parameters.cc index 570289ba3..911929822 100644 --- a/src/devices/wifi/mac-parameters.cc +++ b/src/devices/wifi/mac-parameters.cc @@ -50,13 +50,13 @@ MacParameters::Initialize80211a (WifiPhy const*phy) WifiMacHeader hdr; hdr.SetType (WIFI_MAC_CTL_CTS); m_ctsTimeout = m_sifs; - m_ctsTimeout += phy->CalculateTxDuration (hdr.GetSize (), phy->GetMode (0)); + m_ctsTimeout += phy->CalculateTxDuration (hdr.GetSize (), phy->GetMode (0), phy->GetMode (0)); m_ctsTimeout += m_maxPropagationDelay * Scalar (2); m_ctsTimeout += m_slot; hdr.SetType (WIFI_MAC_CTL_ACK); m_ackTimeout = m_sifs; - m_ackTimeout += phy->CalculateTxDuration (hdr.GetSize (), phy->GetMode (0)); + m_ackTimeout += phy->CalculateTxDuration (hdr.GetSize (), phy->GetMode (0), phy->GetMode (0)); m_ackTimeout += m_maxPropagationDelay * Scalar (2); m_ackTimeout += m_slot; } diff --git a/src/devices/wifi/wifi-channel.cc b/src/devices/wifi/wifi-channel.cc index d3e296aec..078dfd4b1 100644 --- a/src/devices/wifi/wifi-channel.cc +++ b/src/devices/wifi/wifi-channel.cc @@ -30,12 +30,11 @@ namespace ns3 { WifiChannel::ReceiveData::ReceiveData (const Packet &packet, double rxPowerDbm, - WifiMode txMode, WifiMode headerMode, uint32_t extra) + WifiMode txMode, WifiMode headerMode) : m_packet (packet), m_rxPowerDbm (rxPowerDbm), m_wifiMode (txMode), - m_headerMode (headerMode), - m_extra (extra) + m_headerMode (headerMode) {} @@ -62,7 +61,7 @@ WifiChannel::Add (Ptr device, ReceiveCallback callback) } void WifiChannel::Send (Ptr sender, const Packet &packet, double txPowerDbm, - WifiMode wifiMode, WifiMode headerMode, uint32_t extra) const + WifiMode wifiMode, WifiMode headerMode) const { Ptr senderMobility = sender->GetNode ()->QueryInterface (MobilityModel::iid); uint32_t j = 0; @@ -74,7 +73,7 @@ WifiChannel::Send (Ptr sender, const Packet &packet, double txPowerDb double distance = senderMobility->GetDistanceFrom (receiverMobility); Time delay = m_delay->GetDelay (distance); double rxPowerDbm = m_loss->GetRxPower (txPowerDbm, distance); - struct ReceiveData data = ReceiveData (packet, rxPowerDbm, wifiMode, headerMode, extra); + struct ReceiveData data = ReceiveData (packet, rxPowerDbm, wifiMode, headerMode); Simulator::Schedule (delay, &WifiChannel::Receive, this, j, data); } @@ -86,7 +85,7 @@ void WifiChannel::Receive (uint32_t i, const struct ReceiveData &data) const { - m_deviceList[i].second (data.m_packet, data.m_rxPowerDbm, data.m_wifiMode, data.m_headerMode, data.m_extra); + m_deviceList[i].second (data.m_packet, data.m_rxPowerDbm, data.m_wifiMode, data.m_headerMode); } uint32_t diff --git a/src/devices/wifi/wifi-channel.h b/src/devices/wifi/wifi-channel.h index ab16086d2..2a3aef1d9 100644 --- a/src/devices/wifi/wifi-channel.h +++ b/src/devices/wifi/wifi-channel.h @@ -35,7 +35,7 @@ class PropagationDelayModel; class WifiChannel : public Channel { public: - typedef Callback ReceiveCallback; + typedef Callback ReceiveCallback; WifiChannel (); virtual ~WifiChannel (); @@ -47,18 +47,17 @@ public: void Add (Ptr device, ReceiveCallback callback); void Send (Ptr sender, const Packet &packet, double txPowerDbm, - WifiMode wifiMode, WifiMode headerMode, uint32_t extra) const; + WifiMode wifiMode, WifiMode headerMode) const; private: typedef std::vector, ReceiveCallback> > DeviceList; struct ReceiveData { ReceiveData (const Packet &packet, double rxPowerDbm, - WifiMode txMode, WifiMode headerMode, uint32_t extra); + WifiMode txMode, WifiMode headerMode); Packet m_packet; double m_rxPowerDbm; WifiMode m_wifiMode; WifiMode m_headerMode; - uint32_t m_extra; }; void Receive (uint32_t i, const struct ReceiveData &data) const; diff --git a/src/devices/wifi/wifi-phy.cc b/src/devices/wifi/wifi-phy.cc index 015404a3c..401163dc0 100644 --- a/src/devices/wifi/wifi-phy.cc +++ b/src/devices/wifi/wifi-phy.cc @@ -246,10 +246,9 @@ void WifiPhy::ReceivePacket (Packet const packet, double rxPowerW, WifiMode txMode, - WifiMode headerMode, - uint32_t extra) + WifiMode headerMode) { - Time rxDuration = CalculateTxDuration (packet.GetSize (), txMode); + Time rxDuration = CalculateTxDuration (packet.GetSize (), txMode, headerMode); Time endRx = Simulator::Now () + rxDuration; m_startRxLogger (rxDuration, rxPowerW); @@ -288,8 +287,7 @@ WifiPhy::ReceivePacket (Packet const packet, assert (m_endSyncEvent.IsExpired ()); m_endSyncEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndSync, this, packet, - event, - extra); + event); } else { @@ -337,7 +335,7 @@ WifiPhy::ReceivePacket (Packet const packet, event->Unref (); } void -WifiPhy::SendPacket (Packet const packet, WifiMode txMode, WifiMode headerMode, uint8_t txPower, uint32_t stuff) +WifiPhy::SendPacket (Packet const packet, WifiMode txMode, WifiMode headerMode, uint8_t txPower) { /* Transmission can happen if: * - we are syncing on a packet. It is the responsability of the @@ -351,11 +349,11 @@ WifiPhy::SendPacket (Packet const packet, WifiMode txMode, WifiMode headerMode, m_endSyncEvent.Cancel (); } - Time txDuration = CalculateTxDuration (packet.GetSize (), txMode); + Time txDuration = CalculateTxDuration (packet.GetSize (), txMode, headerMode); m_startTxLogger (txDuration, txMode.GetPhyRate (), GetPowerDbm (txPower)); NotifyTxStart (txDuration); SwitchToTx (txDuration); - m_channel->Send (m_device, packet, GetPowerDbm (txPower) + m_txGainDbm, txMode, headerMode, stuff); + m_channel->Send (m_device, packet, GetPowerDbm (txPower) + m_txGainDbm, txMode, headerMode); } void @@ -519,10 +517,10 @@ WifiPhy::GetDelayUntilIdle (void) Time -WifiPhy::CalculateTxDuration (uint32_t size, WifiMode payloadMode) const +WifiPhy::CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiMode headerMode) const { uint64_t delay = m_plcpPreambleDelayUs; - delay += m_plcpHeaderLength * 1000000 / GetMode (0).GetDataRate (); + delay += m_plcpHeaderLength * 1000000 / headerMode.GetDataRate (); uint64_t nbits = size * 8; delay += nbits * 1000000 / payloadMode.GetDataRate (); return MicroSeconds (delay); @@ -1164,7 +1162,7 @@ WifiPhy::CalculatePer (Ptr event, NiChanges *ni) const void -WifiPhy::EndSync (Packet const packet, Ptr event, uint32_t extra) +WifiPhy::EndSync (Packet const packet, Ptr event) { assert (IsStateSync ()); assert (event->GetEndTime () == Simulator::Now ()); @@ -1188,7 +1186,7 @@ WifiPhy::EndSync (Packet const packet, Ptr event, uint32_t extra) m_endSyncLogger (true); NotifySyncEndOk (); SwitchFromSync (); - m_syncOkCallback (packet, snr, event->GetPayloadMode (), event->GetHeaderMode (), extra); + m_syncOkCallback (packet, snr, event->GetPayloadMode (), event->GetHeaderMode ()); } else { diff --git a/src/devices/wifi/wifi-phy.h b/src/devices/wifi/wifi-phy.h index dbad77df6..360b9b472 100644 --- a/src/devices/wifi/wifi-phy.h +++ b/src/devices/wifi/wifi-phy.h @@ -71,7 +71,7 @@ public: class WifiPhy { public: - typedef Callback SyncOkCallback; + typedef Callback SyncOkCallback; typedef Callback SyncErrorCallback; WifiPhy (Ptr device); @@ -82,7 +82,7 @@ public: void SetReceiveOkCallback (SyncOkCallback callback); void SetReceiveErrorCallback (SyncErrorCallback callback); - void SendPacket (Packet const packet, WifiMode mode, WifiMode headeMode, uint8_t txPower, uint32_t stuff); + void SendPacket (Packet const packet, WifiMode mode, WifiMode headerMode, uint8_t txPower); void RegisterListener (WifiPhyListener *listener); @@ -94,7 +94,7 @@ public: Time GetStateDuration (void); Time GetDelayUntilIdle (void); - Time CalculateTxDuration (uint32_t size, WifiMode payloadMode) const; + Time CalculateTxDuration (uint32_t size, WifiMode payloadMode, WifiMode headerMode) const; void Configure80211a (void); void SetEdThresholdDbm (double rxThreshold); @@ -157,7 +157,7 @@ private: double CalculateSnr (double signal, double noiseInterference, WifiMode mode) const; double CalculateChunkSuccessRate (double snir, Time delay, WifiMode mode) const; double CalculatePer (Ptr event, NiChanges *ni) const; - void EndSync (Packet const packet, Ptr event, uint32_t stuff); + void EndSync (Packet const packet, Ptr event); double Log2 (double val) const; double GetBpskBer (double snr, uint32_t signalSpread, uint32_t phyRate) const; double GetQamBer (double snr, unsigned int m, uint32_t signalSpread, uint32_t phyRate) const; @@ -179,8 +179,7 @@ private: void ReceivePacket (Packet packet, double rxPowerW, WifiMode mode, - WifiMode headerMode, - uint32_t stuff); + WifiMode headerMode); private: uint64_t m_txPrepareDelayUs; uint64_t m_plcpPreambleDelayUs;