From 20ad318cb985db317f29dfe4e7398146626935a6 Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Wed, 24 Jun 2020 22:23:09 +0200 Subject: [PATCH] add transmit start for leo mock channels --- model/isl-mock-channel.cc | 31 ------------------- model/isl-mock-channel.h | 3 +- model/leo-mock-channel.cc | 60 +++++------------------------------- model/leo-mock-channel.h | 7 ++++- model/leo-mock-net-device.cc | 6 ++-- model/leo-mock-net-device.h | 6 ++-- model/mock-channel.cc | 33 ++++++++++++++++++++ model/mock-channel.h | 3 ++ 8 files changed, 55 insertions(+), 94 deletions(-) diff --git a/model/isl-mock-channel.cc b/model/isl-mock-channel.cc index a4e7cc1..caeb78c 100644 --- a/model/isl-mock-channel.cc +++ b/model/isl-mock-channel.cc @@ -52,37 +52,6 @@ IslMockChannel::~IslMockChannel() { } -bool IslMockChannel::Deliver ( - Ptr p, - Ptr src, - Ptr dst, - Time txTime) -{ - NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime); - Time delay = GetDelay (src, dst, txTime); - - /* Check if there is LOS between the source and destination */ - if (GetPropagationLoss ()->CalcRxPower(1, src->GetMobilityModel(), dst->GetMobilityModel()) > 0) - { - Simulator::ScheduleWithContext (dst->GetNode ()->GetId (), - delay, - &MockNetDevice::Receive, - dst, - p->Copy (), - src); - - // Call the tx anim callback on the net device - m_txrxMock (p, src, dst, txTime, delay); - return true; - } - else - { - NS_LOG_LOGIC (dst << " unreachable from " << src); - - return false; - } -} - bool IslMockChannel::TransmitStart ( Ptr p, diff --git a/model/isl-mock-channel.h b/model/isl-mock-channel.h index 05bda45..1d751d0 100644 --- a/model/isl-mock-channel.h +++ b/model/isl-mock-channel.h @@ -59,8 +59,9 @@ public: bool TransmitStart (Ptr p, uint32_t devId, Address dst, Time txTime); private: + std::vector > m_link; + - bool Deliver (Ptr p, Ptr src, Ptr dst, Time txTime); }; // class MockChannel } // namespace ns3 diff --git a/model/leo-mock-channel.cc b/model/leo-mock-channel.cc index 51dfb83..a187ad2 100644 --- a/model/leo-mock-channel.cc +++ b/model/leo-mock-channel.cc @@ -21,13 +21,6 @@ LeoMockChannel::GetTypeId (void) .SetParent () .SetGroupName ("Leo") .AddConstructor () - .AddAttribute ("ChannelType", - "The type of the channel", - EnumValue (), - MakeEnumAccessor (&LeoMockChannel::m_channelType), - MakeEnumChecker ( - ChannelType::GW, "ns3::LeoMockChannel::ChannelType::GW", - ChannelType::UT, "ns3::LeoMockChannel::ChannelType::UT")) ; return tid; } @@ -51,63 +44,24 @@ LeoMockChannel::TransmitStart (Ptr p, { // Find devices joined to channel Ptr srcDev = DynamicCast (GetDevice (devId)); - - if (srcDev == nullptr) - { - NS_LOG_ERROR ("Dropping packet: invalid source device"); - return false; - } - Ptr dstDev = DynamicCast (GetDevice (dst)); + bool isBroadcast = (srcDev->GetBroadcast () == dst); - if (dstDev == nullptr && !isBroadcast) + if (!isBroadcast && dstDev == nullptr) { - NS_LOG_ERROR ("Dropping packet: invalid destination device"); + NS_LOG_LOGIC (this << "Dropping packet: direct communication between ground stations and satellites not allowed using this channel"); return false; } - LeoMockNetDevice::DeviceType srcType = srcDev->GetDeviceType (); - - switch (m_channelType) + for (uint32_t i = 0; i < GetNDevices (); i++) { - case LeoMockChannel::ChannelType::GW: - if (srcType == LeoMockNetDevice::GW) + if (srcDev->GetDeviceType () != dstDev->GetDeviceType ()) { - // Get device from SAT_GW set - return true; + Deliver (p, srcDev, dstDev, txTime); } - else if (srcType == LeoMockNetDevice::SAT_GW) - { - // Get device from GW set - return true; - } - break; - case LeoMockChannel::ChannelType::UT: - if (srcType == LeoMockNetDevice::UT) - { - // Get device from SAT_UT set - return true; - } - else if (srcType == LeoMockNetDevice::SAT_UT) - { - // Get device from UT set - return true; - } - break; - // Other kinds of transmissions are not allowed - default: - NS_LOG_ERROR ("Dropping packet: invalid channel type"); - return false; } - // Apply propagation loss and schedule transmission - - - // Get propagation delay - Time delay = GetDelay (srcDev, dstDev, txTime); - - // Make compiler happy - return false; + return true; } }; // namespace ns3 diff --git a/model/leo-mock-channel.h b/model/leo-mock-channel.h index 1d036cc..173695e 100644 --- a/model/leo-mock-channel.h +++ b/model/leo-mock-channel.h @@ -44,6 +44,8 @@ namespace ns3 { * \brief Mocked satellite-gateway, satellite-terminal channel types * */ + // TODO make separate clases for ut and gw links + // TODO make separate clases for ut and gw devices class LeoMockChannel : public MockChannel { public: @@ -60,7 +62,6 @@ public: virtual bool TransmitStart (Ptr p, uint32_t devId, Address dst, Time txTime); protected: - enum ChannelType { GW, @@ -78,6 +79,10 @@ private: bool IsChannel (Ptr dstType, Ptr srcType, bool isBroadcast); + typedef std::map > DeviceIndex; + DeviceIndex m_gndDevs; + DeviceIndex m_satDevs; + }; // class MockChannel } // namespace ns3 diff --git a/model/leo-mock-net-device.cc b/model/leo-mock-net-device.cc index ad1379b..b0ddf05 100644 --- a/model/leo-mock-net-device.cc +++ b/model/leo-mock-net-device.cc @@ -23,10 +23,8 @@ LeoMockNetDevice::GetTypeId (void) EnumValue (), MakeEnumAccessor (&LeoMockNetDevice::m_deviceType), MakeEnumChecker ( - DeviceType::GW, "ns3::LeoMockNetDevice::NetDeviceType::GW_FORWARD", - DeviceType::UT, "ns3::LeoMockNetDevice::NetDeviceType::GW_RETURN", - DeviceType::SAT_GW, "ns3::LeoMockNetDevice::NetDeviceType::UT_FORWARD", - DeviceType::SAT_UT, "ns3::LeoMockNetDevice::NetDeviceType::UT_RETURN")) + DeviceType::GND, "ns3::LeoMockNetDevice::NetDeviceType::GND", + DeviceType::SAT, "ns3::LeoMockNetDevice::NetDeviceType::SAT")) ; return tid; }; diff --git a/model/leo-mock-net-device.h b/model/leo-mock-net-device.h index 0182b0d..db6281f 100644 --- a/model/leo-mock-net-device.h +++ b/model/leo-mock-net-device.h @@ -15,10 +15,8 @@ class LeoMockNetDevice : public MockNetDevice public: enum DeviceType { - GW, - UT, - SAT_UT, - SAT_GW + GND, + SAT }; static TypeId GetTypeId (void); diff --git a/model/mock-channel.cc b/model/mock-channel.cc index f26f0d4..22fe639 100644 --- a/model/mock-channel.cc +++ b/model/mock-channel.cc @@ -152,4 +152,37 @@ MockChannel::GetPropagationLoss () const return m_propagationLoss; } +bool +MockChannel::Deliver ( + Ptr p, + Ptr src, + Ptr dst, + Time txTime) +{ + NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime); + Time delay = GetDelay (src, dst, txTime); + + /* Check if there is LOS between the source and destination */ + if (GetPropagationLoss ()->CalcRxPower(1, src->GetMobilityModel(), dst->GetMobilityModel()) > 0) + { + Simulator::ScheduleWithContext (dst->GetNode ()->GetId (), + delay, + &MockNetDevice::Receive, + dst, + p->Copy (), + src); + + // Call the tx anim callback on the net device + m_txrxMock (p, src, dst, txTime, delay); + return true; + } + else + { + NS_LOG_LOGIC (dst << " unreachable from " << src); + + return false; + } +} + + } // namespace ns3 diff --git a/model/mock-channel.h b/model/mock-channel.h index 10c7eb6..9163197 100644 --- a/model/mock-channel.h +++ b/model/mock-channel.h @@ -89,6 +89,9 @@ protected: Ptr GetPropagationDelay () const; Ptr GetPropagationLoss () const; Ptr GetDevice (Address &addr) const; + + bool Deliver ( Ptr p, Ptr src, Ptr dst, Time txTime); + private: std::vector > m_link;