align lr-wpan with ns-3.13 spectrum API changes
This commit is contained in:
@@ -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<MobilityModel> ());
|
||||
Ptr<LrWpanErrorModel> model = CreateObject<LrWpanErrorModel> ();
|
||||
m_phy->SetErrorModel (model);
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ LrWpanPhy::DoDispose ()
|
||||
SpectrumPhy::DoDispose ();
|
||||
}
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<NetDevice>
|
||||
LrWpanPhy::GetDevice ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
@@ -157,7 +157,7 @@ LrWpanPhy::GetDevice ()
|
||||
}
|
||||
|
||||
|
||||
Ptr<Object>
|
||||
Ptr<MobilityModel>
|
||||
LrWpanPhy::GetMobility ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
@@ -166,7 +166,7 @@ LrWpanPhy::GetMobility ()
|
||||
|
||||
|
||||
void
|
||||
LrWpanPhy::SetDevice (Ptr<Object> d)
|
||||
LrWpanPhy::SetDevice (Ptr<NetDevice> d)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << d);
|
||||
m_device = d;
|
||||
@@ -174,7 +174,7 @@ LrWpanPhy::SetDevice (Ptr<Object> d)
|
||||
|
||||
|
||||
void
|
||||
LrWpanPhy::SetMobility (Ptr<Object> m)
|
||||
LrWpanPhy::SetMobility (Ptr<MobilityModel> m)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << m);
|
||||
m_mobility = m;
|
||||
@@ -210,22 +210,28 @@ LrWpanPhy::GetRxSpectrumModel () const
|
||||
}
|
||||
|
||||
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 @@ LrWpanPhy::PdDataRequest (const uint32_t psduLength, Ptr<Packet> p)
|
||||
{
|
||||
//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 @@ LrWpanPhy::CalculateTxTime (Ptr<const Packet> 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)
|
||||
{
|
||||
|
||||
@@ -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 @@ public:
|
||||
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 @@ 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<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 @@ private:
|
||||
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;
|
||||
|
||||
49
src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.cc
Normal file
49
src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.cc
Normal file
@@ -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
|
||||
61
src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.h
Normal file
61
src/lr-wpan/model/lr-wpan-spectrum-signal-parameters.h
Normal file
@@ -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 */
|
||||
@@ -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")
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user