From 45228b292e5bef27d01fa409d524168389450ecc Mon Sep 17 00:00:00 2001 From: Tim Schubert Date: Mon, 22 Jun 2020 18:15:52 +0200 Subject: [PATCH] add mock channel for ground to space communication --- model/leo-mock-channel.cc | 61 ++++++++++++++++++++++++++++ model/leo-mock-channel.h | 85 +++++++++++++++++++++++++++++++++++++++ model/mock-channel.cc | 1 + model/mock-channel.h | 1 + 4 files changed, 148 insertions(+) create mode 100644 model/leo-mock-channel.cc create mode 100644 model/leo-mock-channel.h diff --git a/model/leo-mock-channel.cc b/model/leo-mock-channel.cc new file mode 100644 index 0000000..1edfd3d --- /dev/null +++ b/model/leo-mock-channel.cc @@ -0,0 +1,61 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ + +#include "ns3/object.h" +#include "ns3/ptr.h" +#include "ns3/log.h" +#include "ns3/enum.h" +#include "leo-mock-channel.h" + +namespace ns3 { + +NS_LOG_COMPONENT_DEFINE ("LeoMockChannel"); + +NS_OBJECT_ENSURE_REGISTERED (LeoMockChannel); + +TypeId +LeoMockChannel::GetTypeId (void) +{ + static TypeId tid = TypeId ("ns3::LeoMockChannel") + .SetParent () + .SetGroupName ("Leo") + .AddConstructor () + .AddAttribute ("ChannelType", + "The type of the channel", + EnumValue (), + MakeEnumAccessor (&LeoMockChannel::m_channelType), + MakeEnumChecker ( + ChannelType::GW_FORWARD, "ns3::LeoMockChannel::ChannelType::GW_FORWARD", + ChannelType::GW_RETURN, "ns3::LeoMockChannel::ChannelType::GW_RETURN", + ChannelType::UT_FORWARD, "ns3::LeoMockChannel::ChannelType::UT_FORWARD", + ChannelType::UT_RETURN, "ns3::LeoMockChannel::ChannelType::UT_RETURN")) + .AddTraceSource ("TxRxLeoMockChannel", + "Trace source indicating transmission of packet " + "from the LeoMockChannel, used by the Animation " + "interface.", + MakeTraceSourceAccessor (&LeoMockChannel::m_txrxMock), + "ns3::LeoMockChannel::TxRxAnimationCallback") + ; + return tid; +} + +// +// By default, you get a channel that +// has an "infitely" fast transmission speed and zero processing delay. +LeoMockChannel::LeoMockChannel() : MockChannel (), m_channelType (LeoMockChannel::ChannelType::UNKNOWN) +{ + NS_LOG_FUNCTION_NOARGS (); +} + +LeoMockChannel::~LeoMockChannel() +{ +} + +bool +TransmitStart (Ptr p, + uint32_t devId, + Address dst, Time txTime) +{ + return false; +} + +}; // namespace ns3 diff --git a/model/leo-mock-channel.h b/model/leo-mock-channel.h new file mode 100644 index 0000000..1dc8151 --- /dev/null +++ b/model/leo-mock-channel.h @@ -0,0 +1,85 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * 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 + */ + +#ifndef LEO_MOCK_CHANNEL_H_ +#define LEO_MOCK_CHANNEL_H_ + +#include +#include + +#include "ns3/object.h" +#include "ns3/ptr.h" +#include "ns3/channel.h" +#include "ns3/mobility-model.h" +#include "ns3/net-device.h" +#include "ns3/time-data-calculators.h" +#include "ns3/traced-callback.h" +#include "ns3/mobility-module.h" +#include "ns3/propagation-delay-model.h" +#include "ns3/propagation-loss-model.h" +#include "mock-net-device.h" +#include "mock-channel.h" + +namespace ns3 { + +/** + * \ingroup network + * \defgroup channel Channel + */ +/** + * \ingroup channel + * \brief Mocked satellite-gateway, satellite-terminal channel types + * + */ +class LeoMockChannel : public MockChannel +{ +public: + static TypeId GetTypeId (void); + + LeoMockChannel (); + virtual ~LeoMockChannel (); + + /** + * \see MockChannel::TransmitStart + * + * A packet is transmitted if the destination is reachable via the beam. + */ + virtual bool TransmitStart (Ptr p, uint32_t devId, Address dst, Time txTime); + +protected: + + enum ChannelType + { + GW_FORWARD, + GW_RETURN, + UT_FORWARD, + UT_RETURN, + UNKNOWN + }; + + ChannelType GetChannelType () const; + +private: + /** + * \brief Type of the channel + */ + ChannelType m_channelType; + +}; // class MockChannel + +} // namespace ns3 + +#endif /* LEO_MOCK_CHANNEL_H */ diff --git a/model/mock-channel.cc b/model/mock-channel.cc index 5cdd439..f26f0d4 100644 --- a/model/mock-channel.cc +++ b/model/mock-channel.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include "mock-channel.h" namespace ns3 { diff --git a/model/mock-channel.h b/model/mock-channel.h index b3b3820..10c7eb6 100644 --- a/model/mock-channel.h +++ b/model/mock-channel.h @@ -101,6 +101,7 @@ private: * \brief Propagation loss model to be used with this channel */ Ptr m_propagationLoss; + }; // class MockChannel } // namespace ns3