30 #include "ns3/drop-tail-queue.h"
31 #include "ns3/error-model.h"
32 #include "ns3/llc-snap-header.h"
34 #include "ns3/mac48-address.h"
35 #include "ns3/pointer.h"
36 #include "ns3/ppp-header.h"
37 #include "ns3/simulator.h"
38 #include "ns3/uinteger.h"
42 NS_LOG_COMPONENT_DEFINE(
"PointToPointIslNetDevice");
47 NS_OBJECT_ENSURE_REGISTERED(PointToPointIslNetDevice);
53 TypeId(
"ns3::PointToPointIslNetDevice")
54 .SetParent<NetDevice>()
55 .AddConstructor<PointToPointIslNetDevice>()
56 .AddAttribute(
"ReceiveErrorModel",
57 "The receiver error model used to simulate packet loss",
60 MakePointerChecker<ErrorModel>())
61 .AddAttribute(
"InterframeGap",
62 "The time to wait between packet (frame) transmissions",
63 TimeValue(Seconds(0.0)),
67 "PacketDropRateTrace",
68 "A packet has been dropped or not",
70 "ns3::SatTypedefs::PacketDropRateTrace");
75 : m_txMachineState(READY),
80 NS_LOG_FUNCTION(
this);
85 NS_LOG_FUNCTION(
this);
91 NS_LOG_FUNCTION(
this << p << protocolNumber);
100 NS_LOG_FUNCTION(
this << p << param);
102 p->RemoveHeader(ppp);
110 NS_LOG_FUNCTION(
this);
116 NetDevice::DoDispose();
122 NS_LOG_FUNCTION(
this);
129 NS_LOG_FUNCTION(
this << t.GetSeconds());
136 NS_LOG_FUNCTION(
this << p);
137 NS_LOG_LOGIC(
"UID is " << p->GetUid() <<
")");
148 Time txTime =
m_dataRate.CalculateBytesTxTime(p->GetSize());
151 NS_LOG_LOGIC(
"Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds() <<
"sec");
161 NS_LOG_FUNCTION(
this);
173 "PointToPointIslNetDevice::TransmitComplete(): m_currentPkt zero");
177 Ptr<Packet> p =
m_queue->Dequeue();
180 NS_LOG_LOGIC(
"No pending packets in device queue after tx complete");
190 NS_LOG_FUNCTION(
this << &ch);
208 NS_LOG_FUNCTION(
this << q);
215 NS_LOG_FUNCTION(
this << em);
222 NS_LOG_FUNCTION(
this << packet);
223 uint16_t protocol = 0;
242 NetDevice::PACKET_HOST);
247 if (!packet->PeekPacketTag(groundStationAddressTag))
249 NS_FATAL_ERROR(
"SatGroundStationAddressTag not found");
260 NS_LOG_FUNCTION(
this);
265 Ptr<DropTailQueue<Packet>>
268 NS_LOG_FUNCTION(
this);
275 NS_LOG_FUNCTION(
this);
282 NS_LOG_FUNCTION(
this);
307 NS_LOG_FUNCTION(
this << address);
308 m_address = Mac48Address::ConvertFrom(address);
320 NS_LOG_FUNCTION(
this << node);
333 NS_LOG_FUNCTION(
this);
340 NS_LOG_FUNCTION(
this);
350 NS_LOG_FUNCTION(
this);
362 NS_LOG_FUNCTION(
this);
363 return Mac48Address(
"ff:ff:ff:ff:ff:ff");
369 NS_LOG_FUNCTION(
this);
376 NS_LOG_FUNCTION(
this);
377 return Mac48Address(
"01:00:5e:00:00:00");
383 NS_LOG_FUNCTION(
this << addr);
384 return Mac48Address(
"33:33:00:00:00:00");
390 NS_LOG_FUNCTION(
this);
397 NS_LOG_FUNCTION(
this);
404 NS_LOG_FUNCTION(
this << packet << dest << protocolNumber);
405 NS_LOG_LOGIC(
"p=" << packet <<
", dest=" << &dest);
406 NS_LOG_LOGIC(
"UID is " << packet->GetUid());
442 const Address& source,
444 uint16_t protocolNumber)
446 NS_LOG_FUNCTION(
this << packet << source << dest << protocolNumber);
459 NS_LOG_FUNCTION(
this);
466 NS_LOG_FUNCTION(
this);
485 NS_LOG_FUNCTION(
this);
492 NS_LOG_FUNCTION(
this);
493 NS_ASSERT(
m_channel->GetNDevices() == 2);
494 for (std::size_t i = 0; i <
m_channel->GetNDevices(); ++i)
496 Ptr<NetDevice> tmp =
m_channel->GetDevice(i);
499 return tmp->GetAddress();
510 NS_LOG_FUNCTION(
this << mtu);
518 NS_LOG_FUNCTION(
this);
525 NS_LOG_FUNCTION_NOARGS();
533 NS_ASSERT_MSG(
false,
"PPP Protocol number not defined!");
541 NS_LOG_FUNCTION_NOARGS();
549 NS_ASSERT_MSG(
false,
"PPP Protocol number not defined!");
@ READY
The transmitter is ready to begin transmission of a packet.
@ BUSY
The transmitter is busy transmitting a packet.
virtual uint32_t GetIfIndex(void) const
Ptr< DropTailQueue< Packet > > m_queue
The Queue which this PointToPointIslNetDevice uses as a packet source.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the PointToPointIslNetDevice.
virtual Address GetBroadcast(void) const
NetDevice::ReceiveCallback m_rxCallback
Receive callback.
bool TransmitStart(Ptr< Packet > p)
Start Sending a Packet Down the Wire.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual bool NeedsArp(void) const
virtual void SetIfIndex(const uint32_t index)
void NotifyLinkUp(void)
Make the link up and running.
void SetInterframeGap(Time t)
Set the interframe gap used to separate packets.
Mac48Address m_address
Mac48Address of this NetDevice.
void Receive(Ptr< Packet > p)
Receive a packet from a connected PointToPointIslChannel.
Ptr< Packet > m_currentPkt
Current packet processed.
PointToPointIslNetDevice()
Construct a PointToPointIslNetDevice.
bool ProcessHeader(Ptr< Packet > p, uint16_t ¶m)
Removes, from a packet of data, all headers and trailers that relate to the protocol implemented by t...
void AddHeader(Ptr< Packet > p, uint16_t protocolNumber)
Adds the necessary headers and trailers to a packet of data in order to respect the protocol implemen...
virtual bool SupportsSendFrom(void) const
NetDevice::PromiscReceiveCallback m_promiscCallback
Receive callback.
virtual bool IsBridge(void) const
bool m_linkUp
Identify if the link is up or not.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual Ptr< Node > GetDestinationNode(void) const
void SetDataRate(DataRate bps)
Set the Data Rate used for transmission of packets.
Ptr< DropTailQueue< Packet > > GetQueue(void) const
Get a copy of the attached Queue.
Address GetRemote(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
TracedCallback< uint32_t, Ptr< Node >, Ptr< Node >, bool > m_packetDropRateTrace
Traced callback for drop rate in queue.
virtual bool SetMtu(const uint16_t mtu)
virtual void SetAddress(Address address)
virtual uint16_t GetMtu(void) const
Ptr< Node > m_node
Node owning this NetDevice.
virtual bool IsLinkUp(void) const
virtual ~PointToPointIslNetDevice()
Destroy a PointToPointIslNetDevice.
TxMachineState m_txMachineState
The state of the Net Device transmit state machine.
Time m_tInterframeGap
The interframe gap that the Net Device uses to throttle packet transmission.
DataRate m_dataRate
The data rate that the Net Device uses to simulate packet transmission timing.
virtual bool IsPointToPoint(void) const
static uint16_t EtherToPpp(uint16_t protocol)
Ethernet to PPP protocol number mapping.
Ptr< SatOrbiterNetDevice > m_orbiterNetDevice
Satellite Orbiter Net Device associated to this instance.
virtual bool IsMulticast(void) const
virtual void SetNode(Ptr< Node > node)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
virtual bool IsBroadcast(void) const
void TransmitComplete(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
virtual Ptr< Node > GetNode(void) const
void SetOrbiterNetDevice(Ptr< SatOrbiterNetDevice > orbiterNetDevice)
Set the associated OrbiterNetDevice.
virtual void SetDestinationNode(Ptr< Node > node)
static TypeId GetTypeId(void)
Get the TypeId.
uint32_t m_ifIndex
Index of the interface.
static uint16_t PppToEther(uint16_t protocol)
PPP to Ethernet protocol number mapping.
uint32_t m_mtu
The Maximum Transmission Unit.
virtual void DoDispose(void)
Dispose of the object.
Ptr< Node > m_destinationNode
Node at the other end of the p2pIslLink.
Ptr< PointToPointIslChannel > m_channel
The PointToPointIslChannel to which this PointToPointIslNetDevice has been attached.
void SetQueue(Ptr< DropTailQueue< Packet >> queue)
Attach a queue to the PointToPointIslNetDevice.
bool Attach(Ptr< PointToPointIslChannel > ch)
Attach the device to a channel.
virtual Ptr< Channel > GetChannel(void) const
virtual Address GetAddress(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events.
Tag to store ground station destination address.
Mac48Address GetGroundStationAddress(void) const
Get the ground station MAC address.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.