38 #include <ns3/channel.h>
39 #include <ns3/error-model.h>
40 #include <ns3/ipv4-header.h>
41 #include <ns3/ipv4-l3-protocol.h>
44 #include <ns3/object-map.h>
45 #include <ns3/packet.h>
46 #include <ns3/pointer.h>
47 #include <ns3/singleton.h>
48 #include <ns3/trace-source-accessor.h>
49 #include <ns3/uinteger.h>
57 NS_LOG_COMPONENT_DEFINE(
"SatOrbiterNetDevice");
62 NS_OBJECT_ENSURE_REGISTERED(SatOrbiterNetDevice);
68 TypeId(
"ns3::SatOrbiterNetDevice")
69 .SetParent<NetDevice>()
70 .AddAttribute(
"ReceiveErrorModel",
71 "The receiver error model used to simulate packet loss",
74 MakePointerChecker<ErrorModel>())
75 .AddAttribute(
"UserPhy",
76 "The User Phy objects attached to this device.",
79 MakeObjectMapChecker<SatPhy>())
80 .AddAttribute(
"FeederPhy",
81 "The Feeder Phy objects attached to this device.",
84 MakeObjectMapChecker<SatPhy>())
85 .AddAttribute(
"UserMac",
86 "The User MAC objects attached to this device.",
89 MakeObjectMapChecker<SatMac>())
90 .AddAttribute(
"FeederMac",
91 "The Feeder MAC objects attached to this device.",
94 MakeObjectMapChecker<SatMac>())
95 .AddAttribute(
"EnableStatisticsTags",
96 "If true, some tags will be added to each transmitted packet to assist "
97 "with statistics computation",
100 MakeBooleanChecker())
101 .AddTraceSource(
"PacketTrace",
102 "Packet event trace",
104 "ns3::SatTypedefs::PacketTraceCallback")
105 .AddTraceSource(
"Tx",
106 "A packet to be sent",
108 "ns3::Packet::TracedCallback")
109 .AddTraceSource(
"SignallingTx",
110 "A signalling packet to be sent",
112 "ns3::SatTypedefs::PacketDestinationAddressCallback")
113 .AddTraceSource(
"RxFeeder",
114 "A packet received on feeder",
116 "ns3::SatTypedefs::PacketSourceAddressCallback")
117 .AddTraceSource(
"RxUser",
118 "A packet received on user",
120 "ns3::SatTypedefs::PacketSourceAddressCallback")
121 .AddTraceSource(
"RxFeederLinkDelay",
122 "A packet is received with feeder link delay information",
124 "ns3::SatTypedefs::PacketDelayAddressCallback")
126 "RxFeederLinkJitter",
127 "A packet is received with feeder link jitter information",
129 "ns3::SatTypedefs::PacketJitterAddressCallback")
130 .AddTraceSource(
"RxUserLinkDelay",
131 "A packet is received with feeder link delay information",
133 "ns3::SatTypedefs::PacketDelayAddressCallback")
134 .AddTraceSource(
"RxUserLinkJitter",
135 "A packet is received with feeder link jitter information",
137 "ns3::SatTypedefs::PacketJitterAddressCallback");
146 NS_LOG_FUNCTION(
this);
151 Ptr<SatSignalParameters> rxParams)
153 NS_LOG_FUNCTION(
this << rxParams->m_packetsInBurst.size() << rxParams);
154 NS_LOG_INFO(
"Receiving a packet at the satellite from user link");
160 DynamicCast<SatOrbiterFeederPhy>(
m_feederPhy[rxParams->m_beamId])
161 ->SendPduWithParams(rxParams);
165 for (SatPhy::PacketContainer_t::const_iterator it = rxParams->m_packetsInBurst.begin();
166 it != rxParams->m_packetsInBurst.end();
169 DynamicCast<SatOrbiterFeederMac>(
m_feederMac[rxParams->m_beamId])->EnquePacket(*it);
176 "SatOrbiterNetDevice::ReceiveUser should not be used in case of network regeneration");
179 NS_FATAL_ERROR(
"Not implemented yet");
186 Ptr<SatSignalParameters> rxParams)
188 NS_LOG_FUNCTION(
this << rxParams->m_packetsInBurst.size() << rxParams);
189 NS_LOG_INFO(
"Receiving a packet at the satellite from feeder link");
195 DynamicCast<SatOrbiterUserPhy>(
m_userPhy[rxParams->m_beamId])->SendPduWithParams(rxParams);
199 NS_FATAL_ERROR(
"SatOrbiterNetDevice::ReceiveFeeder should not be used in case of network "
203 NS_FATAL_ERROR(
"Not implemented yet");
211 NS_LOG_FUNCTION(
this << em);
238 NS_LOG_FUNCTION(
this << index);
245 NS_LOG_FUNCTION(
this);
252 NS_LOG_FUNCTION(
this << address);
253 m_address = Mac48Address::ConvertFrom(address);
262 NS_LOG_FUNCTION(
this);
269 NS_LOG_FUNCTION(
this << mtu);
277 NS_LOG_FUNCTION(
this);
284 NS_LOG_FUNCTION(
this);
291 NS_LOG_FUNCTION(
this << &callback);
297 NS_LOG_FUNCTION(
this);
304 NS_LOG_FUNCTION(
this);
305 return Mac48Address(
"ff:ff:ff:ff:ff:ff");
311 NS_LOG_FUNCTION(
this);
318 NS_LOG_FUNCTION(
this << multicastGroup);
319 return Mac48Address::GetMulticast(multicastGroup);
325 NS_LOG_FUNCTION(
this << addr);
326 return Mac48Address::GetMulticast(addr);
332 NS_LOG_FUNCTION(
this);
339 NS_LOG_FUNCTION(
this);
346 NS_LOG_FUNCTION(
this << packet << dest << protocolNumber);
358 const Address& source,
360 uint16_t protocolNumber)
362 NS_LOG_FUNCTION(
this << packet << source << dest << protocolNumber);
375 NS_LOG_FUNCTION(
this);
382 NS_LOG_FUNCTION(
this << node);
389 NS_LOG_FUNCTION(
this);
396 NS_LOG_FUNCTION(
this << &cb);
402 NS_LOG_FUNCTION(
this);
411 NetDevice::DoDispose();
417 NS_LOG_FUNCTION(
this << &cb);
424 NS_LOG_FUNCTION(
this);
431 NS_LOG_FUNCTION(
this);
438 NS_LOG_FUNCTION(
this << phy << beamId);
439 m_userPhy.insert(std::pair<uint32_t, Ptr<SatPhy>>(beamId, phy));
445 NS_LOG_FUNCTION(
this << phy << beamId);
446 m_feederPhy.insert(std::pair<uint32_t, Ptr<SatPhy>>(beamId, phy));
456 NS_FATAL_ERROR(
"User Phy does not exist for beam " << beamId);
466 NS_FATAL_ERROR(
"User Phy does not exist for beam " << beamId);
469 std::map<uint32_t, Ptr<SatPhy>>
475 std::map<uint32_t, Ptr<SatPhy>>
484 NS_LOG_FUNCTION(
this << mac << beamId);
485 m_userMac.insert(std::pair<uint32_t, Ptr<SatMac>>(beamId, mac));
491 NS_LOG_FUNCTION(
this << mac << macUsed << beamId);
492 m_feederMac.insert(std::pair<uint32_t, Ptr<SatMac>>(beamId, macUsed));
493 m_allFeederMac.insert(std::pair<uint32_t, Ptr<SatMac>>(beamId, mac));
503 NS_FATAL_ERROR(
"User MAC does not exist for beam " << beamId);
513 NS_FATAL_ERROR(
"User MAC does not exist for beam " << beamId);
516 std::map<uint32_t, Ptr<SatMac>>
522 std::map<uint32_t, Ptr<SatMac>>
528 std::map<uint32_t, Ptr<SatMac>>
537 NS_LOG_FUNCTION(
this << beamId << satelliteFeederAddress);
539 m_addressMapFeeder.insert(std::pair<uint32_t, Mac48Address>(beamId, satelliteFeederAddress));
545 NS_LOG_FUNCTION(
this << beamId << satelliteUserAddress);
547 m_addressMapUser.insert(std::pair<uint32_t, Mac48Address>(beamId, satelliteUserAddress));
553 NS_LOG_FUNCTION(
this << beamId);
559 NS_FATAL_ERROR(
"Satellite MAC does not exist for beam " << beamId);
565 NS_LOG_FUNCTION(
this << beamId);
571 NS_FATAL_ERROR(
"Satellite MAC does not exist for beam " << beamId);
577 NS_LOG_FUNCTION(
this << packet);
582 if (packet->PeekPacketTag(addressE2ETag))
584 NS_LOG_DEBUG(
this <<
" contains a SatE2E tag");
601 NS_LOG_FUNCTION(
this << gwAddress << beamId);
604 "Cannot add same GW twice to map");
607 Singleton<SatIdMapper>::Get()->AttachMacToSatIdIsl(gwAddress,
m_nodeId);
611 Ptr<SatOrbiterFeederMac> orbiterFeederMac =
613 NS_ASSERT(orbiterFeederMac !=
nullptr);
615 orbiterFeederMac->AddPeer(gwAddress);
623 NS_LOG_FUNCTION(
this << gwAddress << beamId);
628 Singleton<SatIdMapper>::Get()->RemoveMacToSatIdIsl(gwAddress);
632 Ptr<SatOrbiterFeederMac> orbiterFeederMac =
634 NS_ASSERT(orbiterFeederMac !=
nullptr);
636 orbiterFeederMac->RemovePeer(gwAddress);
641 std::set<Mac48Address>
644 NS_LOG_FUNCTION(
this);
646 std::set<Mac48Address> gws;
647 std::map<Mac48Address, uint32_t>::iterator it;
650 gws.insert(it->first);
656 std::set<Mac48Address>
659 NS_LOG_FUNCTION(
this);
661 std::set<Mac48Address> uts;
662 std::map<Mac48Address, uint32_t>::iterator it;
665 uts.insert(it->first);
674 NS_LOG_FUNCTION(
this);
679 std::vector<Ptr<PointToPointIslNetDevice>>
682 NS_LOG_FUNCTION(
this);
690 NS_LOG_FUNCTION(
this << arbiter);
698 NS_LOG_FUNCTION(
this);
706 NS_LOG_FUNCTION(
this << packet << destination);
709 NS_ASSERT_MSG(
m_arbiter !=
nullptr,
"Arbiter not set");
711 if (destination.IsBroadcast())
721 int32_t islInterfaceIndex =
m_arbiter->BaseDecide(packet, destination);
723 if (islInterfaceIndex < 0)
725 NS_LOG_INFO(
"Cannot route packet form node " <<
m_nodeId <<
" to " << destination);
729 NS_FATAL_ERROR(
"Incorrect interface index from arbiter: "
This class implements a tag that carries the satellite MAC of GW and UT.
Mac48Address GetE2ESourceAddress(void) const
Get E2E source MAC address.
Mac48Address GetE2EDestAddress(void) const
Get E2E destination MAC address.
SatLinkDir_t
Link direction used for packet tracing.
RegenerationMode_t
The regeneration mode used in satellites.
Ptr< SatIslArbiter > m_arbiter
Arbiter used to route on ISLs.
virtual bool IsLinkUp(void) const
void ReceiveFeeder(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive the packet from the lower layers.
std::map< uint32_t, Mac48Address > m_addressMapFeeder
std::map< uint32_t, Mac48Address > m_addressMapUser
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SatOrbiterNetDevice.
virtual bool IsPointToPoint(void) const
std::set< Mac48Address > GetGwConnected()
The the list of MAC GW connected to this satellite.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
void ConnectGw(Mac48Address gwAddress, uint32_t beamId)
Connect a GW to this satellite.
void DisconnectGw(Mac48Address gwAddress, uint32_t beamId)
Disconnect a GW to this satellite.
std::map< Mac48Address, uint32_t > m_gwConnected
Set containing all connected GWs.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
virtual uint32_t GetIfIndex(void) const
std::vector< Ptr< PointToPointIslNetDevice > > GetIslsNetDevices()
Get all the ISL Net devices.
std::map< uint32_t, Ptr< SatMac > > GetFeederMac()
Get all Feeder MAC objects attached to this satellite that are in use.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced callback for all packets received to be transmitted.
virtual void AddLinkChangeCallback(Callback< void > callback)
void SetNodeId(uint32_t nodeId)
void AddUserPair(uint32_t beamId, Mac48Address satelliteUserAddress)
Add an entry in the database to get satellite user address from beam ID.
Mac48Address GetSatelliteUserAddress(uint32_t beamId)
Get satellite user entry from associated beam ID.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
std::set< Mac48Address > GetUtConnected()
The the list of UT MAC connected to this satellite.
void SetArbiter(Ptr< SatIslArbiter > arbiter)
Set the arbiter for ISL routing.
Address GetRxUtAddress(Ptr< Packet > packet, SatEnums::SatLinkDir_t ld)
Get UT MAC address associated to this packet.
std::map< uint32_t, Ptr< SatPhy > > GetUserPhy()
Get all User Phy objects attached to this satellite.
std::vector< Ptr< PointToPointIslNetDevice > > m_islNetDevices
List of ISLs starting from this node.
void ReceiveUser(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive the packet from the lower layers.
virtual Ptr< Node > GetNode(void) const
void SetForwardLinkRegenerationMode(SatEnums::RegenerationMode_t forwardLinkRegenerationMode)
Set the forward link regeneration mode.
TracedCallback< const Time &, const Address & > m_rxUserLinkJitterTrace
Traced callback for all received packets, including user link jitter information and the address of t...
TracedCallback< Ptr< const Packet >, const Address & > m_rxUserTrace
Traced callback for all received packets on user, including the address of the senders.
TracedCallback< Ptr< const Packet >, const Address & > m_signallingTxTrace
Traced callback for all signalling (control message) packets sent, including the destination address.
TracedCallback< Ptr< const Packet >, const Address & > m_rxFeederTrace
Traced callback for all received packets on feeder, including the address of the senders.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
TracedCallback< const Time &, const Address & > m_rxFeederLinkDelayTrace
Traced callback for all received packets, including feeder link delay information and the address of ...
std::map< uint32_t, Ptr< SatMac > > m_feederMac
virtual Address GetAddress(void) const
virtual void SetAddress(Address address)
virtual bool NeedsArp(void) const
void AddFeederPair(uint32_t beamId, Mac48Address satelliteFeederAddress)
Add an entry in the database to get satellite feeder address from beam ID.
std::map< uint32_t, Ptr< SatMac > > m_userMac
SatOrbiterNetDevice()
Default constructor.
virtual bool SupportsSendFrom(void) const
std::map< uint32_t, Ptr< SatPhy > > m_userPhy
void AddUserMac(Ptr< SatMac > mac, uint32_t beamId)
Add the User MAC object for the beam.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
void AddFeederPhy(Ptr< SatPhy > phy, uint32_t beamId)
Add the Feeder Phy object for the beam.
void SetReturnLinkRegenerationMode(SatEnums::RegenerationMode_t returnLinkRegenerationMode)
Set the return link regeneration mode.
void AddFeederMac(Ptr< SatMac > mac, Ptr< SatMac > macUsed, uint32_t beamId)
Add the Feeder MAC object for the beam.
Ptr< SatIslArbiter > GetArbiter()
Get the arbiter for ISL routing.
std::map< uint32_t, Ptr< SatPhy > > GetFeederPhy()
Get all Feeder Phy objects attached to this satellite.
std::map< uint32_t, Ptr< SatMac > > GetUserMac()
Get all User MAC objects attached to this satellite.
void SendToIsl(Ptr< Packet > packet, Mac48Address destination)
Send a packet to ISL.
NetDevice::PromiscReceiveCallback m_promiscCallback
Ptr< ErrorModel > m_receiveErrorModel
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
virtual bool IsBridge(void) const
virtual bool SetMtu(const uint16_t mtu)
std::map< uint32_t, Ptr< SatMac > > GetAllFeederMac()
Get all Feeder MAC objects attached to this satellite.
std::map< uint32_t, Ptr< SatMac > > m_allFeederMac
TracedCallback< const Time &, const Address & > m_rxUserLinkDelayTrace
Traced callback for all received packets, including user link delay information and the address of th...
void AddUserPhy(Ptr< SatPhy > phy, uint32_t beamId)
Add the User Phy object for the beam.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
TracedCallback< const Time &, const Address & > m_rxFeederLinkJitterTrace
Traced callback for all received packets, including feeder link jitter information and the address of...
virtual bool IsMulticast(void) const
virtual Ptr< Channel > GetChannel(void) const
virtual bool IsBroadcast(void) const
static TypeId GetTypeId(void)
Get the type ID.
Mac48Address GetSatelliteFeederAddress(uint32_t beamId)
Get satellite feeder entry from associated beam ID.
virtual Address GetBroadcast(void) const
virtual void SetIfIndex(const uint32_t index)
std::map< uint32_t, Ptr< SatPhy > > m_feederPhy
bool m_isStatisticsTagsEnabled
void AddIslsNetDevice(Ptr< PointToPointIslNetDevice > islNetDevices)
Add a ISL Net Device to this satellite.
virtual uint16_t GetMtu(void) const
std::map< Mac48Address, uint32_t > m_utConnected
Set containing all connected UTs.
virtual void DoDispose(void)
Dispose of this class instance.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void SetNode(Ptr< Node > node)
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.