satellite-geo-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) 2013 Magister Solutions Ltd.
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  * Author: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
21 #ifndef SATELLITE_GEO_NET_DEVICE_H
22 #define SATELLITE_GEO_NET_DEVICE_H
23 
24 #include <ns3/error-model.h>
25 #include <ns3/mac48-address.h>
26 #include <ns3/net-device.h>
27 #include <ns3/output-stream-wrapper.h>
28 #include <ns3/satellite-channel.h>
29 #include <ns3/satellite-isl-arbiter.h>
30 #include <ns3/satellite-mac.h>
31 #include <ns3/satellite-phy.h>
32 #include <ns3/satellite-point-to-point-isl-net-device.h>
33 #include <ns3/satellite-signal-parameters.h>
34 #include <ns3/traced-callback.h>
35 
36 #include <map>
37 #include <stdint.h>
38 #include <string>
39 
40 namespace ns3
41 {
42 
43 class PointToPointIslNetDevice;
44 class SatIslArbiter;
45 
54 class SatGeoNetDevice : public NetDevice
55 {
56  public:
61  static TypeId GetTypeId(void);
62 
67 
73  void ReceivePacketUser(Ptr<Packet> packet, const Address& userAddress);
74 
80  void ReceivePacketFeeder(Ptr<Packet> packet, const Address& feederAddress);
81 
87  void ReceiveUser(SatPhy::PacketContainer_t packets, Ptr<SatSignalParameters> rxParams);
88 
94  void ReceiveFeeder(SatPhy::PacketContainer_t packets, Ptr<SatSignalParameters> rxParams);
95 
103  bool SendControlMsgToFeeder(Ptr<SatControlMessage> msg,
104  const Address& dest,
105  Ptr<SatSignalParameters> rxParams);
106 
112  void AddUserPhy(Ptr<SatPhy> phy, uint32_t beamId);
113 
119  void AddFeederPhy(Ptr<SatPhy> phy, uint32_t beamId);
120 
126  Ptr<SatPhy> GetUserPhy(uint32_t beamId);
127 
133  Ptr<SatPhy> GetFeederPhy(uint32_t beamId);
134 
139  std::map<uint32_t, Ptr<SatPhy>> GetUserPhy();
140 
145  std::map<uint32_t, Ptr<SatPhy>> GetFeederPhy();
146 
152  void AddUserMac(Ptr<SatMac> mac, uint32_t beamId);
153 
160  void AddFeederMac(Ptr<SatMac> mac, Ptr<SatMac> macUsed, uint32_t beamId);
161 
167  Ptr<SatMac> GetUserMac(uint32_t beamId);
168 
174  Ptr<SatMac> GetFeederMac(uint32_t beamId);
175 
180  std::map<uint32_t, Ptr<SatMac>> GetUserMac();
181 
186  std::map<uint32_t, Ptr<SatMac>> GetFeederMac();
187 
192  std::map<uint32_t, Ptr<SatMac>> GetAllFeederMac();
193 
199  void AddFeederPair(uint32_t beamId, Mac48Address satelliteFeederAddress);
200 
206  Mac48Address GetSatelliteFeederAddress(uint32_t beamId);
207 
212  void SetReceiveErrorModel(Ptr<ErrorModel> em);
213 
218  void SetForwardLinkRegenerationMode(SatEnums::RegenerationMode_t forwardLinkRegenerationMode);
219 
224  void SetReturnLinkRegenerationMode(SatEnums::RegenerationMode_t returnLinkRegenerationMode);
225 
226  void SetNodeId(uint32_t nodeId);
227 
232  void ConnectGw(Mac48Address gwAddress);
233 
238  void DisconnectGw(Mac48Address gwAddress);
239 
245  std::set<Mac48Address> GetGwConnected();
246 
251  void ConnectUt(Mac48Address utAddress);
252 
257  void DisconnectUt(Mac48Address utAddress);
258 
264  std::set<Mac48Address> GetUtConnected();
265 
270  void AddIslsNetDevice(Ptr<PointToPointIslNetDevice> islNetDevices);
271 
276  std::vector<Ptr<PointToPointIslNetDevice>> GetIslsNetDevices();
277 
282  void SetArbiter(Ptr<SatIslArbiter> arbiter);
283 
288  Ptr<SatIslArbiter> GetArbiter();
289 
295  void SendToIsl(Ptr<Packet> packet, Mac48Address destination);
296 
302  void ReceiveFromIsl(Ptr<Packet> packet, Mac48Address destination);
303 
304  // inherited from NetDevice base class.
305  virtual void SetIfIndex(const uint32_t index);
306  virtual uint32_t GetIfIndex(void) const;
307  virtual void SetAddress(Address address);
308  virtual Address GetAddress(void) const;
309  virtual bool SetMtu(const uint16_t mtu);
310  virtual uint16_t GetMtu(void) const;
311  virtual bool IsLinkUp(void) const;
312  virtual void AddLinkChangeCallback(Callback<void> callback);
313  virtual bool IsBroadcast(void) const;
314  virtual Address GetBroadcast(void) const;
315  virtual bool IsMulticast(void) const;
316  virtual Address GetMulticast(Ipv4Address multicastGroup) const;
317  virtual bool IsPointToPoint(void) const;
318  virtual bool IsBridge(void) const;
319  virtual bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
320  virtual bool SendFrom(Ptr<Packet> packet,
321  const Address& source,
322  const Address& dest,
323  uint16_t protocolNumber);
324  virtual Ptr<Node> GetNode(void) const;
325  virtual void SetNode(Ptr<Node> node);
326  virtual bool NeedsArp(void) const;
327  virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb);
328  virtual Address GetMulticast(Ipv6Address addr) const;
329 
330  virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb);
331  virtual bool SupportsSendFrom(void) const;
332 
333  virtual Ptr<Channel> GetChannel(void) const;
334 
335  protected:
339  virtual void DoDispose(void);
340 
341  private:
346  Address GetRxUtAddress(Ptr<Packet> packet, SatEnums::SatLinkDir_t ld);
347 
348  NetDevice::ReceiveCallback m_rxCallback;
349  NetDevice::PromiscReceiveCallback m_promiscCallback;
350  Ptr<Node> m_node;
351  uint16_t m_mtu;
352  uint32_t m_ifIndex;
353  Mac48Address m_address;
354  Ptr<ErrorModel> m_receiveErrorModel;
355  std::map<uint32_t, Ptr<SatPhy>> m_userPhy;
356  std::map<uint32_t, Ptr<SatPhy>> m_feederPhy;
357  std::map<uint32_t, Ptr<SatMac>> m_userMac;
358  std::map<uint32_t, Ptr<SatMac>> m_feederMac;
359 
360  std::map<uint32_t, Ptr<SatMac>> m_allFeederMac;
361 
362  std::map<uint32_t, Mac48Address> m_addressMapFeeder;
363 
366  uint32_t m_nodeId;
367 
369 
370  std::map<Mac48Address, Time> m_lastDelays;
371 
375  std::set<Mac48Address> m_gwConnected;
376 
380  std::set<Mac48Address> m_utConnected;
381 
385  std::vector<Ptr<PointToPointIslNetDevice>> m_islNetDevices;
386 
390  Ptr<SatIslArbiter> m_arbiter;
391 
395  std::set<uint32_t> m_broadcastReceived;
396 
397  TracedCallback<Time,
400  uint32_t,
401  Mac48Address,
404  std::string>
406 
410  TracedCallback<Ptr<const Packet>> m_txTrace;
411 
416  TracedCallback<Ptr<const Packet>, const Address&> m_signallingTxTrace;
417 
422  TracedCallback<Ptr<const Packet>, const Address&> m_rxFeederTrace;
423 
428  TracedCallback<Ptr<const Packet>, const Address&> m_rxUserTrace;
429 
434  TracedCallback<const Time&, const Address&> m_rxFeederLinkDelayTrace;
435 
440  TracedCallback<const Time&, const Address&> m_rxFeederLinkJitterTrace;
441 
446  TracedCallback<const Time&, const Address&> m_rxUserLinkDelayTrace;
447 
452  TracedCallback<const Time&, const Address&> m_rxUserLinkJitterTrace;
453 };
454 
455 } // namespace ns3
456 
457 #endif /* SATELLITE_GEO_NET_DEVICE_H */
SatLinkDir_t
Link direction used for packet tracing.
SatNodeType_t
Node type used for packet tracing.
SatPacketEvent_t
Packet event used for packet tracing.
SatLogLevel_t
Log level used for packet tracing.
RegenerationMode_t
The regeneration mode used in satellites.
SatGeoNetDevice to be utilized in geostationary satellite.
void ReceiveFromIsl(Ptr< Packet > packet, Mac48Address destination)
Receive a packet from ISL.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint16_t GetMtu(void) const
Mac48Address GetSatelliteFeederAddress(uint32_t beamId)
Get satellite feeder entry from associated beam ID.
virtual Address GetAddress(void) const
TracedCallback< const Time &, const Address & > m_rxFeederLinkJitterTrace
Traced callback for all received packets, including feeder link jitter information and the address of...
virtual bool IsBridge(void) const
Ptr< SatIslArbiter > GetArbiter()
Get the arbiter for ISL routing.
std::map< Mac48Address, Time > m_lastDelays
SatGeoNetDevice()
Default constructor.
std::map< uint32_t, Ptr< SatMac > > GetAllFeederMac()
Get all Feeder MAC objects attached to this satellite.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
void DisconnectGw(Mac48Address gwAddress)
Disconnect a GW to this satellite.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
std::set< Mac48Address > m_utConnected
Set containing all connected UTs.
virtual bool SetMtu(const uint16_t mtu)
void AddUserPhy(Ptr< SatPhy > phy, uint32_t beamId)
Add the User Phy object for the beam.
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual void SetAddress(Address address)
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
void AddIslsNetDevice(Ptr< PointToPointIslNetDevice > islNetDevices)
Add a ISL Net Device to this satellite.
NetDevice::PromiscReceiveCallback m_promiscCallback
std::map< uint32_t, Ptr< SatPhy > > m_userPhy
std::map< uint32_t, Ptr< SatMac > > m_userMac
std::map< uint32_t, Ptr< SatPhy > > GetFeederPhy()
Get all Feeder Phy objects attached to this satellite.
Address GetRxUtAddress(Ptr< Packet > packet, SatEnums::SatLinkDir_t ld)
Get UT MAC address associated to this packet.
static TypeId GetTypeId(void)
Get the type ID.
std::set< Mac48Address > m_gwConnected
Set containing all connected GWs.
void SetForwardLinkRegenerationMode(SatEnums::RegenerationMode_t forwardLinkRegenerationMode)
Set the forward link regeneration mode.
virtual bool SupportsSendFrom(void) const
std::map< uint32_t, Ptr< SatMac > > m_allFeederMac
void SetArbiter(Ptr< SatIslArbiter > arbiter)
Set the arbiter for ISL routing.
std::set< uint32_t > m_broadcastReceived
Keep a count of all incoming broadcast data to avoid handling them several times.
NetDevice::ReceiveCallback m_rxCallback
TracedCallback< Ptr< const Packet >, const Address & > m_signallingTxTrace
Traced callback for all signalling (control message) packets sent, including the destination address.
std::map< uint32_t, Ptr< SatPhy > > m_feederPhy
std::set< Mac48Address > GetUtConnected()
The the list of UT MAC connected to this satellite.
virtual void SetIfIndex(const uint32_t index)
virtual bool IsMulticast(void) const
void ReceivePacketFeeder(Ptr< Packet > packet, const Address &feederAddress)
Receive the packet from the lower layers, in network regeneration on forward link.
void SendToIsl(Ptr< Packet > packet, Mac48Address destination)
Send a packet to ISL.
virtual Address GetBroadcast(void) const
virtual bool IsLinkUp(void) const
void ConnectUt(Mac48Address utAddress)
Connect a UT to this satellite.
void AddFeederMac(Ptr< SatMac > mac, Ptr< SatMac > macUsed, uint32_t beamId)
Add the Feeder MAC object for the beam.
void AddUserMac(Ptr< SatMac > mac, uint32_t beamId)
Add the User MAC object for the beam.
std::map< uint32_t, Ptr< SatMac > > GetUserMac()
Get all User MAC objects attached to this satellite.
std::map< uint32_t, Mac48Address > m_addressMapFeeder
Ptr< ErrorModel > m_receiveErrorModel
void AddFeederPair(uint32_t beamId, Mac48Address satelliteFeederAddress)
Add an entry in the database to get satellite feeder address from beam ID.
virtual void DoDispose(void)
Dispose of this class instance.
std::map< uint32_t, Ptr< SatMac > > GetFeederMac()
Get all Feeder MAC objects attached to this satellite that are in use.
virtual bool NeedsArp(void) const
virtual uint32_t GetIfIndex(void) const
TracedCallback< const Time &, const Address & > m_rxFeederLinkDelayTrace
Traced callback for all received packets, including feeder link delay information and the address of ...
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SatGeoNetDevice.
void DisconnectUt(Mac48Address utAddress)
Disconnect a UT to this satellite.
bool SendControlMsgToFeeder(Ptr< SatControlMessage > msg, const Address &dest, Ptr< SatSignalParameters > rxParams)
Send a control packet on the feeder link.
std::vector< Ptr< PointToPointIslNetDevice > > m_islNetDevices
List of ISLs starting from this node.
Ptr< SatIslArbiter > m_arbiter
Arbiter used to route on ISLs.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced callback for all packets received to be transmitted.
virtual Ptr< Node > GetNode(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void SetNode(Ptr< Node > node)
void SetReturnLinkRegenerationMode(SatEnums::RegenerationMode_t returnLinkRegenerationMode)
Set the return link regeneration mode.
virtual bool IsPointToPoint(void) const
std::vector< Ptr< PointToPointIslNetDevice > > GetIslsNetDevices()
Get all the ISL Net devices.
TracedCallback< const Time &, const Address & > m_rxUserLinkJitterTrace
Traced callback for all received packets, including user link jitter information and the address of t...
void ReceiveUser(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive the packet from the lower layers.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
void ReceivePacketUser(Ptr< Packet > packet, const Address &userAddress)
Receive the packet from the lower layers, in network regeneration on return link.
void ConnectGw(Mac48Address gwAddress)
Connect a GW to this satellite.
TracedCallback< const Time &, const Address & > m_rxUserLinkDelayTrace
Traced callback for all received packets, including user link delay information and the address of th...
std::set< Mac48Address > GetGwConnected()
The the list of MAC GW connected to this satellite.
void SetNodeId(uint32_t nodeId)
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
void ReceiveFeeder(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters > rxParams)
Receive the packet from the lower layers.
virtual bool IsBroadcast(void) const
virtual Ptr< Channel > GetChannel(void) const
void AddFeederPhy(Ptr< SatPhy > phy, uint32_t beamId)
Add the Feeder Phy object for the beam.
std::map< uint32_t, Ptr< SatPhy > > GetUserPhy()
Get all User Phy objects attached to this satellite.
TracedCallback< Ptr< const Packet >, const Address & > m_rxUserTrace
Traced callback for all received packets on user, including the address of the senders.
std::map< uint32_t, Ptr< SatMac > > m_feederMac
TracedCallback< Ptr< const Packet >, const Address & > m_rxFeederTrace
Traced callback for all received packets on feeder, including the address of the senders.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
Definition: satellite-phy.h:78
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.