Add constructor for channls wih params for constellations

This commit is contained in:
Tim Schubert 2020-08-10 14:03:59 +02:00
parent 27ee6a3697
commit bb3bcb627c
7 changed files with 132 additions and 6 deletions

View file

@ -6,9 +6,13 @@
#include "ns3/enum.h"
#include "ns3/queue.h"
#include "ns3/names.h"
#include "ns3/assert.h"
#include "ns3/string.h"
#include "../model/leo-mock-channel.h"
#include "../model/leo-mock-net-device.h"
#include "../model/leo-starlink-constants.h"
#include "../model/leo-telesat-constants.h"
namespace ns3
{
@ -29,6 +33,61 @@ LeoChannelHelper::LeoChannelHelper ()
m_channelFactory.SetTypeId ("ns3::LeoMockChannel");
}
LeoChannelHelper::LeoChannelHelper (std::string constellation) :
LeoChannelHelper ()
{
SetConstellation (constellation);
}
void
LeoChannelHelper::SetConstellation (std::string constellation);
{
if (constellation == "Starlink")
{
SetConstellationAttributes (LEO_STARLINK_EIRP,
LEO_STARLINK_ELEVATION_ANGLE,
LEO_STARLINK_FSPL,
LEO_STARLINK_ATMOSPHERIC_LOSS,
LEO_STARLINK_LINK_MARGIN,
LEO_STARLINK_DATA_RATE);
}
else if (constellation == "Telesat")
{
SetConstellationAttributes (LEO_TELESAT_EIRP,
LEO_TELESAT_ELEVATION_ANGLE,
LEO_TELESAT_FSPL,
LEO_TELESAT_ATMOSPHERIC_LOSS,
LEO_TELESAT_LINK_MARGIN,
LEO_TELESAT_DATA_RATE);
}
else
{
NS_ASSERT_MSG (false, "Invalid constellation");
}
}
void
LeoChannelHelper::SetConstellationAttributes (double eirp,
double elevationAngle,
double fspl,
double atmosphericLoss,
double linkMargin,
double dataRate)
{
m_gndDeviceFactory.Set ("TxPower", DoubleValue (eirp));
m_satDeviceFactory.Set ("TxPower", DoubleValue (eirp));
m_gndDeviceFactory.Set ("DataRate", DoubleValue (dataRate));
m_satDeviceFactory.Set ("DataRate", DoubleValue (dataRate));
m_propagationLossFactory.SetTypeId ("ns3::LeoPropagationLossModel");
m_propagationLossFactory.Set ("ElevationAngle", DoubleValue (elevationAngle));
m_propagationLossFactory.Set ("FreeSpaceLoss", DoubleValue (fspl));
m_propagationLossFactory.Set ("AtmosphericLoss", DoubleValue (atmosphericLoss));
m_propagationLossFactory.Set ("LinkMargin", DoubleValue (linkMargin));
}
void
LeoChannelHelper::SetQueue(ObjectFactory &factory,
std::string type,
@ -233,6 +292,7 @@ LeoChannelHelper::Install (std::vector<Ptr<Node> > &satellites, std::vector<Ptr<
NS_LOG_FUNCTION (this);
Ptr<LeoMockChannel> channel = m_channelFactory.Create<LeoMockChannel> ();
channel->SetPropagationLoss (m_propagationLossFactory.Create ());
NetDeviceContainer container;

View file

@ -20,6 +20,7 @@ class LeoChannelHelper : public PcapHelperForDevice,
{
public:
LeoChannelHelper ();
LeoChannelHelper (std::string constellation);
virtual ~LeoChannelHelper ()
{};
@ -49,6 +50,8 @@ public:
Ptr<NetDevice> nd,
bool explicitFilename);
void SetConstellation (std::string constellation);
private:
ObjectFactory m_satQueueFactory;
ObjectFactory m_gndDeviceFactory;
@ -58,6 +61,8 @@ private:
ObjectFactory m_channelFactory;
ObjectFactory m_propagationLossFactory;
void SetQueue (ObjectFactory &factory,
std::string type,
std::string n1, const AttributeValue &v1,
@ -65,6 +70,13 @@ private:
std::string n3, const AttributeValue &v3,
std::string n4, const AttributeValue &v4);
void SetConstellationAttributes (double eirp,
double elevationAngle,
double fspl,
double atmosphericLoss,
double linkMargin,
double dataRate);
};
};

View file

