satellite-point-to-point-isl-net-device.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007, 2008 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * (Based on point-to-point network device)
19  * Author: Andre Aguas March 2020
20  * Simon 2020
21  * Adapted to SNS-3 by: Bastien Tauran <bastien.tauran@viveris.fr>
22  *
23  */
24 
25 #ifndef SATELLITE_POINT_TO_POINT_ISL_NET_DEVICE_H
26 #define SATELLITE_POINT_TO_POINT_ISL_NET_DEVICE_H
27 
28 #include "ns3/address.h"
29 #include "ns3/callback.h"
30 #include "ns3/data-rate.h"
31 #include "ns3/mac48-address.h"
32 #include "ns3/net-device.h"
33 #include "ns3/node.h"
34 #include "ns3/nstime.h"
35 #include "ns3/packet.h"
36 #include "ns3/ptr.h"
37 #include "ns3/satellite-geo-net-device.h"
38 #include "ns3/traced-callback.h"
39 
40 #include <cstring>
41 
42 namespace ns3
43 {
44 
45 template <typename Item>
48 class ErrorModel;
49 class SatGeoNetDevice;
50 
64 class PointToPointIslNetDevice : public NetDevice
65 {
66  public:
72  static TypeId GetTypeId(void);
73 
80 
86  virtual ~PointToPointIslNetDevice();
87 
95  void SetDataRate(DataRate bps);
96 
103  void SetInterframeGap(Time t);
104 
111  bool Attach(Ptr<PointToPointIslChannel> ch);
112 
121  void SetQueue(Ptr<DropTailQueue<Packet>> queue);
122 
128  Ptr<DropTailQueue<Packet>> GetQueue(void) const;
129 
138  void SetReceiveErrorModel(Ptr<ErrorModel> em);
139 
150  void Receive(Ptr<Packet> p);
151 
156  void SetGeoNetDevice(Ptr<SatGeoNetDevice> geoNetDevice);
157 
158  // The remaining methods are documented in ns3::NetDevice*
159 
160  virtual void SetIfIndex(const uint32_t index);
161  virtual uint32_t GetIfIndex(void) const;
162 
163  virtual Ptr<Channel> GetChannel(void) const;
164 
165  virtual void SetAddress(Address address);
166  virtual Address GetAddress(void) const;
167 
168  virtual void SetDestinationNode(Ptr<Node> node);
169  virtual Ptr<Node> GetDestinationNode(void) const;
170 
171  virtual bool SetMtu(const uint16_t mtu);
172  virtual uint16_t GetMtu(void) const;
173 
174  virtual bool IsLinkUp(void) const;
175 
176  virtual void AddLinkChangeCallback(Callback<void> callback);
177 
178  virtual bool IsBroadcast(void) const;
179  virtual Address GetBroadcast(void) const;
180 
181  virtual bool IsMulticast(void) const;
182  virtual Address GetMulticast(Ipv4Address multicastGroup) const;
183 
184  virtual bool IsPointToPoint(void) const;
185  virtual bool IsBridge(void) const;
186 
187  virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
188  virtual bool SendFrom(Ptr<Packet> packet,
189  const Address& source,
190  const Address& dest,
191  uint16_t protocolNumber);
192 
193  virtual Ptr<Node> GetNode(void) const;
194  virtual void SetNode(Ptr<Node> node);
195 
196  virtual bool NeedsArp(void) const;
197 
198  virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb);
199 
200  virtual Address GetMulticast(Ipv6Address addr) const;
201 
202  virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb);
203  virtual bool SupportsSendFrom(void) const;
204 
205  private:
215 
224 
228  virtual void DoDispose(void);
229 
234  Address GetRemote(void) const;
235 
242  void AddHeader(Ptr<Packet> p, uint16_t protocolNumber);
243 
252  bool ProcessHeader(Ptr<Packet> p, uint16_t& param);
253 
269  bool TransmitStart(Ptr<Packet> p);
270 
277  void TransmitComplete(void);
278 
284  void NotifyLinkUp(void);
285 
290  {
292  BUSY
293  };
294 
295  static const uint16_t DEFAULT_MTU = 1500;
296 
298  DataRate m_dataRate;
302  Ptr<PointToPointIslChannel> m_channel;
304  Ptr<DropTailQueue<Packet>>
306  // Management of this Queue has been delegated to the PointToPointIslNetDevice
307  // and it has the responsibility for deletion
308  Ptr<ErrorModel> m_receiveErrorModel;
309  Ptr<Node> m_node;
310  Ptr<Node> m_destinationNode;
311  Mac48Address m_address;
312  NetDevice::ReceiveCallback m_rxCallback;
313  NetDevice::PromiscReceiveCallback m_promiscCallback;
314  // (promisc data)
315  uint32_t m_ifIndex;
316  bool m_linkUp;
317  uint32_t m_mtu;
318  Ptr<Packet> m_currentPkt;
319 
320  Ptr<SatGeoNetDevice> m_geoNetDevice;
321 
327  static uint16_t PppToEther(uint16_t protocol);
328 
334  static uint16_t EtherToPpp(uint16_t protocol);
335 
339  TracedCallback<uint32_t, Ptr<Node>, Ptr<Node>, bool> m_packetDropRateTrace;
340 };
341 
342 } // namespace ns3
343 
344 #endif /* SATELLITE_POINT_TO_POINT_ISL_NET_DEVICE_H */
TxMachineState
Enumeration of the states of the transmit machine of the net device.
@ READY
The transmitter is ready to begin transmission of a packet.
@ BUSY
The transmitter is busy transmitting a packet.
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.
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)
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 &param)
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...
NetDevice::PromiscReceiveCallback m_promiscCallback
Receive callback.
PointToPointIslNetDevice & operator=(const PointToPointIslNetDevice &o)
Assign operator.
bool m_linkUp
Identify if the link is up or not.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
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.
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.
Ptr< Node > m_node
Node owning this NetDevice.
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.
static uint16_t EtherToPpp(uint16_t protocol)
Ethernet to PPP protocol number mapping.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
PointToPointIslNetDevice(const PointToPointIslNetDevice &o)
Copy constructor.
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.
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 bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Ptr< ErrorModel > m_receiveErrorModel
Error model for receive packet events.
SatGeoNetDevice to be utilized in geostationary satellite.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.