satellite-mac.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 SAT_MAC_H
22 #define SAT_MAC_H
23 
25 #include "satellite-node-info.h"
26 #include "satellite-phy.h"
27 #include "satellite-queue.h"
29 
30 #include <ns3/address.h>
31 #include <ns3/callback.h>
32 #include <ns3/mac48-address.h>
33 #include <ns3/ptr.h>
34 #include <ns3/traced-callback.h>
35 
36 #include <cstring>
37 
38 namespace ns3
39 {
40 
41 class Packet;
42 
51 class SatMac : public Object
52 {
53  public:
57  static TypeId GetTypeId(void);
58 
65  SatMac();
66 
74  SatMac(uint32_t satId,
75  uint32_t beamId,
76  SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
77  SatEnums::RegenerationMode_t returnLinkRegenerationMode);
78 
84  ~SatMac();
85 
90  inline uint32_t GetSatId() const
91  {
92  return m_satId;
93  }
94 
99  inline uint32_t GetBeamId() const
100  {
101  return m_beamId;
102  }
103 
108  inline Address GetAddress() const
109  {
110  return m_nodeInfo->GetMacAddress();
111  }
112 
119  typedef Callback<void, SatPhy::PacketContainer_t, uint32_t, Time, SatSignalParameters::txInfo_s>
121 
128 
135  typedef Callback<void, Ptr<Packet>, Mac48Address, Mac48Address> ReceiveCallback;
136 
141  typedef Callback<void, Ptr<const Packet>> LoraReceiveCallback;
142 
149 
156 
163  typedef Callback<Ptr<SatControlMessage>, uint32_t> ReadCtrlMsgCallback;
164 
171  typedef Callback<uint32_t, Ptr<SatControlMessage>> ReserveCtrlMsgCallback;
172 
178  typedef Callback<uint32_t, uint32_t> SendCtrlMsgCallback;
179 
185 
192 
198 
204  typedef Callback<void, Address, Address> RoutingUpdateCallback;
205 
211 
216  virtual void SetNodeInfo(Ptr<SatNodeInfo> nodeInfo);
217 
224  uint32_t ReserveIdAndStoreCtrlMsgToContainer(Ptr<SatControlMessage> msg);
225 
232  uint32_t SendCtrlMsgFromContainer(uint32_t sendId);
233 
241  virtual void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t flowIndex);
242 
247  virtual void Enable();
248 
253  virtual void Disable();
254 
258  virtual void SetSatelliteAddress(Address satelliteAddress);
259 
260  private:
262  SatMac(const SatMac&);
263 
264  protected:
268  void DoDispose(void);
269 
275 
283  virtual void SendPacket(SatPhy::PacketContainer_t packets,
284  uint32_t carrierId,
285  Time duration,
287 
292  void RxTraces(SatPhy::PacketContainer_t packets);
293 
298 
303 
308 
313 
318 
323 
328 
334  bool m_ncrV2;
335 
339  TracedCallback<Time,
342  uint32_t,
343  Mac48Address,
346  std::string>
348 
353  TracedCallback<Ptr<const Packet>, const Address&> m_rxTrace;
354 
359  TracedCallback<const Time&, const Address&> m_rxDelayTrace;
360 
365  TracedCallback<const Time&, const Address&> m_rxLinkDelayTrace;
366 
371  TracedCallback<const Time&, const Address&> m_rxJitterTrace;
372 
377  TracedCallback<const Time&, const Address&> m_rxLinkJitterTrace;
378 
382  TracedCallback<Time> m_beamServiceTrace;
383 
388 
393  Ptr<SatNodeInfo> m_nodeInfo;
394 
398  uint32_t m_satId;
399 
403  uint32_t m_beamId;
404 
411 
416 
421 
425  std::queue<Ptr<SatNcrMessage>> m_ncrMessagesToSend;
426 
430  std::queue<Time> m_lastSOF;
431 
436 
441 
446 
451 
456 };
457 
458 } // namespace ns3
459 
460 #endif /* SAT_MAC_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.
Base MAC class for SatNetDevices.
Definition: satellite-mac.h:52
TracedCallback< const Time &, const Address & > m_rxJitterTrace
Traced callback for all received packets, including jitter information and the address of the senders...
uint32_t GetBeamId() const
Get beam ID of the object.
Definition: satellite-mac.h:99
SatMac::TransmitCallback m_txCallback
The lower layer packet transmit callback.
void RxTraces(SatPhy::PacketContainer_t packets)
Invoke the Rx trace source for each received packet.
uint32_t ReserveIdAndStoreCtrlMsgToContainer(Ptr< SatControlMessage > msg)
Reserve id and store the control message.
TracedCallback< Time > m_beamServiceTrace
Traced callback for beam being disabled and including service time.
uint32_t m_beamId
The ID of the beam where mac belongs.
static TypeId GetTypeId(void)
Derived from Object.
void SetReserveCtrlCallback(SatMac::ReserveCtrlMsgCallback cb)
Method to set reserve control message id callback.
virtual void SetSatelliteAddress(Address satelliteAddress)
Set the satellite MAC address on the other side of this link (if regenerative satellite).
Callback< void, SatPhy::PacketContainer_t, uint32_t, Time, SatSignalParameters::txInfo_s > TransmitCallback
Callback to send packet to lower layer.
Address GetAddress() const
Get MAC address.
void SetTransmitCallback(SatMac::TransmitCallback cb)
Method to set transmit callback.
bool m_isStatisticsTagsEnabled
EnableStatisticsTags attribute.
Time m_beamEnabledTime
Time of the last beam enable event.
SatMac::RoutingUpdateCallback m_routingUpdateCallback
Callback to update routing and ARP tables after a beam handover.
std::queue< Ptr< SatNcrMessage > > m_ncrMessagesToSend
List of NCR control messages created but not sent yet.
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.
SatMac::SendCtrlMsgCallback m_sendCtrlCallback
The send control message callback.
void SetTimeTag(SatPhy::PacketContainer_t packets)
Set SatMacTimeTag of packets.
Callback< uint32_t, Ptr< SatControlMessage > > ReserveCtrlMsgCallback
Callback to reserve an id and initially store the control message.
Address m_satelliteAddress
MAC address of satellite on other side of the link.
virtual void Enable()
Enable the MAC layer, i.e.
SatMac::LoraReceiveCallback m_rxLoraCallback
The upper layer package receive callback.
void SetSendCtrlCallback(SatMac::SendCtrlMsgCallback cb)
Method to set send control message callback.
virtual void SetNodeInfo(Ptr< SatNodeInfo > nodeInfo)
Set the node info.
uint32_t GetSatId() const
Get sat ID of the object.
Definition: satellite-mac.h:90
void DoDispose(void)
Dispose of SatMac.
virtual void ReceiveQueueEvent(SatQueue::QueueEvent_t event, uint8_t flowIndex)
Receive a queue event:
TracedCallback< const Time &, const Address & > m_rxLinkJitterTrace
Traced callback for all received packets, including link jitter information and the address of the se...
TracedCallback< const Time &, const Address & > m_rxDelayTrace
Traced callback for all received packets, including delay information and the address of the senders.
Time m_lastDelay
Last delay measurement.
Callback< void, Ptr< const Packet > > LoraReceiveCallback
Callback to receive packet by upper layer.
~SatMac()
Destroy a SatMac.
void SetRoutingUpdateCallback(SatMac::RoutingUpdateCallback cb)
Method to set the routing update callback.
SatMac::ReceiveCallback m_rxCallback
The upper layer package receive callback.
bool m_ncrV2
Use of version 2 of NCR dates.
SatMac & operator=(const SatMac &)
bool m_isRegenerative
Indicate if satellite is regeneration (at least LINK level) for TX.
Callback< void, Address, Address > RoutingUpdateCallback
Callback to update routing and ARP tables after handover.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced callback for all received packets, including the address of the senders.
Callback< void, Ptr< Packet >, Mac48Address, Mac48Address > ReceiveCallback
Callback to receive packet by upper layer.
void SetReadCtrlCallback(SatMac::ReadCtrlMsgCallback cb)
Method to set read control message callback.
bool m_txEnabled
Flag indicating whether the MAC is enabled, i.e.
TracedCallback< const Time &, const Address & > m_rxLinkDelayTrace
Traced callback for all received packets, including link delay information and the address of the sen...
SatMac::ReadCtrlMsgCallback m_readCtrlCallback
The read control message callback.
Callback< uint32_t, uint32_t > SendCtrlMsgCallback
Callback to send a control message and allocate a recv ID for it.
SatMac()
Construct a SatMac.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
Regeneration mode on forward link.
Ptr< SatNodeInfo > m_nodeInfo
Node info containing node related information, such as node type, node id and MAC address (of the Sat...
void SetLoraReceiveCallback(SatMac::LoraReceiveCallback cb)
Method to set receive callback.
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
Regeneration mode on return link.
uint32_t SendCtrlMsgFromContainer(uint32_t sendId)
Send the control message from the container.
Time m_lastLinkDelay
Last delay measurement for link.
Callback< Ptr< SatControlMessage >, uint32_t > ReadCtrlMsgCallback
Callback to read control messages from container storing control messages.
void SetReceiveCallback(SatMac::ReceiveCallback cb)
Method to set receive callback.
SatMac::ReserveCtrlMsgCallback m_reserveCtrlCallback
The reserve control message id callback.
uint32_t m_satId
The ID of the sat where mac belongs.
virtual void Disable()
Disable the MAC layer, i.e.
virtual void SendPacket(SatPhy::PacketContainer_t packets, uint32_t carrierId, Time duration, SatSignalParameters::txInfo_s txInfo)
Send packets to lower layer by using a callback.
SatMac(const SatMac &)
std::queue< Time > m_lastSOF
Store last 3 SOF date for Forward messages, to insert in NCR packets.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
Definition: satellite-phy.h:78
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Struct for storing the packet specific Tx information.