@ -31,7 +31,7 @@ namespace ns3 {
#define LEO_STARLINK_PATH_DISTANCE 1684 // km
#define LEO_STARLINK_ELEVATION_ANGLE 40 // deg
#define LEO_STARLINK_FSPL 186.1 // dB
#define LEO_STARLINK_ATMOSPHERIC_LOSS 2.9 // dBm
#define LEO_STARLINK_ATMOSPHERIC_LOSS 2.9 // dB
#define LEO_STARLINK_RX_ANTENNA_GAIN 40.9 // dBi
#define LEO_STARLINK_SYSTEM_TEMP 535.9 // K
#define LEO_STARLINK_G_T 13.6 // dB/K

View file

@ -155,6 +155,12 @@ MockChannel::GetPropagationLoss () const
return m_propagationLoss;
}
void
MockChannel::SetPropagationLoss (PropagationLossModel model)
{
m_propagationLoss = model;
}
bool
MockChannel::Deliver (
Ptr<const Packet> p,
@ -168,13 +174,17 @@ MockChannel::Deliver (
Ptr<MobilityModel> srcMob = src->GetObject<MobilityModel> ();
Ptr<MobilityModel> dstMob = dst->GetObject<MobilityModel> ();
double txPower = src->GetTxPower ();
double rxPower = txPower;
if (srcMob != 0 && dstMob != 0)
{
Ptr<PropagationLossModel> pLoss = GetPropagationLoss ();
if (pLoss != 0)
{
// check if Rx power is below link margin
if (pLoss->CalcRxPower (src->GetTxPower (), srcMob, dstMob) == 0.0)
// check if signal reaches destination
rxPower = pLoss->CalcRxPower (txPower, srcMob, dstMob);
if (rxPower == 0.0)
{
return false;
}
@ -187,7 +197,8 @@ MockChannel::Deliver (
&MockNetDevice::Receive,
dst,
p->Copy (),
src);
src,
rxPower);
// Call the tx anim callback on the net device
m_txrxMock (p, src, dst, txTime, delay);

View file

@ -72,6 +72,9 @@ public:
std::size_t GetNDevices (void) const;
virtual bool TransmitStart (Ptr<const Packet> p, uint32_t devId, Address dst, Time txTime) = 0;
Ptr<PropagationLossModel> GetPropagationLoss () const;
void SetPropagationLoss (PropagationLossModel model);
protected:
TracedCallback<Ptr<const Packet>, // Packet being transmitted
Ptr<NetDevice>, // Transmitting NetDevice
@ -87,7 +90,6 @@ protected:
Time GetPropagationDelay (Ptr<MobilityModel> first, Ptr<MobilityModel> second, Time txTime) const;
Ptr<PropagationDelayModel> GetPropagationDelay () const;
Ptr<PropagationLossModel> GetPropagationLoss () const;
Ptr<MockNetDevice> GetDevice (Address &addr) const;
bool Deliver ( Ptr<const Packet> p, Ptr<MockNetDevice> src, Ptr<MockNetDevice> dst, Time txTime);

View file

@ -70,6 +70,11 @@ MockNetDevice::GetTypeId (void)
TimeValue (Seconds (0.0)),
MakeTimeAccessor (&MockNetDevice::m_tInterframeGap),
MakeTimeChecker ())
.AddAttribute ("RxThreshold",
"Receive threshold in dBm",
DoubleValue (0.0),
MakeDoubleAccessor (&MockNetDevice::m_rxThreshold),
MakeDoubleChecker<double> ())
.AddAttribute ("TxPower",
"Transmit power in dBm",
DoubleValue (1.0),
@ -410,7 +415,9 @@ MockNetDevice::SetReceiveErrorModel (Ptr<ErrorModel> em)
}
void
MockNetDevice::Receive (Ptr<Packet> packet, Ptr<MockNetDevice> senderDevice)
MockNetDevice::Receive (Ptr<Packet> packet,
Ptr<MockNetDevice> senderDevice,
double rxPower)
{
NS_LOG_FUNCTION (this << packet << senderDevice);
@ -421,6 +428,13 @@ MockNetDevice::Receive (Ptr<Packet> packet, Ptr<MockNetDevice> senderDevice)
m_phyRxEndTrace (packet);
if (rxPower < m_rxThreshold)
{
// Received power is below threshold
m_phyRxDropTrace (packet);
return;
}
if (m_receiveErrorModel && m_receiveErrorModel->IsCorrupt (packet) )
{
//
@ -783,4 +797,16 @@ MockNetDevice::SetTxPower (double txPower)
m_txPower = txPower;
}
double
MockNetDevice::GetRxTreshold () const
{
return m_rxThreshold;
}
void
MockNetDevice::SetRxThreshold (double rxThresh)
{
m_rxThreshold = rxThresh;
}
} // namespace ns3

View file

@ -101,6 +101,16 @@ public:
*/
void SetTxPower (double txPower);
/**
* Get the receive threshold in dBm
*/
double GetRxTreshold () const;
/**
* Set the receive threshold in dBm
*/
void SetRxThreshold (double rxThresh);
/**
* Attach a queue to the MockNetDevice.
*
@ -295,6 +305,11 @@ private:
*/
double m_txPower;
/**
* Minimum threshold for received power
*/
double m_rxThreshold;
/**
* The state of the Net Device transmit state machine.
*/