diff --git a/src/lr-wpan/model/lr-wpan-net-device.cc b/src/lr-wpan/model/lr-wpan-net-device.cc index 26e176a08..7bbe53f5f 100644 --- a/src/lr-wpan/model/lr-wpan-net-device.cc +++ b/src/lr-wpan/model/lr-wpan-net-device.cc @@ -21,6 +21,7 @@ #include "ns3/abort.h" #include "ns3/node.h" #include "lr-wpan-net-device.h" +#include "ns3/log.h" #include "ns3/lr-wpan-mac.h" #include "ns3/lr-wpan-phy.h" #include "ns3/lr-wpan-csmaca.h" @@ -115,7 +116,7 @@ LrWpanNetDevice::CompleteConfig (void) m_mac->SetCsmaCa (m_csmaca); m_csmaca->SetMac (m_mac); - m_phy->SetMobility (m_node); + m_phy->SetMobility (m_node->GetObject ()); Ptr model = CreateObject (); m_phy->SetErrorModel (model); diff --git a/src/lr-wpan/model/lr-wpan-phy.cc b/src/lr-wpan/model/lr-wpan-phy.cc index 10df65b36..653155d64 100644 --- a/src/lr-wpan/model/lr-wpan-phy.cc +++ b/src/lr-wpan/model/lr-wpan-phy.cc @@ -149,7 +149,7 @@ LrWpanPhy::DoDispose () SpectrumPhy::DoDispose (); } -Ptr +Ptr LrWpanPhy::GetDevice () { NS_LOG_FUNCTION (this); @@ -157,7 +157,7 @@ LrWpanPhy::GetDevice () } -Ptr +Ptr LrWpanPhy::GetMobility () { NS_LOG_FUNCTION (this); @@ -166,7 +166,7 @@ LrWpanPhy::GetMobility () void -LrWpanPhy::SetDevice (Ptr d) +LrWpanPhy::SetDevice (Ptr d) { NS_LOG_FUNCTION (this << d); m_device = d; @@ -174,7 +174,7 @@ LrWpanPhy::SetDevice (Ptr d) void -LrWpanPhy::SetMobility (Ptr m) +LrWpanPhy::SetMobility (Ptr m) { NS_LOG_FUNCTION (this << m); m_mobility = m; @@ -210,22 +210,28 @@ LrWpanPhy::GetRxSpectrumModel () const } void -LrWpanPhy::StartRx (Ptr pb, Ptr rxPsd, SpectrumType st, Time duration) +LrWpanPhy::StartRx (Ptr spectrumRxParams) { - NS_LOG_FUNCTION (this << pb << *rxPsd << st << duration); + NS_LOG_FUNCTION (this << spectrumRxParams); LrWpanSpectrumValueHelper psdHelper; - // The specification doesn't seem to refer to BUSY_RX, but vendor - // data sheets suggest that this is a substate of the RX_ON state - // that is entered after preamble detection when the digital receiver - // is enabled. Here, for now, we use BUSY_RX to mark the period between - // StartRx() and EndRx() states. - ChangeTrxState (IEEE_802_15_4_PHY_BUSY_RX); - if (st == GetSpectrumType ()) + + Ptr lrWpanRxParams = DynamicCast (spectrumRxParams); + + if (lrWpanRxParams != 0) { - Ptr p = (pb->GetPackets ()).front (); + // The specification doesn't seem to refer to BUSY_RX, but vendor + // data sheets suggest that this is a substate of the RX_ON state + // that is entered after preamble detection when the digital receiver + // is enabled. Here, for now, we use BUSY_RX to mark the period between + // StartRx() and EndRx() states. + ChangeTrxState (IEEE_802_15_4_PHY_BUSY_RX); + + Time duration = lrWpanRxParams->duration; + + Ptr p = (lrWpanRxParams->packetBurst->GetPackets ()).front (); m_currentRxPacket = std::make_pair (p, false); - m_rxPsd = rxPsd; + m_rxPsd = lrWpanRxParams->psd; m_rxTotalPower = psdHelper.TotalAvgPower (*m_rxPsd); Simulator::Schedule (duration, &LrWpanPhy::EndRx, this); m_phyRxBeginTrace (p); @@ -319,11 +325,16 @@ LrWpanPhy::PdDataRequest (const uint32_t psduLength, Ptr p) { //send down NS_ASSERT (m_channel); - Time txTime = CalculateTxTime (p); + + Ptr txParams = Create (); + txParams->duration = CalculateTxTime (p); + txParams->txPhy = GetObject (); + txParams->psd = m_txPsd; Ptr pb = CreateObject (); pb->AddPacket (p); - m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), txTime, GetObject ()); - m_pdDataRequest = Simulator::Schedule (txTime, &LrWpanPhy::EndTx, this); + txParams->packetBurst = pb; + m_channel->StartTx (txParams); + m_pdDataRequest = Simulator::Schedule (txParams->duration, &LrWpanPhy::EndTx, this); ChangeTrxState (IEEE_802_15_4_PHY_BUSY_TX); m_phyTxBeginTrace (p); m_currentTxPacket.first = p; @@ -881,14 +892,6 @@ LrWpanPhy::CalculateTxTime (Ptr packet) return txTime; } -SpectrumType -LrWpanPhy::GetSpectrumType () -{ - NS_LOG_FUNCTION (this); - static SpectrumType st = SpectrumTypeFactory::Create ("Ieee802.15.4"); - return st; -} - double LrWpanPhy::GetDataOrSymbolRate (bool isData) { diff --git a/src/lr-wpan/model/lr-wpan-phy.h b/src/lr-wpan/model/lr-wpan-phy.h index b22d01fef..08856c79a 100644 --- a/src/lr-wpan/model/lr-wpan-phy.h +++ b/src/lr-wpan/model/lr-wpan-phy.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -39,6 +38,7 @@ #include #include "lr-wpan-spectrum-value-helper.h" #include "lr-wpan-error-model.h" +#include "lr-wpan-spectrum-signal-parameters.h" namespace ns3 { @@ -205,19 +205,13 @@ public: virtual ~LrWpanPhy (); // inherited from SpectrumPhy - void SetMobility (Ptr m); - Ptr GetMobility (); + void SetMobility (Ptr m); + Ptr GetMobility (); void SetChannel (Ptr c); Ptr GetChannel (void); - void SetDevice (Ptr d); - Ptr GetDevice (); + void SetDevice (Ptr d); + Ptr GetDevice (); virtual Ptr GetRxSpectrumModel () const; - /** - * Get the SpectrumType used by this PHY - * - * @return - */ - SpectrumType GetSpectrumType (); /** * set the Power Spectral Density of outgoing signals in W/Hz. @@ -242,13 +236,9 @@ public: /** * Notify the SpectrumPhy instance of an incoming waveform * - * @param p the PacketBurst associated with the incoming waveform - * @param rxPsd the Power Spectral Density of the incoming - * waveform. The units of the PSD are the same specified for SpectrumChannel::StartTx(). - * @param st spectrum type - * @param duration the duration of the incoming waveform + * @param params the SpectrumSignalParameters associated with the incoming waveform */ - virtual void StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration); + virtual void StartRx (Ptr params); /** * IEEE 802.15.4-2006 section 6.2.1.1 @@ -393,8 +383,8 @@ private: Time CalculateTxTime (Ptr packet); double GetPpduHeaderTxTime (void); bool ChannelSupported (uint8_t); - Ptr m_mobility; - Ptr m_device; + Ptr m_mobility; + Ptr m_device; Ptr m_channel; Ptr m_txPsd; Ptr m_rxPsd; diff --git a/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.cc b/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.cc new file mode 100644 index 000000000..ed4e59c2a --- /dev/null +++ b/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.cc @@ -0,0 +1,49 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2012 The Boeing Company + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Gary Pei + */ + +#include +#include +#include "lr-wpan-spectrum-signal-parameters.h" + + +NS_LOG_COMPONENT_DEFINE ("LrWpanSpectrumSignalParameters"); + +namespace ns3 { + +LrWpanSpectrumSignalParameters::LrWpanSpectrumSignalParameters () +{ + NS_LOG_FUNCTION (this); +} + +LrWpanSpectrumSignalParameters::LrWpanSpectrumSignalParameters (const LrWpanSpectrumSignalParameters& p) + : SpectrumSignalParameters (p) +{ + NS_LOG_FUNCTION (this << &p); + packetBurst = p.packetBurst->Copy (); +} + +Ptr +LrWpanSpectrumSignalParameters::Copy () +{ + NS_LOG_FUNCTION (this); + return Create (*this); +} + +} // namespace ns3 diff --git a/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.h b/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.h new file mode 100644 index 000000000..5a5b03238 --- /dev/null +++ b/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.h @@ -0,0 +1,61 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2012 The Boeing Company + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Gary Pei + */ + +#ifndef LR_WPAN_SPECTRUM_SIGNAL_PARAMETERS_H +#define LR_WPAN_SPECTRUM_SIGNAL_PARAMETERS_H + + +#include + +namespace ns3 { + +class PacketBurst; + +/** + * \ingroup lte + * + * Signal parameters for LrWpan + */ +struct LrWpanSpectrumSignalParameters : public SpectrumSignalParameters +{ + + // inherited from SpectrumSignalParameters + virtual Ptr Copy (); + + /** + * default constructor + */ + LrWpanSpectrumSignalParameters (); + + /** + * copy constructor + */ + LrWpanSpectrumSignalParameters (const LrWpanSpectrumSignalParameters& p); + + /** + * The packet burst being transmitted with this signal + */ + Ptr packetBurst; +}; + +} // namespace ns3 + + +#endif /* LR_WPAN_SPECTRUM_SIGNAL_PARAMETERS_H */ diff --git a/src/lr-wpan/test/lr-wpan-packet-test.cc b/src/lr-wpan/test/lr-wpan-packet-test.cc index 7cc56779c..3329d99b8 100644 --- a/src/lr-wpan/test/lr-wpan-packet-test.cc +++ b/src/lr-wpan/test/lr-wpan-packet-test.cc @@ -43,7 +43,7 @@ private: }; LrWpanPacketTestCase::LrWpanPacketTestCase () - : TestCase ("Test the 802.15.4 MAC header/trailer classes") + : TestCase ("Test the 802.15.4 MAC header and trailer classes") { } diff --git a/src/lr-wpan/wscript b/src/lr-wpan/wscript index adc1a2244..997fa3966 100644 --- a/src/lr-wpan/wscript +++ b/src/lr-wpan/wscript @@ -11,13 +11,19 @@ def build(bld): 'model/lr-wpan-csmaca.cc', 'model/lr-wpan-net-device.cc', 'model/lr-wpan-spectrum-value-helper.cc', + 'model/lr-wpan-spectrum-signal-parameters.cc', + 'helper/lr-wpan-helper.cc', + ] + + module_test = bld.create_ns3_module_test_library('lr-wpan') + module_test.source = [ 'test/lr-wpan-pd-plme-sap-test.cc', 'test/lr-wpan-packet-test.cc', 'test/lr-wpan-error-model-test.cc', 'test/lr-wpan-spectrum-value-helper-test.cc', - 'helper/lr-wpan-helper.cc', ] - headers = bld.new_task_gen('ns3header') + + headers = bld.new_task_gen(features=['ns3header']) headers.module = 'lr-wpan' headers.source = [ 'model/lr-wpan-error-model.h', @@ -28,8 +34,10 @@ def build(bld): 'model/lr-wpan-csmaca.h', 'model/lr-wpan-net-device.h', 'model/lr-wpan-spectrum-value-helper.h', + 'model/lr-wpan-spectrum-signal-parameters.h', 'helper/lr-wpan-helper.h', ] + if (bld.env['ENABLE_EXAMPLES']): bld.add_subdirs('examples') diff --git a/src/wscript b/src/wscript index 9cf072e6b..f11745183 100644 --- a/src/wscript +++ b/src/wscript @@ -16,6 +16,7 @@ except NameError: from sets import Set as set # Python 2.3 fallback + all_modules = [] for dirname in os.listdir('src'): if dirname.startswith('.') or dirname == 'CVS':