satellite-llc.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: Jani Puttonen <jani.puttonen@magister.fi>
19  */
20 
21 #ifndef SATELLITE_LLC_H_
22 #define SATELLITE_LLC_H_
23 
25 
26 #include <ns3/mac48-address.h>
27 #include <ns3/object.h>
28 #include <ns3/ptr.h>
29 #include <ns3/simple-ref-count.h>
30 #include <ns3/traced-callback.h>
31 
32 #include <map>
33 #include <vector>
34 
35 namespace ns3
36 {
37 
38 class Time;
39 class Address;
40 class Packet;
41 class SatControlMessage;
42 class SatSchedulingObject;
43 class SatNodeInfo;
44 
50 class EncapKey : public SimpleRefCount<EncapKey>
51 {
52  public:
53  Mac48Address m_encapAddress;
54  Mac48Address m_decapAddress;
55  Mac48Address m_sourceE2EAddress;
56  Mac48Address m_destE2EAddress;
57  int8_t m_flowId;
58 
59  EncapKey(const Mac48Address encapAddress,
60  const Mac48Address decapAddress,
61  const uint8_t flowId,
62  const Mac48Address sourceE2EAddress = Mac48Address(),
63  const Mac48Address destE2EAddress = Mac48Address())
64  : m_encapAddress(encapAddress),
65  m_decapAddress(decapAddress),
66  m_sourceE2EAddress(sourceE2EAddress),
67  m_destE2EAddress(destE2EAddress),
68  m_flowId(flowId)
69  {
70  }
71 };
72 
81 {
82  public:
83  bool operator()(Ptr<EncapKey> key1, Ptr<EncapKey> key2) const
84  {
85  if (key1->m_encapAddress == key2->m_encapAddress)
86  {
87  if (key1->m_decapAddress == key2->m_decapAddress)
88  {
89  return key1->m_flowId < key2->m_flowId;
90  }
91  else
92  {
93  return key1->m_decapAddress < key2->m_decapAddress;
94  }
95  }
96  else
97  {
98  return key1->m_encapAddress < key2->m_encapAddress;
99  }
100  }
101 };
102 
129 class SatLlc : public Object
130 {
131  public:
135  static TypeId GetTypeId(void);
136 
140  SatLlc();
141 
147  SatLlc(SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
148  SatEnums::RegenerationMode_t returnLinkRegenerationMode);
149 
155  virtual ~SatLlc();
156 
162  typedef std::map<Ptr<EncapKey>, Ptr<SatBaseEncapsulator>, EncapKeyCompare> EncapContainer_t;
163 
168  typedef Callback<void, Ptr<const Packet>> ReceiveCallback;
169 
176  typedef Callback<Ptr<SatControlMessage>, uint32_t> ReadCtrlMsgCallback;
177 
183 
192  virtual bool Enque(Ptr<Packet> packet, Address dest, uint8_t flowId);
193 
207  virtual Ptr<Packet> NotifyTxOpportunity(uint32_t bytes,
208  Mac48Address utAddr,
209  uint8_t flowId,
210  uint32_t& bytesLeft,
211  uint32_t& nextMinTxO) = 0;
212 
219  virtual void Receive(Ptr<Packet> packet, Mac48Address source, Mac48Address dest);
220 
228  virtual void ReceiveHigherLayerPdu(Ptr<Packet> packet, Mac48Address source, Mac48Address dest);
229 
236 
245  void AddEncap(Mac48Address source,
246  Mac48Address dest,
247  uint8_t flowId,
248  Ptr<SatBaseEncapsulator> enc);
249 
258  void AddDecap(Mac48Address source,
259  Mac48Address dest,
260  uint8_t flowId,
261  Ptr<SatBaseEncapsulator> dec);
262 
267  virtual void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
268 
276  virtual void GetSchedulingContexts(std::vector<Ptr<SatSchedulingObject>>& output) const = 0;
277 
282  virtual bool BuffersEmpty() const;
283 
288  virtual bool ControlBuffersEmpty() const;
289 
299  virtual uint32_t GetNBytesInQueue(Mac48Address utAddress) const = 0;
300 
310  virtual uint32_t GetNPacketsInQueue(Mac48Address utAddress) const = 0;
311 
318  virtual uint32_t GetNBytesInQueue() const;
319 
326  virtual uint32_t GetNPacketsInQueue() const;
327 
332 
337  virtual void SetGwAddress(Mac48Address address);
338 
343  virtual void SetSatelliteAddress(Mac48Address address);
344 
349  void SetAdditionalHeaderSize(uint32_t additionalHeaderSize);
350 
351  protected:
355  virtual void DoDispose();
356 
363  virtual void CreateEncap(Ptr<EncapKey> key) = 0;
364 
371  virtual void CreateDecap(Ptr<EncapKey> key) = 0;
372 
379  virtual void ReceiveAck(Ptr<SatArqAckMessage> ack, Mac48Address source, Mac48Address dest);
380 
386 
392 
396  TracedCallback<Time,
399  uint32_t,
400  Mac48Address,
403  std::string>
405 
410  Ptr<SatNodeInfo> m_nodeInfo;
411 
416 
421 
426 
431 
435  Mac48Address m_gwAddress;
436 
440  Mac48Address m_satelliteAddress;
441 
446 
451 
456 
463 
468 
473 };
474 
475 } // namespace ns3
476 
477 #endif /* SATELLITE_LLC_H_ */
EncapKeyCompare is used as a custom compare method within EncapContainer map.
Definition: satellite-llc.h:81
bool operator()(Ptr< EncapKey > key1, Ptr< EncapKey > key2) const
Definition: satellite-llc.h:83
EncapKey class is used as a key in the encapsulator/decapsulator container.
Definition: satellite-llc.h:51
Mac48Address m_encapAddress
Definition: satellite-llc.h:53
Mac48Address m_decapAddress
Definition: satellite-llc.h:54
EncapKey(const Mac48Address encapAddress, const Mac48Address decapAddress, const uint8_t flowId, const Mac48Address sourceE2EAddress=Mac48Address(), const Mac48Address destE2EAddress=Mac48Address())
Definition: satellite-llc.h:59
Mac48Address m_sourceE2EAddress
Definition: satellite-llc.h:55
Mac48Address m_destE2EAddress
Definition: satellite-llc.h:56
Callback< bool, Ptr< SatControlMessage >, const Address & > SendCtrlCallback
Control msg sending callback.
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.
SatLlc base class holds the UT specific SatBaseEncapsulator instances, which are responsible of fragm...
virtual SatEnums::SatLinkDir_t GetSatLinkTxDir()
Get the link TX direction.
virtual bool BuffersEmpty() const
Are buffers empty?
static TypeId GetTypeId(void)
Derived from Object.
virtual SatEnums::SatLinkDir_t GetSatLinkRxDir()
Get the link RX direction.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
virtual void SetGwAddress(Mac48Address address)
Set the GW address.
SatLlc::ReadCtrlMsgCallback m_readCtrlCallback
The read control message callback.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
virtual uint32_t GetNBytesInQueue() const
Get the total number of (new) bytes in all encapsulators.
virtual void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
void SetReadCtrlCallback(SatLlc::ReadCtrlMsgCallback cb)
Method to set read control message callback.
uint32_t m_additionalHeaderSize
Additional header size to add to encapsulation/decapsulation.
void SetReceiveCallback(SatLlc::ReceiveCallback cb)
Set Receive callback to forward packet to upper layer.
bool m_fwdLinkArqEnabled
Is FWD link ARQ enabled.
SatBaseEncapsulator::SendCtrlCallback m_sendCtrlCallback
Callback to send control messages.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
EncapContainer_t m_decaps
Map of decapsulator base pointers.
virtual void GetSchedulingContexts(std::vector< Ptr< SatSchedulingObject >> &output) const =0
Create and fill the scheduling objects based on LLC layer information.
virtual void CreateEncap(Ptr< EncapKey > key)=0
Virtual method to create a new encapsulator 'on-a-need-basis' dynamically.
virtual uint32_t GetNPacketsInQueue(Mac48Address utAddress) const =0
Get the number of (new) packets at LLC queues for a certain UT.
TracedCallback< Time, SatEnums::SatPacketEvent_t, SatEnums::SatNodeType_t, uint32_t, Mac48Address, SatEnums::SatLogLevel_t, SatEnums::SatLinkDir_t, std::string > m_packetTrace
Trace callback used for packet tracing:
virtual void CreateDecap(Ptr< EncapKey > key)=0
Virtual method to create a new decapsulator 'on-a-need-basis' dynamically.
Mac48Address m_gwAddress
GW address.
virtual void DoDispose()
Dispose of this class instance.
void AddEncap(Mac48Address source, Mac48Address dest, uint8_t flowId, Ptr< SatBaseEncapsulator > enc)
Add an encapsulator entry for the LLC.
virtual void ReceiveAck(Ptr< SatArqAckMessage > ack, Mac48Address source, Mac48Address dest)
Receive a control msg (ARQ ACK) from lower layer.
void SetCtrlMsgCallback(SatBaseEncapsulator::SendCtrlCallback cb)
EncapContainer_t m_encaps
Map of encapsulator base pointers.
virtual ~SatLlc()
Destroy a SatLlc.
void SetAdditionalHeaderSize(uint32_t additionalHeaderSize)
Set the additional header size.
std::map< Ptr< EncapKey >, Ptr< SatBaseEncapsulator >, EncapKeyCompare > EncapContainer_t
Key = Ptr<EncapKey> (source, dest, flowId) Value = Ptr<SatBaseEncapsulator> Compare class = EncapKeyC...
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
virtual bool ControlBuffersEmpty() const
Are buffers empty?
SatLlc()
Construct a SatLlc, should not be used.
virtual void SetSatelliteAddress(Mac48Address address)
Set the SAT address.
virtual uint32_t GetNPacketsInQueue() const
Get the total number of (new) packets in all encapsulators.
virtual void ReceiveHigherLayerPdu(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive HL PDU from encapsulator/decapsulator entity.
Callback< void, Ptr< const Packet > > ReceiveCallback
Receive callback used for sending packet to netdevice layer.
virtual Ptr< Packet > NotifyTxOpportunity(uint32_t bytes, Mac48Address utAddr, uint8_t flowId, uint32_t &bytesLeft, uint32_t &nextMinTxO)=0
Called from lower layer (MAC) to inform a Tx opportunity of certain amount of bytes.
virtual bool Enque(Ptr< Packet > packet, Address dest, uint8_t flowId)
Called from higher layer (SatNetDevice) to enque packet to LLC.
Mac48Address m_satelliteAddress
SAT address, used in case of network regeneration.
void AddDecap(Mac48Address source, Mac48Address dest, uint8_t flowId, Ptr< SatBaseEncapsulator > dec)
Add an decapsulator entry for the LLC.
bool m_rtnLinkArqEnabled
Is RTN link ARQ enabled.
virtual void Receive(Ptr< Packet > packet, Mac48Address source, Mac48Address dest)
Receive user data packet from lower layer.
virtual uint32_t GetNBytesInQueue(Mac48Address utAddress) const =0
Get the number of (new) bytes at LLC queue for a certain UT.
ReceiveCallback m_rxCallback
The upper layer package receive callback.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.