33 #include <ns3/boolean.h>
34 #include <ns3/channel.h>
35 #include <ns3/error-model.h>
36 #include <ns3/ipv4-l3-protocol.h>
39 #include <ns3/packet.h>
40 #include <ns3/pointer.h>
41 #include <ns3/trace-source-accessor.h>
43 NS_LOG_COMPONENT_DEFINE(
"SatNetDevice");
48 NS_OBJECT_ENSURE_REGISTERED(SatNetDevice);
54 TypeId(
"ns3::SatNetDevice")
55 .SetParent<NetDevice>()
56 .AddConstructor<SatNetDevice>()
57 .AddAttribute(
"ReceiveErrorModel",
58 "The receiver error model used to simulate packet loss",
61 MakePointerChecker<ErrorModel>())
62 .AddAttribute(
"SatMac",
63 "The Satellite MAC layer attached to this device.",
66 MakePointerChecker<SatMac>())
67 .AddAttribute(
"SatPhy",
68 "The Satellite Phy layer attached to this device.",
71 MakePointerChecker<SatPhy>())
72 .AddAttribute(
"SatLlc",
73 "The Satellite Llc layer attached to this device.",
76 MakePointerChecker<SatLlc>())
77 .AddAttribute(
"MaximumTransmissionUnit",
78 "Maximum transmission unit in Bytes",
79 UintegerValue(0xffff),
81 MakeUintegerChecker<uint16_t>())
82 .AddAttribute(
"EnableStatisticsTags",
83 "If true, some tags will be added to each transmitted packet to assist "
84 "with statistics computation",
88 .AddTraceSource(
"PacketTrace",
91 "ns3::SatTypedefs::PacketTraceCallback")
93 "A packet to be sent",
95 "ns3::Packet::TracedCallback")
96 .AddTraceSource(
"SignallingTx",
97 "A signalling packet to be sent",
99 "ns3::SatTypedefs::PacketDestinationAddressCallback")
100 .AddTraceSource(
"Rx",
103 "ns3::SatTypedefs::PacketSourceAddressCallback")
104 .AddTraceSource(
"RxDelay",
105 "A packet is received with delay information",
107 "ns3::SatTypedefs::PacketDelayAddressCallback")
108 .AddTraceSource(
"RxJitter",
109 "A packet is received with jitter information",
111 "ns3::SatTypedefs::PacketJitterAddressCallback")
112 .AddTraceSource(
"RxLinkDelay",
113 "A packet is received with link delay information",
115 "ns3::SatTypedefs::PacketDelayAddressCallback")
116 .AddTraceSource(
"RxLinkJitter",
117 "A packet is received with link jitter information",
119 "ns3::SatTypedefs::PacketJitterAddressCallback");
127 m_isStatisticsTagsEnabled(false),
134 NS_LOG_FUNCTION(
this);
140 NS_LOG_FUNCTION(
this << packet);
141 NS_LOG_INFO(
"Receiving a packet: " << packet->GetUid());
163 bool isTaggedWithAddress =
false;
164 ByteTagIterator it = packet->GetByteTagIterator();
166 while (!isTaggedWithAddress && it.HasNext())
168 ByteTagIterator::Item item = it.Next();
172 NS_LOG_DEBUG(
this <<
" contains a SatAddressTag tag:"
173 <<
" start=" << item.GetStart() <<
" end=" << item.GetEnd());
175 item.GetTag(addrTag);
177 isTaggedWithAddress =
true;
184 if (packet->PeekPacketTag(timeTag))
186 NS_LOG_DEBUG(
this <<
" contains a SatDevTimeTag tag");
198 if (packet->PeekPacketTag(linkTimeTag))
200 NS_LOG_DEBUG(
this <<
" contains a SatDevLinkTimeTag tag");
213 m_rxCallback(
this, packet, Ipv4L3Protocol::PROT_NUMBER, Address());
219 NS_LOG_FUNCTION(
this << phy);
226 NS_LOG_FUNCTION(
this << mac);
233 NS_LOG_FUNCTION(
this << llc);
240 NS_LOG_FUNCTION(
this << nodeInfo);
247 NS_LOG_FUNCTION(
this << enabled);
262 NS_LOG_FUNCTION(
this << em);
269 NS_LOG_FUNCTION(
this << index);
276 NS_LOG_FUNCTION(
this);
283 NS_LOG_FUNCTION(
this);
290 NS_LOG_FUNCTION(
this);
297 NS_LOG_FUNCTION(
this);
304 NS_LOG_FUNCTION(
this);
308 Ptr<SatPacketClassifier>
311 NS_LOG_FUNCTION(
this);
318 NS_LOG_FUNCTION(
this << address);
319 m_address = Mac48Address::ConvertFrom(address);
328 NS_LOG_FUNCTION(
this);
335 NS_LOG_FUNCTION(
this << mtu);
343 NS_LOG_FUNCTION(
this);
350 NS_LOG_FUNCTION(
this);
357 NS_LOG_FUNCTION(
this << &callback);
363 NS_LOG_FUNCTION(
this);
370 NS_LOG_FUNCTION(
this);
371 return Mac48Address(
"ff:ff:ff:ff:ff:ff");
377 NS_LOG_FUNCTION(
this);
384 NS_LOG_FUNCTION(
this << multicastGroup);
385 return Mac48Address::GetMulticast(multicastGroup);
391 NS_LOG_FUNCTION(
this << addr);
392 return Mac48Address::GetMulticast(addr);
398 NS_LOG_FUNCTION(
this);
405 NS_LOG_FUNCTION(
this);
412 NS_LOG_FUNCTION(
this << packet << dest << protocolNumber);
441 uint8_t flowId =
m_classifier->Classify(packet, dest, protocolNumber);
442 m_llc->Enque(packet, dest, flowId);
449 const Address& source,
451 uint16_t protocolNumber)
453 NS_LOG_FUNCTION(
this << packet << source << dest << protocolNumber);
482 uint8_t flowId =
m_classifier->Classify(packet, dest, protocolNumber);
483 m_llc->Enque(packet, dest, flowId);
491 NS_LOG_FUNCTION(
this << msg << dest);
493 Ptr<Packet> packet = Create<Packet>(msg->GetSizeInBytes());
522 uint32_t
id =
m_mac->ReserveIdAndStoreCtrlMsgToContainer(msg);
525 packet->AddPacketTag(tag);
527 uint8_t flowId =
m_classifier->Classify(msg->GetMsgType(), dest);
531 m_llc->Enque(packet, dest, flowId);
539 NS_LOG_FUNCTION(
this);
546 NS_LOG_FUNCTION(
this << node);
553 NS_LOG_FUNCTION(
this);
560 NS_LOG_FUNCTION(
this << &cb);
567 NS_LOG_FUNCTION(
this);
575 if (
m_llc !=
nullptr)
582 NetDevice::DoDispose();
588 NS_LOG_FUNCTION(
this << &cb);
595 NS_LOG_FUNCTION(
this);
602 NS_LOG_FUNCTION(
this);
This class implements a tag that carries the MAC address of the sender of the packet.
static TypeId GetTypeId()
Inherited from ObjectBase base class.
Address GetSourceAddress() const
Get the source address.
This class implements a tag that is used to identify control messages (packages).
void SetMsgType(SatControlMsgType_t type)
Set type of the control message.
virtual void SetMsgId(uint32_t msgId)
Set message type specific identifier.
Time tag used to identify the time when packet is enqueued at device level.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
Time tag used to identify the time when packet is enqueued at device level.
Time GetSenderTimestamp(void) const
Get sender time stamp of this tag.
SatLinkDir_t
Link direction used for packet tracing.
Time m_lastLinkDelay
Last link delay measurement.
TracedCallback< const Time &, const Address & > m_rxDelayTrace
Traced callback for all received packets, including delay information and the address of the senders.
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsLinkUp(void) const
virtual Ptr< Channel > GetChannel(void) const
void ToggleState(bool enabled)
Toggle the state of the device.
void SetLlc(Ptr< SatLlc > llc)
Attach the SatLlc llc layer to this netdevice.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Ptr< SatMac > GetMac(void) const
Get a Mac pointer.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
SatNetDevice()
Default constructor.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced callback for all packets received to be transmitted.
Ptr< SatPacketClassifier > m_classifier
Ptr< ErrorModel > m_receiveErrorModel
Time m_lastDelay
Last delay measurement.
virtual uint16_t GetMtu(void) const
virtual bool SupportsSendFrom(void) const
virtual bool NeedsArp(void) const
virtual Address GetAddress(void) const
virtual void DoDispose(void)
Dispose of this class instance.
TracedCallback< const Time &, const Address & > m_rxLinkDelayTrace
Traced callback for all received packets, including link delay information and the address of the sen...
void SetPhy(Ptr< SatPhy > phy)
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
virtual bool IsBroadcast(void) const
Ptr< SatLlc > GetLlc(void) const
Get Llc pointer.
Ptr< SatNodeInfo > m_nodeInfo
virtual Address GetMulticast(Ipv4Address multicastGroup) const
virtual void Receive(Ptr< const Packet > packet)
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
static TypeId GetTypeId(void)
Get the type ID.
Ptr< SatPhy > GetPhy(void) const
Get a Phy pointer.
virtual Address GetBroadcast(void) const
virtual uint32_t GetIfIndex(void) const
void SetMac(Ptr< SatMac > mac)
virtual void SetIfIndex(const uint32_t index)
virtual void SetAddress(Address address)
Ptr< SatPacketClassifier > GetPacketClassifier() const
Get a pointer to packet classifier class.
bool SendControlMsg(Ptr< SatControlMessage > msg, const Address &dest)
NetDevice::PromiscReceiveCallback m_promiscCallback
virtual Ptr< Node > GetNode(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
TracedCallback< const Time &, const Address & > m_rxJitterTrace
Traced callback for all received packets, including jitter information and the address of the senders...
void SetPacketClassifier(Ptr< SatPacketClassifier > classifier)
Set the packet classifier class.
NetDevice::ReceiveCallback m_rxCallback
void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
TracedCallback< const Time &, const Address & > m_rxLinkJitterTrace
Traced callback for all received packets, including link jitter information and the address of the se...
virtual bool IsPointToPoint(void) const
virtual bool IsMulticast(void) const
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SatNetDevice.
virtual bool IsBridge(void) const
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
TracedCallback< Ptr< const Packet >, const Address & > m_signallingTxTrace
Traced callback for all signalling (control message) packets sent, including the destination address.
virtual void SetNode(Ptr< Node > node)
static std::string GetPacketInfo(const Ptr< const Packet > p)
Get packet information in std::string for printing purposes.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.