merge
This commit is contained in:
@@ -23,49 +23,52 @@
|
||||
# - DropTail queues
|
||||
# - Tracing of queues and packet receptions to file "udp-echo.tr"
|
||||
|
||||
import ns3
|
||||
|
||||
import ns.applications
|
||||
import ns.core
|
||||
import ns.csma
|
||||
import ns.internet
|
||||
import ns.network
|
||||
|
||||
def main(argv):
|
||||
#
|
||||
# Allow the user to override any of the defaults and the above Bind() at
|
||||
# run-time, via command-line arguments
|
||||
#
|
||||
cmd = ns3.CommandLine()
|
||||
cmd = ns.core.CommandLine()
|
||||
cmd.Parse(argv)
|
||||
|
||||
#
|
||||
# But since this is a realtime script, don't allow the user to mess with
|
||||
# that.
|
||||
#
|
||||
ns3.GlobalValue.Bind("SimulatorImplementationType", ns3.StringValue("ns3::RealtimeSimulatorImpl"))
|
||||
ns.core.GlobalValue.Bind("SimulatorImplementationType", ns.core.StringValue("ns3::RealtimeSimulatorImpl"))
|
||||
|
||||
#
|
||||
# Explicitly create the nodes required by the topology (shown above).
|
||||
#
|
||||
print "Create nodes."
|
||||
n = ns3.NodeContainer()
|
||||
n = ns.network.NodeContainer()
|
||||
n.Create(4)
|
||||
|
||||
internet = ns3.InternetStackHelper()
|
||||
internet = ns.internet.InternetStackHelper()
|
||||
internet.Install(n)
|
||||
|
||||
#
|
||||
# Explicitly create the channels required by the topology (shown above).
|
||||
#
|
||||
print ("Create channels.")
|
||||
csma = ns3.CsmaHelper()
|
||||
csma.SetChannelAttribute("DataRate", ns3.DataRateValue(ns3.DataRate(5000000)))
|
||||
csma.SetChannelAttribute("Delay", ns3.TimeValue(ns3.MilliSeconds(2)));
|
||||
csma.SetDeviceAttribute("Mtu", ns3.UintegerValue(1400))
|
||||
csma = ns.csma.CsmaHelper()
|
||||
csma.SetChannelAttribute("DataRate", ns.network.DataRateValue(ns.network.DataRate(5000000)))
|
||||
csma.SetChannelAttribute("Delay", ns.core.TimeValue(ns.core.MilliSeconds(2)));
|
||||
csma.SetDeviceAttribute("Mtu", ns.core.UintegerValue(1400))
|
||||
d = csma.Install(n)
|
||||
|
||||
#
|
||||
# We've got the "hardware" in place. Now we need to add IP addresses.
|
||||
#
|
||||
print ("Assign IP Addresses.")
|
||||
ipv4 = ns3.Ipv4AddressHelper()
|
||||
ipv4.SetBase(ns3.Ipv4Address("10.1.1.0"), ns3.Ipv4Mask("255.255.255.0"))
|
||||
ipv4 = ns.internet.Ipv4AddressHelper()
|
||||
ipv4.SetBase(ns.network.Ipv4Address("10.1.1.0"), ns.network.Ipv4Mask("255.255.255.0"))
|
||||
i = ipv4.Assign(d)
|
||||
|
||||
print ("Create Applications.")
|
||||
@@ -74,10 +77,10 @@ def main(argv):
|
||||
# Create a UdpEchoServer application on node one.
|
||||
#
|
||||
port = 9 # well-known echo port number
|
||||
server = ns3.UdpEchoServerHelper(port)
|
||||
server = ns.applications.UdpEchoServerHelper(port)
|
||||
apps = server.Install(n.Get(1))
|
||||
apps.Start(ns3.Seconds(1.0))
|
||||
apps.Stop(ns3.Seconds(10.0))
|
||||
apps.Start(ns.core.Seconds(1.0))
|
||||
apps.Stop(ns.core.Seconds(10.0))
|
||||
|
||||
#
|
||||
# Create a UdpEchoClient application to send UDP datagrams from node zero to
|
||||
@@ -85,16 +88,16 @@ def main(argv):
|
||||
#
|
||||
packetSize = 1024
|
||||
maxPacketCount = 500
|
||||
interPacketInterval = ns3.Seconds(0.01)
|
||||
client = ns3.UdpEchoClientHelper(i.GetAddress (1), port)
|
||||
client.SetAttribute("MaxPackets", ns3.UintegerValue(maxPacketCount))
|
||||
client.SetAttribute("Interval", ns3.TimeValue(interPacketInterval))
|
||||
client.SetAttribute("PacketSize", ns3.UintegerValue(packetSize))
|
||||
interPacketInterval = ns.core.Seconds(0.01)
|
||||
client = ns.applications.UdpEchoClientHelper(i.GetAddress (1), port)
|
||||
client.SetAttribute("MaxPackets", ns.core.UintegerValue(maxPacketCount))
|
||||
client.SetAttribute("Interval", ns.core.TimeValue(interPacketInterval))
|
||||
client.SetAttribute("PacketSize", ns.core.UintegerValue(packetSize))
|
||||
apps = client.Install(n.Get(0))
|
||||
apps.Start(ns3.Seconds(2.0))
|
||||
apps.Stop(ns3.Seconds(10.0))
|
||||
apps.Start(ns.core.Seconds(2.0))
|
||||
apps.Stop(ns.core.Seconds(10.0))
|
||||
|
||||
ascii = ns3.AsciiTraceHelper()
|
||||
ascii = ns.network.AsciiTraceHelper()
|
||||
csma.EnableAsciiAll(ascii.CreateFileStream("realtime-udp-echo.tr"))
|
||||
csma.EnablePcapAll("realtime-udp-echo", False)
|
||||
|
||||
@@ -102,8 +105,8 @@ def main(argv):
|
||||
# Now, do the actual simulation.
|
||||
#
|
||||
print ("Run Simulation.")
|
||||
ns3.Simulator.Run()
|
||||
ns3.Simulator.Destroy()
|
||||
ns.core.Simulator.Run()
|
||||
ns.core.Simulator.Destroy()
|
||||
print ("Done.")
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -3,3 +3,5 @@
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_program('realtime-udp-echo', ['csma', 'internet'])
|
||||
obj.source = 'realtime-udp-echo.cc'
|
||||
|
||||
bld.register_ns3_script('realtime-udp-echo.py', ['csma', 'internet', 'applications'])
|
||||
|
||||
@@ -105,7 +105,8 @@ RttEstimator::RttEstimator () : next (1), history (),
|
||||
|
||||
RttEstimator::RttEstimator(const RttEstimator& c)
|
||||
: Object (c), next(c.next), history(c.history),
|
||||
m_maxMultiplier (c.m_maxMultiplier), est(c.est), nSamples(c.nSamples),
|
||||
m_maxMultiplier (c.m_maxMultiplier), est(c.est),
|
||||
minrto(c.minrto), nSamples(c.nSamples),
|
||||
multiplier(c.multiplier)
|
||||
{}
|
||||
|
||||
|
||||
@@ -272,7 +272,6 @@ LenaHelper::InstallSingleUeDevice (Ptr<Node> n)
|
||||
n->AddDevice (dev);
|
||||
dlPhy->SetGenericPhyRxEndOkCallback (MakeCallback (&LteUePhy::PhyPduReceived, phy));
|
||||
|
||||
dev->Start ();
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -306,8 +305,12 @@ LenaHelper::Attach (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice)
|
||||
|
||||
// WILD HACK - should be done through PHY SAP, probably passing by RRC
|
||||
uePhy->SetRnti (rnti);
|
||||
uePhy->DoSetBandwidth (enbDevice->GetObject<LteEnbNetDevice> ()->GetUlBandwidth (),
|
||||
uePhy->DoSetBandwidth (enbDevice->GetObject<LteEnbNetDevice> ()->GetUlBandwidth (),
|
||||
enbDevice->GetObject<LteEnbNetDevice> ()->GetDlBandwidth ());
|
||||
uePhy->DoSetEarfcn (enbDevice->GetObject<LteEnbNetDevice> ()->GetDlEarfcn (),
|
||||
enbDevice->GetObject<LteEnbNetDevice> ()->GetUlEarfcn ());
|
||||
|
||||
ueDevice->Start ();
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +350,7 @@ LenaHelper::EnableLogComponents (void)
|
||||
LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
|
||||
|
||||
LogComponentEnable ("LteSpectrumValueHelper", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("LteInterference", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("LteSinrChunkProcessor", LOG_LEVEL_ALL);
|
||||
|
||||
@@ -76,13 +76,13 @@ TypeId LteEnbNetDevice::GetTypeId (void)
|
||||
MakePointerAccessor (&LteEnbNetDevice::m_phy),
|
||||
MakePointerChecker <LteEnbPhy> ())
|
||||
.AddAttribute ("UlBandwidth",
|
||||
"Uplink bandwidth in number of Resource Blocks",
|
||||
"Uplink Transmission Bandwidth Configuration in number of Resource Blocks",
|
||||
UintegerValue (25),
|
||||
MakeUintegerAccessor (&LteEnbNetDevice::SetUlBandwidth,
|
||||
&LteEnbNetDevice::GetUlBandwidth),
|
||||
MakeUintegerChecker<uint8_t> ())
|
||||
.AddAttribute ("DlBandwidth",
|
||||
"Downlink bandwidth in number of Resource Blocks",
|
||||
"Downlink Transmission Bandwidth Configuration in number of Resource Blocks",
|
||||
UintegerValue (25),
|
||||
MakeUintegerAccessor (&LteEnbNetDevice::SetDlBandwidth,
|
||||
&LteEnbNetDevice::GetDlBandwidth),
|
||||
@@ -92,6 +92,18 @@ TypeId LteEnbNetDevice::GetTypeId (void)
|
||||
UintegerValue (0),
|
||||
MakeUintegerAccessor (&LteEnbNetDevice::m_cellId),
|
||||
MakeUintegerChecker<uint16_t> ())
|
||||
.AddAttribute ("DlEarfcn",
|
||||
"Downlink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
|
||||
"as per 3GPP 36.101 Section 5.7.3. ",
|
||||
UintegerValue (100),
|
||||
MakeUintegerAccessor (&LteEnbNetDevice::m_dlEarfcn),
|
||||
MakeUintegerChecker<uint16_t> ())
|
||||
.AddAttribute ("UlEarfcn",
|
||||
"Uplink E-UTRA Absolute Radio Frequency Channel Number (EARFCN) "
|
||||
"as per 3GPP 36.101 Section 5.7.3. ",
|
||||
UintegerValue (18100),
|
||||
MakeUintegerAccessor (&LteEnbNetDevice::m_ulEarfcn),
|
||||
MakeUintegerChecker<uint16_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
@@ -220,11 +232,39 @@ LteEnbNetDevice::SetDlBandwidth (uint8_t bw)
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t
|
||||
LteEnbNetDevice::GetDlEarfcn () const
|
||||
{
|
||||
return m_dlEarfcn;
|
||||
}
|
||||
|
||||
void
|
||||
LteEnbNetDevice::SetDlEarfcn (uint16_t earfcn)
|
||||
{
|
||||
m_dlEarfcn = earfcn;
|
||||
}
|
||||
|
||||
uint16_t
|
||||
LteEnbNetDevice::GetUlEarfcn () const
|
||||
{
|
||||
return m_ulEarfcn;
|
||||
}
|
||||
|
||||
void
|
||||
LteEnbNetDevice::SetUlEarfcn (uint16_t earfcn)
|
||||
{
|
||||
m_ulEarfcn = earfcn;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LteEnbNetDevice::DoStart (void)
|
||||
{
|
||||
m_cellId = ++m_cellIdCounter;
|
||||
UpdateConfig ();
|
||||
UpdateConfig ();
|
||||
m_phy->Start ();
|
||||
m_mac->Start ();
|
||||
m_rrc->Start ();
|
||||
}
|
||||
|
||||
|
||||
@@ -274,8 +314,10 @@ LteEnbNetDevice::UpdateConfig (void)
|
||||
|
||||
m_rrc->ConfigureCell (m_ulBandwidth, m_dlBandwidth);
|
||||
|
||||
// WILD HACK - should use the PHY SAP instead. Probably should handle this through the RRC
|
||||
// Configuring directly for now, but ideally we should use the PHY
|
||||
// SAP instead. Probably should handle this through the RRC.
|
||||
m_phy->DoSetBandwidth (m_ulBandwidth, m_dlBandwidth);
|
||||
m_phy->DoSetEarfcn (m_dlEarfcn, m_ulEarfcn);
|
||||
m_phy->DoSetCellId (m_cellId);
|
||||
|
||||
}
|
||||
|
||||
@@ -105,6 +105,26 @@ public:
|
||||
*/
|
||||
void SetDlBandwidth (uint8_t bw);
|
||||
|
||||
/**
|
||||
* \return the downlink carrier frequency (EARFCN)
|
||||
*/
|
||||
uint16_t GetDlEarfcn () const;
|
||||
|
||||
/**
|
||||
* \param bw the downlink carrier frequency (EARFCN)
|
||||
*/
|
||||
void SetDlEarfcn (uint16_t earfcn);
|
||||
|
||||
/**
|
||||
* \return the uplink carrier frequency (EARFCN)
|
||||
*/
|
||||
uint16_t GetUlEarfcn () const;
|
||||
|
||||
/**
|
||||
* \param bw the uplink carrier frequency (EARFCN)
|
||||
*/
|
||||
void SetUlEarfcn (uint16_t earfcn);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -144,6 +164,9 @@ private:
|
||||
|
||||
uint8_t m_dlBandwidth; /**< downlink bandwidth in RBs */
|
||||
uint8_t m_ulBandwidth; /**< uplink bandwidth in RBs */
|
||||
|
||||
uint16_t m_dlEarfcn; /**< downlink carrier frequency */
|
||||
uint16_t m_ulEarfcn; /**< uplink carrier frequency */
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -158,6 +158,16 @@ LteEnbPhy::DoDispose ()
|
||||
LtePhy::DoDispose ();
|
||||
}
|
||||
|
||||
void
|
||||
LteEnbPhy::DoStart ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_noiseFigure);
|
||||
m_uplinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
|
||||
LtePhy::DoStart ();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LteEnbPhy::SetLteEnbPhySapUser (LteEnbPhySapUser* s)
|
||||
{
|
||||
@@ -189,8 +199,6 @@ LteEnbPhy::SetNoiseFigure (double nf)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << nf);
|
||||
m_noiseFigure = nf;
|
||||
Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (m_noiseFigure);
|
||||
m_uplinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
|
||||
}
|
||||
|
||||
double
|
||||
@@ -268,8 +276,7 @@ LteEnbPhy::CreateTxPowerSpectralDensity ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
LteSpectrumValueHelper psdHelper;
|
||||
Ptr<SpectrumValue> psd = psdHelper.CreateDownlinkTxPowerSpectralDensity (GetTxPower (), GetDownlinkSubChannels ());
|
||||
Ptr<SpectrumValue> psd = LteSpectrumValueHelper::CreateTxPowerSpectralDensity (m_dlEarfcn, m_dlBandwidth, m_txPower, GetDownlinkSubChannels ());
|
||||
|
||||
return psd;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ public:
|
||||
|
||||
virtual ~LteEnbPhy ();
|
||||
|
||||
// inherited from Object
|
||||
static TypeId GetTypeId (void);
|
||||
virtual void DoStart (void);
|
||||
virtual void DoDispose (void);
|
||||
|
||||
|
||||
|
||||
@@ -207,6 +207,12 @@ LtePhy::DoSetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LtePhy::DoSetEarfcn (uint16_t dlEarfcn, uint16_t ulEarfcn)
|
||||
{
|
||||
m_dlEarfcn = dlEarfcn;
|
||||
m_ulEarfcn = ulEarfcn;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
LtePhy::GetRbgSize (void) const
|
||||
|
||||
@@ -159,6 +159,13 @@ public:
|
||||
*/
|
||||
void DoSetBandwidth (uint8_t ulBandwidth, uint8_t dlBandwidth);
|
||||
|
||||
/**
|
||||
*
|
||||
* \param dlEarfcn the carrier frequency (EARFCN) in downlink
|
||||
* \param ulEarfcn the carrier frequency (EARFCN) in downlink
|
||||
*/
|
||||
virtual void DoSetEarfcn (uint16_t dlEarfcn, uint16_t ulEarfcn);
|
||||
|
||||
/**
|
||||
*
|
||||
* \param cellId the Cell Identifier
|
||||
@@ -227,6 +234,9 @@ protected:
|
||||
uint8_t m_ulBandwidth;
|
||||
uint8_t m_dlBandwidth;
|
||||
uint8_t m_rbgSize;
|
||||
|
||||
uint16_t m_dlEarfcn;
|
||||
uint16_t m_ulEarfcn;
|
||||
|
||||
std::vector< Ptr<PacketBurst> > m_packetBurstQueue;
|
||||
std::vector< std::list<Ptr<IdealControlMessage> > > m_controlMessagesQueue;
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
* Nicola Baldo <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
#include <ns3/log.h>
|
||||
#include<map>
|
||||
#include <cmath>
|
||||
|
||||
#include <ns3/log.h>
|
||||
#include "lte-spectrum-value-helper.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("LteSpectrumValueHelper");
|
||||
@@ -103,7 +103,7 @@ LteSpectrumValueHelper::GetDownlinkCarrierFrequency (uint16_t nDl)
|
||||
(g_eutraChannelNumbers[i].rangeNdl2 >= nDl))
|
||||
{
|
||||
NS_LOG_LOGIC ("entry " << i << " fDlLow=" << g_eutraChannelNumbers[i].fDlLow);
|
||||
return g_eutraChannelNumbers[i].fDlLow + 0.1 * (nDl - g_eutraChannelNumbers[i].nOffsDl);
|
||||
return 1.0e6 * (g_eutraChannelNumbers[i].fDlLow + 0.1 * (nDl - g_eutraChannelNumbers[i].nOffsDl));
|
||||
}
|
||||
}
|
||||
NS_LOG_ERROR ("invalid EARFCN " << nDl);
|
||||
@@ -120,134 +120,149 @@ LteSpectrumValueHelper::GetUplinkCarrierFrequency (uint16_t nUl)
|
||||
(g_eutraChannelNumbers[i].rangeNul2 >= nUl))
|
||||
{
|
||||
NS_LOG_LOGIC ("entry " << i << " fUlLow=" << g_eutraChannelNumbers[i].fUlLow);
|
||||
return g_eutraChannelNumbers[i].fUlLow + 0.1 * (nUl - g_eutraChannelNumbers[i].nOffsUl);
|
||||
return 1.0e6 * (g_eutraChannelNumbers[i].fUlLow + 0.1 * (nUl - g_eutraChannelNumbers[i].nOffsUl));
|
||||
}
|
||||
}
|
||||
NS_LOG_ERROR ("invalid EARFCN " << nUl);
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Ptr<SpectrumModel> LteDownlinkSpectrumModel;
|
||||
Ptr<SpectrumModel> LteUplinkSpectrumModel;
|
||||
|
||||
class static_LteDownlinkSpectrumModel_initializer
|
||||
double
|
||||
LteSpectrumValueHelper::GetChannelBandwidth (uint8_t transmissionBandwidth)
|
||||
{
|
||||
public:
|
||||
static_LteDownlinkSpectrumModel_initializer ()
|
||||
{
|
||||
|
||||
/*
|
||||
* Operating Bands for the UL: 1920 MHz – 1980 MHz
|
||||
* see for details TR.36.101 - Tab 5.5-1
|
||||
*
|
||||
*/
|
||||
|
||||
std::vector<double> freqs;
|
||||
/* WILD HACK
|
||||
* banwidth 25
|
||||
*/
|
||||
for (int i = 0; i < 25; ++i)
|
||||
{
|
||||
|
||||
double centralFrequencyOfPRB = 1.920 + (i * 0.00018);
|
||||
freqs.push_back (centralFrequencyOfPRB * 1e9);
|
||||
}
|
||||
|
||||
LteDownlinkSpectrumModel = Create<SpectrumModel> (freqs);
|
||||
}
|
||||
|
||||
} static_LteDownlinkSpectrumModel_initializer_instance;
|
||||
NS_LOG_FUNCTION ((uint16_t) transmissionBandwidth);
|
||||
switch (transmissionBandwidth)
|
||||
{
|
||||
case 6:
|
||||
return 1.4e6;
|
||||
case 15:
|
||||
return 3.0e6;
|
||||
case 25:
|
||||
return 5.0e6;
|
||||
case 50:
|
||||
return 10.0e6;
|
||||
case 75:
|
||||
return 15.0e6;
|
||||
case 100:
|
||||
return 20.0e6;
|
||||
default:
|
||||
NS_FATAL_ERROR ("invalid bandwidth value " << (uint16_t) transmissionBandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class static_LteUplinkSpectrumModel_initializer
|
||||
|
||||
struct LteSpectrumModelId
|
||||
{
|
||||
public:
|
||||
static_LteUplinkSpectrumModel_initializer ()
|
||||
{
|
||||
LteSpectrumModelId (uint16_t f, uint8_t b);
|
||||
uint16_t earfcn;
|
||||
uint8_t bandwidth;
|
||||
};
|
||||
|
||||
/*
|
||||
* Operating Bands for the DL: 2110 MHz – 2170 MHz
|
||||
* see for details TR.36.101 - Tab 5.5-1
|
||||
*
|
||||
*/
|
||||
|
||||
std::vector<double> freqs;
|
||||
/* WILD HACK
|
||||
* banwidth 25
|
||||
*/
|
||||
for (int i = 0; i < 25; ++i)
|
||||
{
|
||||
|
||||
double centralFrequencyOfPRB = 2.110 + (i * 0.00018);
|
||||
freqs.push_back (centralFrequencyOfPRB * 1e9);
|
||||
}
|
||||
|
||||
LteUplinkSpectrumModel = Create<SpectrumModel> (freqs);
|
||||
}
|
||||
|
||||
} static_LteUplinkSpectrumModel_initializer_instance;
|
||||
|
||||
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
LteSpectrumValueHelper::CreateDownlinkTxPowerSpectralDensity (double powerTx, std::vector<int> channels)
|
||||
LteSpectrumModelId::LteSpectrumModelId (uint16_t f, uint8_t b)
|
||||
: earfcn (f),
|
||||
bandwidth (b)
|
||||
{
|
||||
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteDownlinkSpectrumModel);
|
||||
}
|
||||
|
||||
bool
|
||||
operator < (const LteSpectrumModelId& a, const LteSpectrumModelId& b)
|
||||
{
|
||||
return ( (a.earfcn < b.earfcn) || ( (a.earfcn == b.earfcn) && (a.bandwidth < b.bandwidth) ) );
|
||||
}
|
||||
|
||||
|
||||
static std::map<LteSpectrumModelId, Ptr<SpectrumModel> > g_lteSpectrumModelMap;
|
||||
|
||||
|
||||
Ptr<SpectrumModel>
|
||||
LteSpectrumValueHelper::GetSpectrumModel (uint16_t earfcn, uint8_t txBandwidthConfiguration)
|
||||
{
|
||||
NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration);
|
||||
Ptr<SpectrumModel> ret;
|
||||
LteSpectrumModelId key (earfcn, txBandwidthConfiguration);
|
||||
std::map<LteSpectrumModelId, Ptr<SpectrumModel> >::iterator it = g_lteSpectrumModelMap.find (key);
|
||||
if (it != g_lteSpectrumModelMap.end ())
|
||||
{
|
||||
ret = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
double fc = GetCarrierFrequency (earfcn);
|
||||
NS_ASSERT_MSG (fc != 0, "invalid EARFCN=" << earfcn);
|
||||
|
||||
double f = fc - (txBandwidthConfiguration * 180e3 / 2.0);
|
||||
Bands rbs;
|
||||
for (uint8_t numrb = 0; numrb < txBandwidthConfiguration; ++numrb)
|
||||
{
|
||||
BandInfo rb;
|
||||
rb.fl = f;
|
||||
f += 90e3;
|
||||
rb.fc = f;
|
||||
f += 90e3;
|
||||
rb.fh = f;
|
||||
rbs.push_back (rb);
|
||||
}
|
||||
ret = Create<SpectrumModel> (rbs);
|
||||
g_lteSpectrumModelMap.insert (std::pair<LteSpectrumModelId, Ptr<SpectrumModel> > (key, ret));
|
||||
}
|
||||
NS_LOG_LOGIC ("returning SpectrumModel::GetUid () == " << ret->GetUid ());
|
||||
return ret;
|
||||
}
|
||||
|
||||
// just needed to log a std::vector<int> properly...
|
||||
std::ostream&
|
||||
operator << (std::ostream& os, const std::vector<int>& v)
|
||||
{
|
||||
std::vector<int>::const_iterator it = v.begin ();
|
||||
while (it != v.end ())
|
||||
{
|
||||
os << *it << " " ;
|
||||
++it;
|
||||
}
|
||||
os << std::endl;
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
LteSpectrumValueHelper::CreateTxPowerSpectralDensity (uint16_t earfcn, uint8_t txBandwidthConfiguration, double powerTx, std::vector <int> activeRbs)
|
||||
{
|
||||
NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration << powerTx << activeRbs);
|
||||
|
||||
Ptr<SpectrumModel> model = GetSpectrumModel (earfcn, txBandwidthConfiguration);
|
||||
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (model);
|
||||
|
||||
// powerTx is expressed in dBm. We must convert it into natural unit.
|
||||
powerTx = pow (10., (powerTx - 30) / 10);
|
||||
double powerTxW = pow (10., (powerTx - 30) / 10);
|
||||
|
||||
double txPowerDensity = (powerTx / channels.size ()) / 180000;
|
||||
double txPowerDensity = (powerTxW / GetChannelBandwidth (txBandwidthConfiguration));
|
||||
|
||||
for (std::vector <int>::iterator it = channels.begin (); it != channels.end (); it++)
|
||||
for (std::vector <int>::iterator it = activeRbs.begin (); it != activeRbs.end (); it++)
|
||||
{
|
||||
int idSubChannel = (*it);
|
||||
(*txPsd)[idSubChannel] = txPowerDensity;
|
||||
int rbId = (*it);
|
||||
(*txPsd)[rbId] = txPowerDensity;
|
||||
}
|
||||
|
||||
NS_LOG_LOGIC (*txPsd);
|
||||
|
||||
return txPsd;
|
||||
}
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
LteSpectrumValueHelper::CreateUplinkTxPowerSpectralDensity (double powerTx, std::vector<int> channels)
|
||||
LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (uint16_t earfcn, uint8_t txBandwidthConfiguration, double noiseFigure)
|
||||
{
|
||||
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (LteUplinkSpectrumModel);
|
||||
|
||||
// powerTx is expressed in dBm. We must convert it into natural unit.
|
||||
powerTx = pow (10., (powerTx - 30) / 10);
|
||||
|
||||
double txPowerDensity = (powerTx / channels.size ()) / 180000;
|
||||
|
||||
for (std::vector <int>::iterator it = channels.begin (); it != channels.end (); it++)
|
||||
{
|
||||
int idSubChannel = (*it);
|
||||
(*txPsd)[idSubChannel] = txPowerDensity;
|
||||
}
|
||||
|
||||
return txPsd;
|
||||
}
|
||||
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (double noiseFigure)
|
||||
{
|
||||
return CreateNoisePowerSpectralDensity (noiseFigure, LteDownlinkSpectrumModel);
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
LteSpectrumValueHelper::CreateUplinkNoisePowerSpectralDensity (double noiseFigure)
|
||||
{
|
||||
return CreateNoisePowerSpectralDensity (noiseFigure, LteUplinkSpectrumModel);
|
||||
NS_LOG_FUNCTION (earfcn << (uint16_t) txBandwidthConfiguration << noiseFigure);
|
||||
Ptr<SpectrumModel> model = GetSpectrumModel (earfcn, txBandwidthConfiguration);
|
||||
return CreateNoisePowerSpectralDensity (noiseFigure, model);
|
||||
}
|
||||
|
||||
Ptr<SpectrumValue>
|
||||
LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (double noiseFigureDb, Ptr<SpectrumModel> spectrumModel)
|
||||
{
|
||||
NS_LOG_FUNCTION (noiseFigureDb << spectrumModel);
|
||||
double noiseFigureLinear = pow (10.0, noiseFigureDb / 10.0);
|
||||
static const double BOLTZMANN = 1.3803e-23;
|
||||
static const double ROOM_TEMPERATURE = 290.0;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
*
|
||||
* \param earfcn the EARFCN
|
||||
*
|
||||
* \return the carrier frequency in MHz
|
||||
* \return the carrier frequency in Hz
|
||||
*/
|
||||
static double GetCarrierFrequency (uint16_t earfcn);
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
*
|
||||
* \param earfcn the EARFCN
|
||||
*
|
||||
* \return the dowlink carrier frequency in MHz
|
||||
* \return the dowlink carrier frequency in Hz
|
||||
*/
|
||||
static double GetDownlinkCarrierFrequency (uint16_t earfcn);
|
||||
|
||||
@@ -65,44 +65,63 @@ public:
|
||||
*
|
||||
* \param earfcn the EARFCN
|
||||
*
|
||||
* \return the uplink carrier frequency in MHz
|
||||
* \return the uplink carrier frequency in Hz
|
||||
*/
|
||||
static double GetUplinkCarrierFrequency (uint16_t earfcn);
|
||||
|
||||
/**
|
||||
* \brief create spectrum value
|
||||
* \param powerTx the power transmission in dBm
|
||||
* \param channels the list of sub channels where the signal will be sent
|
||||
* \return a Ptr to a newly created SpectrumValue instance
|
||||
/**
|
||||
*
|
||||
*
|
||||
* \param txBandwidthConf the tranmission bandwidth
|
||||
* configuration in number of resource blocks
|
||||
*
|
||||
* \return the nominal channel bandwidth in Hz as per 3GPP TS 36.101
|
||||
*/
|
||||
static Ptr<SpectrumValue> CreateDownlinkTxPowerSpectralDensity (double powerTx, std::vector <int> channels);
|
||||
static double GetChannelBandwidth (uint8_t txBandwidthConf);
|
||||
|
||||
/**
|
||||
*
|
||||
* \param earfcn the carrier frequency (EARFCN) at which reception
|
||||
* is made
|
||||
* \param bandwidth the Transmission Bandwidth Configuration in
|
||||
* number of resource blocks
|
||||
*
|
||||
* \return the static SpectrumModel instance corresponding to the
|
||||
* given carrier frequency and transmission bandwidth
|
||||
* configuration. If such SpectrumModel does not exist, it is
|
||||
* created.
|
||||
*/
|
||||
static Ptr<SpectrumModel> GetSpectrumModel (uint16_t earfcn, uint8_t bandwdith);
|
||||
|
||||
|
||||
/**
|
||||
* \brief create spectrum value
|
||||
* \param powerTx the power transmission in dBm
|
||||
* \param channels the list of sub channels where the signal will be sent
|
||||
* create a spectrum value representing the power spectral
|
||||
* density of a signal to be transmitted. See 3GPP TS 36.101 for
|
||||
* a definition of most of the parameters described here.
|
||||
*
|
||||
* \param earfcn the carrier frequency (EARFCN) of the transmission
|
||||
* \param bandwidth the Transmission Bandwidth Configuration in
|
||||
* number of resource blocks
|
||||
* \param txPower the total power in dBm over the whole bandwidth
|
||||
* \param ActiveRbs the list of Active Resource Blocks (PRBs)
|
||||
*
|
||||
* \return a Ptr to a newly created SpectrumValue instance
|
||||
*/
|
||||
static Ptr<SpectrumValue> CreateUplinkTxPowerSpectralDensity (double powerTx, std::vector <int> channels);
|
||||
static Ptr<SpectrumValue> CreateTxPowerSpectralDensity (uint16_t earfcn, uint8_t bandwdith, double powerTx, std::vector <int> activeRbs);
|
||||
|
||||
|
||||
/**
|
||||
* create a SpectrumValue that models the power spectral density of AWGN
|
||||
*
|
||||
* \param earfcn the carrier frequency (EARFCN) at which reception
|
||||
* is made
|
||||
* \param bandwidth the Transmission Bandwidth Configuration in
|
||||
* number of resource blocks
|
||||
* \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
|
||||
*
|
||||
* \return a Ptr to a newly created SpectrumValue instance
|
||||
*/
|
||||
static Ptr<SpectrumValue> CreateDownlinkNoisePowerSpectralDensity (double noiseFigure);
|
||||
|
||||
/**
|
||||
* create a SpectrumValue that models the power spectral density of AWGN
|
||||
*
|
||||
* \param noiseFigure the noise figure in dB w.r.t. a reference temperature of 290K
|
||||
*
|
||||
* \return a Ptr to a newly created SpectrumValue instance
|
||||
*/
|
||||
static Ptr<SpectrumValue> CreateUplinkNoisePowerSpectralDensity (double noiseFigure);
|
||||
static Ptr<SpectrumValue> CreateNoisePowerSpectralDensity (uint16_t earfcn, uint8_t bandwdith, double noiseFigure);
|
||||
|
||||
/**
|
||||
* create a SpectrumValue that models the power spectral density of AWGN
|
||||
|
||||
@@ -144,7 +144,7 @@ LteUeNetDevice::SetTargetEnb (Ptr<LteEnbNetDevice> enb)
|
||||
NS_LOG_FUNCTION (this << enb);
|
||||
m_targetEnb = enb;
|
||||
|
||||
// WILD HACK - should go through RRC and then through PHY SAP
|
||||
// should go through RRC and then through PHY SAP
|
||||
m_phy->DoSetCellId (enb->GetCellId ());
|
||||
}
|
||||
|
||||
@@ -168,6 +168,9 @@ LteUeNetDevice::DoStart (void)
|
||||
{
|
||||
UpdateConfig ();
|
||||
m_imsi = ++m_imsiCounter;
|
||||
m_phy->Start ();
|
||||
m_mac->Start ();
|
||||
m_rrc->Start ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +153,14 @@ LteUePhy::GetTypeId (void)
|
||||
return tid;
|
||||
}
|
||||
|
||||
void
|
||||
LteUePhy::DoStart ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (m_dlEarfcn, m_dlBandwidth, m_noiseFigure);
|
||||
m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
|
||||
LtePhy::DoStart ();
|
||||
}
|
||||
|
||||
void
|
||||
LteUePhy::SetLteUePhySapUser (LteUePhySapUser* s)
|
||||
@@ -173,8 +181,6 @@ LteUePhy::SetNoiseFigure (double nf)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << nf);
|
||||
m_noiseFigure = nf;
|
||||
Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateDownlinkNoisePowerSpectralDensity (m_noiseFigure);
|
||||
m_downlinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
|
||||
}
|
||||
|
||||
double
|
||||
@@ -267,7 +273,7 @@ LteUePhy::CreateTxPowerSpectralDensity ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
LteSpectrumValueHelper psdHelper;
|
||||
Ptr<SpectrumValue> psd = psdHelper.CreateUplinkTxPowerSpectralDensity (GetTxPower (), GetSubChannelsForTransmission ());
|
||||
Ptr<SpectrumValue> psd = psdHelper.CreateTxPowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_txPower, GetSubChannelsForTransmission ());
|
||||
|
||||
return psd;
|
||||
}
|
||||
|
||||
@@ -63,9 +63,10 @@ public:
|
||||
|
||||
virtual ~LteUePhy ();
|
||||
|
||||
virtual void DoDispose ();
|
||||
// inherited from Object
|
||||
static TypeId GetTypeId (void);
|
||||
|
||||
virtual void DoStart (void);
|
||||
virtual void DoDispose (void);
|
||||
|
||||
/**
|
||||
* \brief Get the PHY SAP provider
|
||||
|
||||
@@ -44,12 +44,12 @@ using namespace ns3;
|
||||
LteDownlinkSinrTestSuite::LteDownlinkSinrTestSuite ()
|
||||
: TestSuite ("lte-downlink-sinr", SYSTEM)
|
||||
{
|
||||
LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
|
||||
// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
|
||||
|
||||
LogComponentEnable ("LteTestUePhy", logLevel);
|
||||
LogComponentEnable ("LteDownlinkSinrTest", logLevel);
|
||||
// LogComponentEnable ("LteTestUePhy", logLevel);
|
||||
// LogComponentEnable ("LteDownlinkSinrTest", logLevel);
|
||||
|
||||
NS_LOG_INFO ("Creating LteDownlinkSinrTestSuite");
|
||||
// NS_LOG_INFO ("Creating LteDownlinkSinrTestSuite");
|
||||
|
||||
/**
|
||||
* Build Spectrum Model values for the TX signal
|
||||
|
||||
@@ -122,32 +122,32 @@ public:
|
||||
static LteEarfcnTestSuite g_lteEarfcnTestSuite;
|
||||
|
||||
LteEarfcnTestSuite::LteEarfcnTestSuite ()
|
||||
: TestSuite ("lte-earfcn", SYSTEM)
|
||||
: TestSuite ("lte-earfcn", UNIT)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=500", 500, 2110+50));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1000", 1000, 1930+(100-60)));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1301", 1301, 1805+(130.1-120)));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=500", 500, 2160e6));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1000", 1000, 1970e6));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=1301", 1301, 1815.1e6));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=7000", 7000, 0.0));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=20000", 20000, 0.0));
|
||||
AddTestCase (new LteEarfcnDlTestCase ("DL EARFCN=50000", 50000, 0.0));
|
||||
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=18100", 18100, 1920 + 1810 - 1800));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19000", 19000, 1850 + 1900 - 1860));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19400", 19400, 1710 + 1940 - 1920));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=18100", 18100, 1930e6));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19000", 19000, 1890e6));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=19400", 19400, 1730e6));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=10", 10, 0.0));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=1000", 1000, 0.0));
|
||||
AddTestCase (new LteEarfcnUlTestCase ("UL EARFCN=50000", 50000, 0.0));
|
||||
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=500", 500, 2110+50));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=1000", 1000, 1930+(100-60)));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=1301", 1301, 1805+(130.1-120)));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=500", 500, 2160e6));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=1000", 1000, 1970e6));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=1301", 1301, 1815.1e6));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=8000", 8000, 0.0));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=50000", 50000, 0.0));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=18100", 18100, 1920 + 1810 - 1800));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=19000", 19000, 1850 + 1900 - 1860));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=19400", 19400, 1710 + 1940 - 1920));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=18100", 18100, 1930e6));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=19000", 19000, 1890e6));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=19400", 19400, 1730e6));
|
||||
AddTestCase (new LteEarfcnTestCase ("EARFCN=50000", 50000, 0.0));
|
||||
}
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ LenaRrFfMacSchedulerTestCase::DoRun (void)
|
||||
mm->SetPosition (Vector (m_dist, 0.0, 0.0));
|
||||
|
||||
lena->EnableRlcTraces ();
|
||||
double simulationTime = 0.040;
|
||||
double simulationTime = 0.010;
|
||||
Simulator::Stop (Seconds (simulationTime));
|
||||
|
||||
Ptr<RlcStatsCalculator> rlcStats = lena->GetRlcStats ();
|
||||
|
||||
1642
src/lte/test/lte-test-spectrum-value-helper.cc
Normal file
1642
src/lte/test/lte-test-spectrum-value-helper.cc
Normal file
File diff suppressed because it is too large
Load Diff
@@ -43,12 +43,12 @@ using namespace ns3;
|
||||
LteUplinkSinrTestSuite::LteUplinkSinrTestSuite ()
|
||||
: TestSuite ("lte-uplink-sinr", SYSTEM)
|
||||
{
|
||||
LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
|
||||
// LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL);
|
||||
|
||||
LogComponentEnable ("LteTestUePhy", logLevel);
|
||||
LogComponentEnable ("LteUplinkSinrTest", logLevel);
|
||||
// LogComponentEnable ("LteTestUePhy", logLevel);
|
||||
// LogComponentEnable ("LteUplinkSinrTest", logLevel);
|
||||
|
||||
NS_LOG_INFO ("Creating LteUplinkSinrTestSuite");
|
||||
// NS_LOG_INFO ("Creating LteUplinkSinrTestSuite");
|
||||
|
||||
/**
|
||||
* Build Spectrum Model values for the TX signal
|
||||
|
||||
@@ -57,6 +57,7 @@ def build(bld):
|
||||
'test/lte-test-rr-ff-mac-scheduler.cc',
|
||||
'test/lte-test-pf-ff-mac-scheduler.cc',
|
||||
'test/lte-test-earfcn.cc',
|
||||
'test/lte-test-spectrum-value-helper.cc',
|
||||
]
|
||||
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
|
||||
152
src/spectrum/test/spectrum-test.h
Normal file
152
src/spectrum/test/spectrum-test.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
* Copyright (c) 2011 CTTC
|
||||
*
|
||||
* 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: Nicola Baldo <nbaldo@cttc.es>
|
||||
* part of the code copied from test.h
|
||||
*/
|
||||
|
||||
#include <ns3/test.h>
|
||||
#include <ns3/spectrum-value.h>
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if two SpectrumModel instances are equal within a given tolerance.
|
||||
*
|
||||
* This test compares component-by-component the two SpectrumModel
|
||||
* instances; if any pair of components differs by more than the given
|
||||
* tolerance, the test fails.
|
||||
*
|
||||
* \param actual the actual value obtained by the simulator
|
||||
* \param expected the expected value obtained by off-line calculations
|
||||
* \param tol the tolerance
|
||||
* \param msg the message to print if the test fails
|
||||
*
|
||||
*/
|
||||
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \
|
||||
NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL(actual, expected, tol, msg, __FILE__, __LINE__)
|
||||
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
|
||||
do \
|
||||
{ \
|
||||
Bands::const_iterator i = (actual).Begin (); \
|
||||
Bands::const_iterator j = (expected).Begin (); \
|
||||
uint32_t k = 0; \
|
||||
while (i != (actual).End () && j != (expected).End ()) \
|
||||
{ \
|
||||
if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) || \
|
||||
(i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) || \
|
||||
(i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
|
||||
{ \
|
||||
if (gBreakOnFailure) {*(int *)0 = 0;} \
|
||||
std::ostringstream indexStream; \
|
||||
indexStream << "[" << k << "]"; \
|
||||
std::ostringstream msgStream; \
|
||||
msgStream << (msg); \
|
||||
std::ostringstream actualStream; \
|
||||
actualStream << i->fl << " <-- " << i->fc << " --> " << i->fh; \
|
||||
std::ostringstream expectedStream; \
|
||||
expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh; \
|
||||
ReportTestFailure (std::string (#actual) + indexStream.str () + " == " + std::string (#expected) + indexStream.str (), \
|
||||
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
|
||||
} \
|
||||
++i; \
|
||||
++j; \
|
||||
++k; \
|
||||
} \
|
||||
if (i != (actual).End () || j != (expected).End ()) \
|
||||
{ \
|
||||
std::ostringstream msgStream; \
|
||||
msgStream << (msg); \
|
||||
std::ostringstream actualStream; \
|
||||
actualStream << (i != (actual).End ()); \
|
||||
std::ostringstream expectedStream; \
|
||||
expectedStream << (j != (expected).End ()); \
|
||||
ReportTestFailure ("Bands::iterator == End ()" , \
|
||||
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
|
||||
} \
|
||||
} \
|
||||
while (false); \
|
||||
|
||||
|
||||
/**
|
||||
* \brief Test if two SpectrumValue instances are equal within a given tolerance.
|
||||
*
|
||||
* This test compares component-by-component the two SpectrumValue
|
||||
* instances; if any pair of components differs by more than the given
|
||||
* tolerance, the test fails.
|
||||
*
|
||||
* \param actual the actual value obtained by the simulator
|
||||
* \param expected the expected value obtained by off-line calculations
|
||||
* \param tol the tolerance
|
||||
* \param msg the message to print if the test fails
|
||||
*
|
||||
*/
|
||||
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
|
||||
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, __FILE__, __LINE__)
|
||||
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
|
||||
do \
|
||||
{ \
|
||||
Values::const_iterator i = (actual).ConstValuesBegin (); \
|
||||
Values::const_iterator j = (expected).ConstValuesBegin (); \
|
||||
uint32_t k = 0; \
|
||||
while (i != (actual).ConstValuesEnd () && j != (expected).ConstValuesEnd ()) \
|
||||
{ \
|
||||
if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol)) \
|
||||
{ \
|
||||
if (gBreakOnFailure) {*(int *)0 = 0;} \
|
||||
std::ostringstream indexStream; \
|
||||
indexStream << "[" << k << "]"; \
|
||||
std::ostringstream msgStream; \
|
||||
msgStream << msg; \
|
||||
std::ostringstream actualStream; \
|
||||
actualStream << actual; \
|
||||
std::ostringstream expectedStream; \
|
||||
expectedStream << expected; \
|
||||
ReportTestFailure (std::string (#actual) + indexStream.str () + " == " + std::string (#expected) + indexStream.str (), \
|
||||
actualStream.str (), expectedStream.str (), msgStream.str (), file, line); \
|
||||
} \
|
||||
++i; \
|
||||
++j; \
|
||||
++k; \
|
||||
} \
|
||||
if (i != (actual).ConstValuesEnd () || j != (expected).ConstValuesEnd ()) \
|
||||
{ \
|
||||
std::ostringstream msgStream; \
|
||||
msgStream << (msg); \
|
||||
std::ostringstream actualStream; \
|
||||
actualStream << (i != (actual).ConstValuesEnd ()); \
|
||||
std::ostringstream expectedStream; \
|
||||
expectedStream << (j != (expected).ConstValuesEnd ()); \
|
||||
ReportTestFailure ("Values::const_iterator == ConstValuesEnd ()" , \
|
||||
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
|
||||
} \
|
||||
} \
|
||||
while (false); \
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
#include "spectrum-value-test.h"
|
||||
#include "spectrum-test.h"
|
||||
|
||||
// NS_LOG_COMPONENT_DEFINE ("SpectrumValueTest");
|
||||
|
||||
@@ -72,6 +72,7 @@ SpectrumValueTestCase::MoreOrLessEqual (SpectrumValue x, SpectrumValue y)
|
||||
void
|
||||
SpectrumValueTestCase::DoRun (void)
|
||||
{
|
||||
NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL (*m_a.GetSpectrumModel (), *m_b.GetSpectrumModel (), TOLERANCE, GetName ());
|
||||
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL (m_a, m_b, TOLERANCE, GetName ());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
* Copyright (c) 2011 CTTC
|
||||
*
|
||||
* 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: Nicola Baldo <nbaldo@cttc.es>
|
||||
* part of the code copied from test.h
|
||||
*/
|
||||
|
||||
#include <ns3/test.h>
|
||||
#include <ns3/spectrum-value.h>
|
||||
|
||||
/**
|
||||
* \brief Test if two SpectrumValue instances are equal within a given tolerance.
|
||||
*
|
||||
* This test compares component-by-component the two SpectrumValue
|
||||
* instances; if any pair of components differs by more than the given
|
||||
* tolerance, the test fails.
|
||||
*
|
||||
* \param actual the actual value obtained by the simulator
|
||||
* \param expected the expected value obtained by off-line calculations
|
||||
* \param tol the tolerance
|
||||
* \param msg the message to print if the test fails
|
||||
*
|
||||
*/
|
||||
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
|
||||
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, __FILE__, __LINE__)
|
||||
|
||||
|
||||
/**
|
||||
* \internal
|
||||
*/
|
||||
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
|
||||
do \
|
||||
{ \
|
||||
Values::const_iterator i = actual.ConstValuesBegin (); \
|
||||
Values::const_iterator j = expected.ConstValuesBegin (); \
|
||||
uint32_t k = 0; \
|
||||
while (i != actual.ConstValuesEnd () && j != expected.ConstValuesEnd ()) \
|
||||
{ \
|
||||
if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol)) \
|
||||
{ \
|
||||
if (gBreakOnFailure) {*(int *)0 = 0;} \
|
||||
std::ostringstream indexStream; \
|
||||
indexStream << "[" << k << "]"; \
|
||||
std::ostringstream msgStream; \
|
||||
msgStream << msg; \
|
||||
std::ostringstream actualStream; \
|
||||
actualStream << actual; \
|
||||
std::ostringstream expectedStream; \
|
||||
expectedStream << expected; \
|
||||
ReportTestFailure (std::string (#actual) + indexStream.str () + " == " + std::string (#expected) + indexStream.str (), \
|
||||
actualStream.str (), expectedStream.str (), msgStream.str (), file, line); \
|
||||
} \
|
||||
++i; \
|
||||
++j; \
|
||||
++k; \
|
||||
} \
|
||||
} \
|
||||
while (false); \
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ def build(bld):
|
||||
'helper/adhoc-aloha-noack-ideal-phy-helper.h',
|
||||
'helper/waveform-generator-helper.h',
|
||||
'helper/spectrum-analyzer-helper.h',
|
||||
'test/spectrum-value-test.h',
|
||||
'test/spectrum-test.h',
|
||||
]
|
||||
|
||||
if (bld.env['ENABLE_EXAMPLES']):
|
||||
|
||||
@@ -17,7 +17,12 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import ns3
|
||||
|
||||
import ns.core
|
||||
import ns.csma
|
||||
import ns.internet
|
||||
import ns.network
|
||||
import ns.tap_bridge
|
||||
|
||||
def main(argv):
|
||||
#
|
||||
@@ -25,15 +30,15 @@ def main(argv):
|
||||
# interact in real-time and therefore we have to use the real-time simulator
|
||||
# and take the time to calculate checksums.
|
||||
#
|
||||
ns3.GlobalValue.Bind("SimulatorImplementationType", ns3.StringValue("ns3::RealtimeSimulatorImpl"))
|
||||
ns3.GlobalValue.Bind("ChecksumEnabled", ns3.BooleanValue("true"))
|
||||
ns.core.GlobalValue.Bind("SimulatorImplementationType", ns.core.StringValue("ns3::RealtimeSimulatorImpl"))
|
||||
ns.core.GlobalValue.Bind("ChecksumEnabled", ns.core.BooleanValue("true"))
|
||||
|
||||
#
|
||||
# Create two ghost nodes. The first will represent the virtual machine host
|
||||
# on the left side of the network; and the second will represent the VM on
|
||||
# the right side.
|
||||
#
|
||||
nodes = ns3.NodeContainer()
|
||||
nodes = ns.network.NodeContainer()
|
||||
nodes.Create (2)
|
||||
|
||||
#
|
||||
@@ -41,7 +46,7 @@ def main(argv):
|
||||
# devices installed on both of the nodes. The data rate and delay for the
|
||||
# channel can be set through the command-line parser.
|
||||
#
|
||||
csma = ns3.CsmaHelper()
|
||||
csma = ns.csma.CsmaHelper()
|
||||
devices = csma.Install(nodes)
|
||||
|
||||
#
|
||||
@@ -52,24 +57,24 @@ def main(argv):
|
||||
# only see traffic from one other device on that bridge. That is the case
|
||||
# for this configuration.
|
||||
#
|
||||
tapBridge = ns3.TapBridgeHelper()
|
||||
tapBridge.SetAttribute ("Mode", ns3.StringValue ("UseLocal"))
|
||||
tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-left"))
|
||||
tapBridge = ns.tap_bridge.TapBridgeHelper()
|
||||
tapBridge.SetAttribute ("Mode", ns.core.StringValue ("UseLocal"))
|
||||
tapBridge.SetAttribute ("DeviceName", ns.core.StringValue ("tap-left"))
|
||||
tapBridge.Install (nodes.Get (0), devices.Get (0))
|
||||
|
||||
#
|
||||
# Connect the right side tap to the right side wifi device on the right-side
|
||||
# ghost node.
|
||||
#
|
||||
tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-right"))
|
||||
tapBridge.SetAttribute ("DeviceName", ns.core.StringValue ("tap-right"))
|
||||
tapBridge.Install (nodes.Get (1), devices.Get (1))
|
||||
|
||||
#
|
||||
# Run the simulation for ten minutes to give the user time to play around
|
||||
#
|
||||
ns3.Simulator.Stop (ns3.Seconds (600))
|
||||
ns3.Simulator.Run(signal_check_frequency = -1)
|
||||
ns3.Simulator.Destroy()
|
||||
ns.core.Simulator.Stop (ns.core.Seconds (600))
|
||||
ns.core.Simulator.Run(signal_check_frequency = -1)
|
||||
ns.core.Simulator.Destroy()
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -17,7 +17,12 @@
|
||||
#
|
||||
|
||||
import sys
|
||||
import ns3
|
||||
import ns.core
|
||||
import ns.internet
|
||||
import ns.mobility
|
||||
import ns.network
|
||||
import ns.tap_bridge
|
||||
import ns.wifi
|
||||
|
||||
def main(argv):
|
||||
#
|
||||
@@ -25,35 +30,35 @@ def main(argv):
|
||||
# interact in real-time and therefore we have to use the real-time simulator
|
||||
# and take the time to calculate checksums.
|
||||
#
|
||||
ns3.GlobalValue.Bind("SimulatorImplementationType", ns3.StringValue("ns3::RealtimeSimulatorImpl"))
|
||||
ns3.GlobalValue.Bind("ChecksumEnabled", ns3.BooleanValue("true"))
|
||||
ns.core.GlobalValue.Bind("SimulatorImplementationType", ns.core.StringValue("ns3::RealtimeSimulatorImpl"))
|
||||
ns.core.GlobalValue.Bind("ChecksumEnabled", ns.core.BooleanValue("true"))
|
||||
|
||||
#
|
||||
# Create two ghost nodes. The first will represent the virtual machine host
|
||||
# on the left side of the network; and the second will represent the VM on
|
||||
# the right side.
|
||||
#
|
||||
nodes = ns3.NodeContainer()
|
||||
nodes = ns.network.NodeContainer()
|
||||
nodes.Create (2);
|
||||
|
||||
#
|
||||
# We're going to use 802.11 A so set up a wifi helper to reflect that.
|
||||
#
|
||||
wifi = ns3.WifiHelper.Default()
|
||||
wifi.SetStandard (ns3.WIFI_PHY_STANDARD_80211a);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", ns3.StringValue ("OfdmRate54Mbps"));
|
||||
wifi = ns.wifi.WifiHelper.Default()
|
||||
wifi.SetStandard (ns.wifi.WIFI_PHY_STANDARD_80211a);
|
||||
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", ns.core.StringValue ("OfdmRate54Mbps"));
|
||||
|
||||
#
|
||||
# No reason for pesky access points, so we'll use an ad-hoc network.
|
||||
#
|
||||
wifiMac = ns3.NqosWifiMacHelper.Default()
|
||||
wifiMac = ns.wifi.NqosWifiMacHelper.Default()
|
||||
wifiMac.SetType ("ns3::AdhocWifiMac");
|
||||
|
||||
#
|
||||
# Configure the physcial layer.
|
||||
#
|
||||
wifiChannel = ns3.YansWifiChannelHelper.Default()
|
||||
wifiPhy = ns3.YansWifiPhyHelper.Default()
|
||||
wifiChannel = ns.wifi.YansWifiChannelHelper.Default()
|
||||
wifiPhy = ns.wifi.YansWifiPhyHelper.Default()
|
||||
wifiPhy.SetChannel(wifiChannel.Create())
|
||||
|
||||
#
|
||||
@@ -65,10 +70,10 @@ def main(argv):
|
||||
# We need location information since we are talking about wifi, so add a
|
||||
# constant position to the ghost nodes.
|
||||
#
|
||||
mobility = ns3.MobilityHelper()
|
||||
positionAlloc = ns3.ListPositionAllocator()
|
||||
positionAlloc.Add(ns3.Vector(0.0, 0.0, 0.0))
|
||||
positionAlloc.Add(ns3.Vector(5.0, 0.0, 0.0))
|
||||
mobility = ns.mobility.MobilityHelper()
|
||||
positionAlloc = ns.mobility.ListPositionAllocator()
|
||||
positionAlloc.Add(ns.core.Vector(0.0, 0.0, 0.0))
|
||||
positionAlloc.Add(ns.core.Vector(5.0, 0.0, 0.0))
|
||||
mobility.SetPositionAllocator(positionAlloc)
|
||||
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel")
|
||||
mobility.Install(nodes)
|
||||
@@ -81,24 +86,24 @@ def main(argv):
|
||||
# only see traffic from one other device on that bridge. That is the case
|
||||
# for this configuration.
|
||||
#
|
||||
tapBridge = ns3.TapBridgeHelper()
|
||||
tapBridge.SetAttribute ("Mode", ns3.StringValue ("UseLocal"));
|
||||
tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-left"));
|
||||
tapBridge = ns.tap_bridge.TapBridgeHelper()
|
||||
tapBridge.SetAttribute ("Mode", ns.core.StringValue ("UseLocal"));
|
||||
tapBridge.SetAttribute ("DeviceName", ns.core.StringValue ("tap-left"));
|
||||
tapBridge.Install (nodes.Get (0), devices.Get (0));
|
||||
|
||||
#
|
||||
# Connect the right side tap to the right side wifi device on the right-side
|
||||
# ghost node.
|
||||
#
|
||||
tapBridge.SetAttribute ("DeviceName", ns3.StringValue ("tap-right"));
|
||||
tapBridge.SetAttribute ("DeviceName", ns.core.StringValue ("tap-right"));
|
||||
tapBridge.Install (nodes.Get (1), devices.Get (1));
|
||||
|
||||
#
|
||||
# Run the simulation for ten minutes to give the user time to play around
|
||||
#
|
||||
ns3.Simulator.Stop (ns3.Seconds (600));
|
||||
ns3.Simulator.Run(signal_check_frequency = -1)
|
||||
ns3.Simulator.Destroy()
|
||||
ns.core.Simulator.Stop (ns.core.Seconds (600));
|
||||
ns.core.Simulator.Run(signal_check_frequency = -1)
|
||||
ns.core.Simulator.Destroy()
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -156,6 +156,7 @@ class Node(PyVizObject):
|
||||
try:
|
||||
ns3_node = ns3.NodeList.GetNode(self.node_index)
|
||||
ipv4 = ns3_node.GetObject(ns3.Ipv4.GetTypeId())
|
||||
ipv6 = ns3_node.GetObject(ns3.Ipv6.GetTypeId())
|
||||
lines = ['<b><u>Node %i</u></b>' % self.node_index]
|
||||
lines.append('')
|
||||
|
||||
@@ -174,6 +175,7 @@ class Node(PyVizObject):
|
||||
lines.append(' <b>Name:</b> %s' % name)
|
||||
devname = dev.GetInstanceTypeId().GetName()
|
||||
lines.append(' <b>Type:</b> %s' % devname)
|
||||
|
||||
if ipv4 is not None:
|
||||
ipv4_idx = ipv4.GetInterfaceForDevice(dev)
|
||||
if ipv4_idx != -1:
|
||||
@@ -182,6 +184,15 @@ class Node(PyVizObject):
|
||||
ipv4.GetAddress(ipv4_idx, i).GetMask())
|
||||
for i in range(ipv4.GetNAddresses(ipv4_idx))]
|
||||
lines.append(' <b>IPv4 Addresses:</b> %s' % '; '.join(addresses))
|
||||
|
||||
if ipv6 is not None:
|
||||
ipv6_idx = ipv6.GetInterfaceForDevice(dev)
|
||||
if ipv6_idx != -1:
|
||||
addresses = [
|
||||
'%s/%s' % (ipv6.GetAddress(ipv6_idx, i).GetAddress(),
|
||||
ipv6.GetAddress(ipv6_idx, i).GetPrefix())
|
||||
for i in range(ipv6.GetNAddresses(ipv4_idx))]
|
||||
lines.append(' <b>IPv6 Addresses:</b> %s' % '; '.join(addresses))
|
||||
|
||||
lines.append(' <b>MAC Address:</b> %s' % (dev.GetAddress(),))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user