Loading...
Searching...
No Matches
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
29
30#include "ns3/address.h"
31#include "ns3/callback.h"
32#include "ns3/data-rate.h"
33#include "ns3/mac48-address.h"
34#include "ns3/net-device.h"
35#include "ns3/node.h"
36#include "ns3/nstime.h"
37#include "ns3/packet.h"
38#include "ns3/ptr.h"
39#include "ns3/traced-callback.h"
40
41#include <cstring>
42#include <stdint.h>
43
44namespace ns3
45{
46
47template <typename Item>
50class ErrorModel;
52
66class PointToPointIslNetDevice : public NetDevice
67{
68 public:
74 static TypeId GetTypeId(void);
75
82
89
97 void SetDataRate(DataRate bps);
98
105 void SetInterframeGap(Time t);
106
113 bool Attach(Ptr<PointToPointIslChannel> ch);
114
123 void SetQueue(Ptr<DropTailQueue<Packet>> queue);
124
130 Ptr<DropTailQueue<Packet>> GetQueue(void) const;
131
140 void SetReceiveErrorModel(Ptr<ErrorModel> em);
141
152 void Receive(Ptr<Packet> p);
153
158 void SetOrbiterNetDevice(Ptr<SatOrbiterNetDevice> orbiterNetDevice);
159
160 // The remaining methods are documented in ns3::NetDevice*
161
162 virtual void SetIfIndex(const uint32_t index);
163 virtual uint32_t GetIfIndex(void) const;
164
165 virtual Ptr<Channel> GetChannel(void) const;
166
167 virtual void SetAddress(Address address);
168 virtual Address GetAddress(void) const;
169
170 virtual void SetDestinationNode(Ptr<Node> node);
171 virtual Ptr<Node> GetDestinationNode(void) const;
172
173 virtual bool SetMtu(const uint16_t mtu);
174 virtual uint16_t GetMtu(void) const;
175
176 virtual bool IsLinkUp(void) const;
177
178 virtual void AddLinkChangeCallback(Callback<void> callback);
179
180 virtual bool IsBroadcast(void) const;
181 virtual Address GetBroadcast(void) const;
182
183 virtual bool IsMulticast(void) const;
184 virtual Address GetMulticast(Ipv4Address multicastGroup) const;
185
186 virtual bool IsPointToPoint(void) const;
187 virtual bool IsBridge(void) const;
188
189 virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
190 virtual bool SendFrom(Ptr<Packet> packet,
191 const Address& source,
192 const Address& dest,
193 uint16_t protocolNumber);
194
195 virtual Ptr<Node> GetNode(void) const;
196 virtual void SetNode(Ptr<Node> node);
197
198 virtual bool NeedsArp(void) const;
199
200 virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb);
201
202 virtual Address GetMulticast(Ipv6Address addr) const;
203
204 virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb);
205 virtual bool SupportsSendFrom(void) const;
206
207 private:
217
226
230 virtual void DoDispose(void);
231
236 Address GetRemote(void) const;
237
244 void AddHeader(Ptr<Packet> p, uint16_t protocolNumber);
245
254 bool ProcessHeader(Ptr<Packet> p, uint16_t& param);
255
271 bool TransmitStart(Ptr<Packet> p);
272
279 void TransmitComplete(void);
280
286 void NotifyLinkUp(void);
287
296
297 static const uint16_t DEFAULT_MTU = 1500;
298
300 DataRate m_dataRate;
304 Ptr<PointToPointIslChannel> m_channel;
306 Ptr<DropTailQueue<Packet>>
308 // Management of this Queue has been delegated to the PointToPointIslNetDevice
309 // and it has the responsibility for deletion
310 Ptr<ErrorModel> m_receiveErrorModel;
311 Ptr<Node> m_node;
313 Mac48Address m_address;
314 NetDevice::ReceiveCallback m_rxCallback;
315 NetDevice::PromiscReceiveCallback m_promiscCallback;
316 // (promisc data)
317 uint32_t m_ifIndex;
318 bool m_linkUp;
319 uint32_t m_mtu;
320 Ptr<Packet> m_currentPkt;
321
322 Ptr<SatOrbiterNetDevice>
324
330 static uint16_t PppToEther(uint16_t protocol);
331
337 static uint16_t EtherToPpp(uint16_t protocol);
338
342 TracedCallback<uint32_t, Ptr<Node>, Ptr<Node>, bool> m_packetDropRateTrace;
343};
344
345} // namespace ns3
346
347#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.
bool m_linkUp
Identify if the link is up or not.
void SetQueue(Ptr< DropTailQueue< Packet > > queue)
Attach a queue to the PointToPointIslNetDevice.
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)
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.
PointToPointIslNetDevice & operator=(const PointToPointIslNetDevice &o)
Assign operator.
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 Address GetMulticast(Ipv4Address multicastGroup) const
PointToPointIslNetDevice(const PointToPointIslNetDevice &o)
Copy constructor.
void TransmitComplete(void)
Stop Sending a Packet Down the Wire and Begin the Interframe Gap.
void SetOrbiterNetDevice(Ptr< SatOrbiterNetDevice > orbiterNetDevice)
Set the associated OrbiterNetDevice.
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.
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.
SatOrbiterNetDevice to be utilized in geostationary satellite.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.