--- a/src/lr-wpan/model/lr-wpan-net-device.cc Wed Nov 16 22:01:06 2011 -0800
+++ b/src/lr-wpan/model/lr-wpan-net-device.cc Thu Mar 29 19:31:11 2012 -0700
@@ -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 @@
m_mac->SetCsmaCa (m_csmaca);
m_csmaca->SetMac (m_mac);
- m_phy->SetMobility (m_node);
+ m_phy->SetMobility (m_node->GetObject<MobilityModel> ());
Ptr<LrWpanErrorModel> model = CreateObject<LrWpanErrorModel> ();
m_phy->SetErrorModel (model);
--- a/src/lr-wpan/model/lr-wpan-phy.cc Wed Nov 16 22:01:06 2011 -0800
+++ b/src/lr-wpan/model/lr-wpan-phy.cc Thu Mar 29 19:31:11 2012 -0700
@@ -149,7 +149,7 @@
SpectrumPhy::DoDispose ();
}
-Ptr<Object>
+Ptr<NetDevice>
LrWpanPhy::GetDevice ()
{
NS_LOG_FUNCTION (this);
@@ -157,7 +157,7 @@
}
-Ptr<Object>
+Ptr<MobilityModel>
LrWpanPhy::GetMobility ()
{
NS_LOG_FUNCTION (this);
@@ -166,7 +166,7 @@
void
-LrWpanPhy::SetDevice (Ptr<Object> d)
+LrWpanPhy::SetDevice (Ptr<NetDevice> d)
{
NS_LOG_FUNCTION (this << d);
m_device = d;
@@ -174,7 +174,7 @@
void
-LrWpanPhy::SetMobility (Ptr<Object> m)
+LrWpanPhy::SetMobility (Ptr<MobilityModel> m)
{
NS_LOG_FUNCTION (this << m);
m_mobility = m;
@@ -210,22 +210,28 @@
}
void
-LrWpanPhy::StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration)
+LrWpanPhy::StartRx (Ptr<SpectrumSignalParameters> 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<LrWpanSpectrumSignalParameters> lrWpanRxParams = DynamicCast<LrWpanSpectrumSignalParameters> (spectrumRxParams);
+
+ if (lrWpanRxParams != 0)
{
- Ptr<Packet> 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<Packet> 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 @@
{
//send down
NS_ASSERT (m_channel);
- Time txTime = CalculateTxTime (p);
+
+ Ptr<LrWpanSpectrumSignalParameters> txParams = Create<LrWpanSpectrumSignalParameters> ();
+ txParams->duration = CalculateTxTime (p);
+ txParams->txPhy = GetObject<SpectrumPhy> ();
+ txParams->psd = m_txPsd;
Ptr<PacketBurst> pb = CreateObject<PacketBurst> ();
pb->AddPacket (p);
- m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), txTime, GetObject<SpectrumPhy> ());
- 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 @@
return txTime;
}
-SpectrumType
-LrWpanPhy::GetSpectrumType ()
-{
- NS_LOG_FUNCTION (this);
- static SpectrumType st = SpectrumTypeFactory::Create ("Ieee802.15.4");
- return st;
-}
-
double
LrWpanPhy::GetDataOrSymbolRate (bool isData)
{
--- a/src/lr-wpan/model/lr-wpan-phy.h Wed Nov 16 22:01:06 2011 -0800
+++ b/src/lr-wpan/model/lr-wpan-phy.h Thu Mar 29 19:31:11 2012 -0700
@@ -28,7 +28,6 @@
#include <ns3/packet-burst.h>
#include <ns3/spectrum-phy.h>
#include <ns3/spectrum-channel.h>
-#include <ns3/spectrum-type.h>
#include <ns3/spectrum-interference.h>
#include <ns3/spectrum-value.h>
#include <ns3/mobility-model.h>
@@ -39,6 +38,7 @@
#include <ns3/random-variable.h>
#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 @@
virtual ~LrWpanPhy ();
// inherited from SpectrumPhy
- void SetMobility (Ptr<Object> m);
- Ptr<Object> GetMobility ();
+ void SetMobility (Ptr<MobilityModel> m);
+ Ptr<MobilityModel> GetMobility ();
void SetChannel (Ptr<SpectrumChannel> c);
Ptr<SpectrumChannel> GetChannel (void);
- void SetDevice (Ptr<Object> d);
- Ptr<Object> GetDevice ();
+ void SetDevice (Ptr<NetDevice> d);
+ Ptr<NetDevice> GetDevice ();
virtual Ptr<const SpectrumModel> 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 @@
/**
* 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<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
+ virtual void StartRx (Ptr<SpectrumSignalParameters> params);
/**
* IEEE 802.15.4-2006 section 6.2.1.1
@@ -393,8 +383,8 @@
Time CalculateTxTime (Ptr<const Packet> packet);
double GetPpduHeaderTxTime (void);
bool ChannelSupported (uint8_t);
- Ptr<Object> m_mobility;
- Ptr<Object> m_device;
+ Ptr<MobilityModel> m_mobility;
+ Ptr<NetDevice> m_device;
Ptr<SpectrumChannel> m_channel;
Ptr<SpectrumValue> m_txPsd;
Ptr<const SpectrumValue> m_rxPsd;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.cc Thu Mar 29 19:31:11 2012 -0700
@@ -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 <guangyu.pei@boeing.com>
+ */
+
+#include <ns3/log.h>
+#include <ns3/packet-burst.h>
+#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<SpectrumSignalParameters>
+LrWpanSpectrumSignalParameters::Copy ()
+{
+ NS_LOG_FUNCTION (this);
+ return Create<LrWpanSpectrumSignalParameters> (*this);
+}
+
+} // namespace ns3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.h Thu Mar 29 19:31:11 2012 -0700
@@ -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 <guangyu.pei@boeing.com>
+ */
+
+#ifndef LR_WPAN_SPECTRUM_SIGNAL_PARAMETERS_H
+#define LR_WPAN_SPECTRUM_SIGNAL_PARAMETERS_H
+
+
+#include <ns3/spectrum-signal-parameters.h>
+
+namespace ns3 {
+
+class PacketBurst;
+
+/**
+ * \ingroup lte
+ *
+ * Signal parameters for LrWpan
+ */
+struct LrWpanSpectrumSignalParameters : public SpectrumSignalParameters
+{
+
+ // inherited from SpectrumSignalParameters
+ virtual Ptr<SpectrumSignalParameters> Copy ();
+
+ /**
+ * default constructor
+ */
+ LrWpanSpectrumSignalParameters ();
+
+ /**
+ * copy constructor
+ */
+ LrWpanSpectrumSignalParameters (const LrWpanSpectrumSignalParameters& p);
+
+ /**
+ * The packet burst being transmitted with this signal
+ */
+ Ptr<PacketBurst> packetBurst;
+};
+
+} // namespace ns3
+
+
+#endif /* LR_WPAN_SPECTRUM_SIGNAL_PARAMETERS_H */
--- a/src/lr-wpan/test/lr-wpan-packet-test.cc Wed Nov 16 22:01:06 2011 -0800
+++ b/src/lr-wpan/test/lr-wpan-packet-test.cc Thu Mar 29 19:31:11 2012 -0700
@@ -43,7 +43,7 @@
};
LrWpanPacketTestCase::LrWpanPacketTestCase ()
- : TestCase ("Test the 802.15.4 MAC header/trailer classes")
+ : TestCase ("Test the 802.15.4 MAC header and trailer classes")
{
}
--- a/src/lr-wpan/wscript Wed Nov 16 22:01:06 2011 -0800
+++ b/src/lr-wpan/wscript Thu Mar 29 19:31:11 2012 -0700
@@ -11,13 +11,19 @@
'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 @@
'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')
--- a/src/wscript Wed Nov 16 22:01:06 2011 -0800
+++ b/src/wscript Thu Mar 29 19:31:11 2012 -0700
@@ -16,6 +16,7 @@
from sets import Set as set # Python 2.3 fallback
+
all_modules = []
for dirname in os.listdir('src'):
if dirname.startswith('.') or dirname == 'CVS':