25 #include "ns3/satellite-point-to-point-isl-net-device.h"
27 #include "ns3/drop-tail-queue.h"
28 #include "ns3/error-model.h"
29 #include "ns3/llc-snap-header.h"
31 #include "ns3/mac48-address.h"
32 #include "ns3/pointer.h"
33 #include "ns3/ppp-header.h"
34 #include "ns3/satellite-ground-station-address-tag.h"
35 #include "ns3/satellite-point-to-point-isl-channel.h"
36 #include "ns3/simulator.h"
37 #include "ns3/uinteger.h"
39 NS_LOG_COMPONENT_DEFINE(
"PointToPointIslNetDevice");
44 NS_OBJECT_ENSURE_REGISTERED(PointToPointIslNetDevice);
50 TypeId(
"ns3::PointToPointIslNetDevice")
51 .SetParent<NetDevice>()
52 .AddConstructor<PointToPointIslNetDevice>()
53 .AddAttribute(
"ReceiveErrorModel",
54 "The receiver error model used to simulate packet loss",
57 MakePointerChecker<ErrorModel>())
58 .AddAttribute(
"InterframeGap",
59 "The time to wait between packet (frame) transmissions",
60 TimeValue(Seconds(0.0)),
64 "PacketDropRateTrace",
65 "A packet has been dropped or not",
67 "ns3::SatTypedefs::PacketDropRateTrace");
72 : m_txMachineState(READY),
77 NS_LOG_FUNCTION(
this);
82 NS_LOG_FUNCTION(
this);
88 NS_LOG_FUNCTION(
this << p << protocolNumber);
97 NS_LOG_FUNCTION(
this << p << param);
107 NS_LOG_FUNCTION(
this);
113 NetDevice::DoDispose();
119 NS_LOG_FUNCTION(
this);
126 NS_LOG_FUNCTION(
this << t.GetSeconds());
133 NS_LOG_FUNCTION(
this << p);
134 NS_LOG_LOGIC(
"UID is " << p->GetUid() <<
")");
145 Time txTime =
m_dataRate.CalculateBytesTxTime(p->GetSize());
148 NS_LOG_LOGIC(
"Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds() <<
"sec");
158 NS_LOG_FUNCTION(
this);
170 "PointToPointIslNetDevice::TransmitComplete(): m_currentPkt zero");
174 Ptr<Packet> p =
m_queue->Dequeue();
177 NS_LOG_LOGIC(
"No pending packets in device queue after tx complete");
187 NS_LOG_FUNCTION(
this << &ch);
205 NS_LOG_FUNCTION(
this << q);
212 NS_LOG_FUNCTION(
this << em);
219 NS_LOG_FUNCTION(
this << packet);
220 uint16_t protocol = 0;
239 NetDevice::PACKET_HOST);
244 if (!packet->PeekPacketTag(groundStationAddressTag))
246 NS_FATAL_ERROR(
"SatGroundStationAddressTag not found");
256 NS_LOG_FUNCTION(
this);
261 Ptr<DropTailQueue<Packet>>
264 NS_LOG_FUNCTION(
this);
271 NS_LOG_FUNCTION(
this);
278 NS_LOG_FUNCTION(
this);
303 NS_LOG_FUNCTION(
this << address);
304 m_address = Mac48Address::ConvertFrom(address);
316 NS_LOG_FUNCTION(
this << node);
329 NS_LOG_FUNCTION(
this);
336 NS_LOG_FUNCTION(
this);
346 NS_LOG_FUNCTION(
this);
358 NS_LOG_FUNCTION(
this);
359 return Mac48Address(
"ff:ff:ff:ff:ff:ff");
365 NS_LOG_FUNCTION(
this);
372 NS_LOG_FUNCTION(
this);
373 return Mac48Address(
"01:00:5e:00:00:00");
379 NS_LOG_FUNCTION(
this << addr);
380 return Mac48Address(
"33:33:00:00:00:00");
386 NS_LOG_FUNCTION(
this);
393 NS_LOG_FUNCTION(
this);
400 NS_LOG_FUNCTION(
this << packet << dest << protocolNumber);
401 NS_LOG_LOGIC(
"p=" << packet <<
", dest=" << &dest);
402 NS_LOG_LOGIC(
"UID is " << packet->GetUid());
438 const Address& source,
440 uint16_t protocolNumber)
442 NS_LOG_FUNCTION(
this << packet << source << dest << protocolNumber);
455 NS_LOG_FUNCTION(
this);
462 NS_LOG_FUNCTION(
this);
481 NS_LOG_FUNCTION(
this);
488 NS_LOG_FUNCTION(
this);
489 NS_ASSERT(
m_channel->GetNDevices() == 2);
490 for (std::size_t i = 0; i <
m_channel->GetNDevices(); ++i)
492 Ptr<NetDevice> tmp =
m_channel->GetDevice(i);
495 return tmp->GetAddress();
506 NS_LOG_FUNCTION(
this << mtu);
514 NS_LOG_FUNCTION(
this);
521 NS_LOG_FUNCTION_NOARGS();
529 NS_ASSERT_MSG(
false,
"PPP Protocol number not defined!");
537 NS_LOG_FUNCTION_NOARGS();
545 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)
void SetGeoNetDevice(Ptr< SatGeoNetDevice > geoNetDevice)
Set the associated GeoNetDevice.
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.
virtual bool IsMulticast(void) const
virtual void SetNode(Ptr< Node > node)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
virtual bool IsBroadcast(void) const
Ptr< SatGeoNetDevice > m_geoNetDevice
Satellite GEO Net Device associated to this instance.
void TransmitComplete(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
virtual Ptr< Node > GetNode(void) const
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.