satellite-helper.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 #ifndef __SATELLITE_HELPER_H__
21 #define __SATELLITE_HELPER_H__
22 
23 #include "satellite-beam-helper.h"
25 #include "satellite-conf.h"
26 #include "satellite-group-helper.h"
27 #include "satellite-user-helper.h"
28 
29 #include <ns3/csma-helper.h>
30 #include <ns3/ipv4-address-helper.h>
31 #include <ns3/node-container.h>
32 #include <ns3/object.h>
33 #include <ns3/output-stream-wrapper.h>
34 #include <ns3/satellite-antenna-gain-pattern-container.h>
35 #include <ns3/satellite-fading-input-trace-container.h>
36 #include <ns3/satellite-fading-output-trace-container.h>
37 #include <ns3/satellite-interference-input-trace-container.h>
38 #include <ns3/satellite-interference-output-trace-container.h>
39 #include <ns3/satellite-position-allocator.h>
40 #include <ns3/satellite-rx-power-input-trace-container.h>
41 #include <ns3/satellite-rx-power-output-trace-container.h>
42 #include <ns3/satellite-stats-helper-container.h>
43 #include <ns3/trace-helper.h>
44 
45 #include <map>
46 #include <set>
47 #include <stdint.h>
48 #include <string>
49 #include <utility>
50 #include <vector>
51 
52 namespace ns3
53 {
54 
55 class SatGroupHelper;
56 
61 class SatHelper : public Object
62 {
63  public:
67  typedef std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> BeamUserInfoMap_t;
68 
73  typedef enum
74  {
75  NONE,
78  FULL
80 
85  static TypeId GetTypeId(void);
86 
91  TypeId GetInstanceTypeId(void) const;
92 
96  SatHelper();
97 
103  SatHelper(std::string scenarioPath);
104 
108  virtual ~SatHelper()
109  {
110  }
111 
116  typedef Callback<uint32_t> GetNextUtUserCountCallback;
117 
122 
129 
141  void CreateUserDefinedScenarioFromListPositions(uint32_t satId,
142  BeamUserInfoMap_t& info,
143  std::string inputFileUtListPositions,
144  bool checkBeam);
145 
153  GetNextUtUserCountCallback getNextUtUserCountCallback);
154 
159  void SetGwAddressInUts();
160 
165 
171  Ipv4Address GetUserAddress(Ptr<Node> node);
172 
176  Ptr<SatBeamHelper> GetBeamHelper() const;
177 
181  Ptr<SatGroupHelper> GetGroupHelper() const;
182 
186  void SetGroupHelper(Ptr<SatGroupHelper> groupHelper);
187 
192  void SetAntennaGainPatterns(Ptr<SatAntennaGainPatternContainer> antennaGainPattern);
193 
197  Ptr<SatAntennaGainPatternContainer> GetAntennaGainPatterns();
198 
202  Ptr<SatUserHelper> GetUserHelper() const;
203 
209  uint32_t GetBeamCount() const;
210 
215  void SetCustomUtPositionAllocator(Ptr<SatListPositionAllocator> posAllocator);
216 
223  void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr<SatListPositionAllocator> posAllocator);
224 
232  void LoadMobileUTsFromFolder(const std::string& folderName, Ptr<RandomVariableStream> utUsers);
233 
239  Ptr<Node> LoadMobileUtFromFile(const std::string& filename);
240 
247  Ptr<Node> LoadMobileUtFromFile(uint32_t satId, const std::string& filename);
248 
257  void SetMulticastGroupRoutes(Ptr<Node> source,
258  NodeContainer receivers,
259  Ipv4Address sourceAddress,
260  Ipv4Address groupAddress);
261 
265  void DoDispose();
266 
273  Ptr<SatSpotBeamPositionAllocator> GetBeamAllocator(uint32_t beamId);
274 
276  {
278  }
279 
280  private:
281  static const uint16_t MIN_ADDRESS_PREFIX_LENGTH = 1;
282  static const uint16_t MAX_ADDRESS_PREFIX_LENGTH = 31;
283 
286 
290  std::string m_scenarioPath;
291 
295  std::string m_rtnConfFileName;
296  std::string m_fwdConfFileName;
297  std::string m_gwPosFileName;
298  std::string m_satPosFileName;
299  std::string m_utPosFileName;
301 
306 
307  /*
308  * The global standard used. Can be either DVB or Lora
309  */
311 
315  Ptr<SatUserHelper> m_userHelper;
316 
320  Ptr<SatBeamHelper> m_beamHelper;
321 
325  Ptr<SatGroupHelper> m_groupHelper;
326 
330  Ptr<SatConf> m_satConf;
331 
335  TracedCallback<std::string> m_creationDetailsTrace;
336 
341  TracedCallback<std::string> m_creationSummaryTrace;
342 
346  Ptr<OutputStreamWrapper> m_creationTraceStream;
347 
351  Ptr<OutputStreamWrapper> m_utTraceStream;
352 
353  Ipv4Address
355  Ipv4Address
357  Ipv4Address m_utNetworkAddress;
358 
359  Ipv4Mask m_beamNetworkMask;
360  Ipv4Mask m_gwNetworkMask;
361  Ipv4Mask m_utNetworkMask;
362 
367 
372 
377 
382 
387 
391  uint32_t m_utsInBeam;
392 
396  uint32_t m_gwUsers;
397 
402  uint32_t m_utUsers;
403 
412 
417 
421  std::string m_utCreationFileName;
422 
426  std::string m_wfConfigFileName;
427 
431  Ptr<SatAntennaGainPatternContainer> m_antennaGainPatterns;
432 
437  std::map<uint32_t, Ptr<SatListPositionAllocator>> m_utPositionsByBeam;
438 
442  Ptr<SatListPositionAllocator> m_utPositions;
443 
447  std::map<uint32_t, NodeContainer> m_mobileUtsByBeam;
448 
452  std::multimap<uint32_t, uint32_t> m_mobileUtsUsersByBeam;
453 
457  std::map<uint32_t, uint32_t> m_gwSats;
458 
462  std::map<Ptr<NetDevice>, NetDeviceContainer> m_utsDistribution;
463 
467  void EnableCreationTraces();
468 
473 
477  void EnablePacketTrace();
478 
484  void LoadConstellationTopology(std::vector<std::string>& tles,
485  std::vector<std::pair<uint32_t, uint32_t>>& isls);
486 
493  static void CreationDetailsSink(Ptr<OutputStreamWrapper> stream,
494  std::string context,
495  std::string info);
500  void CreationSummarySink(std::string title);
504  void CreateSimpleScenario();
508  void CreateLargerScenario();
512  void CreateFullScenario();
513 
519  void DoCreateScenario(BeamUserInfoMap_t& info, uint32_t gwUsers);
520 
526  std::string CreateCreationSummary(std::string title);
527 
533  void SetGwMobility(NodeContainer gwNodes);
534 
540  void SetSatMobility(Ptr<Node> node);
541 
548  void SetSatMobility(Ptr<Node> node, std::string tle);
549 
558  void SetUtMobility(NodeContainer uts, uint32_t satId, uint32_t beamId);
559 
570  NodeContainer uts,
571  uint32_t satId,
572  uint32_t beamId,
573  std::vector<std::pair<GeoCoordinate, uint32_t>> positionsAndGroupId);
574 
581  void InstallMobilityObserver(uint32_t satId, NodeContainer nodes) const;
582 
591  Ptr<NetDevice> FindMatchingDevice(Ptr<NetDevice> devA, Ptr<Node> nodeB);
592 
594 
603  bool FindMatchingDevices(Ptr<Node> nodeA,
604  Ptr<Node> nodeB,
605  std::pair<Ptr<NetDevice>, Ptr<NetDevice>>& matchingDevices);
606 
617  void SetMulticastRouteToSourceNetwork(Ptr<Node> source, Ptr<Node> destination);
618 
629  bool ConstructMulticastInfo(Ptr<Node> sourceUtNode,
630  NodeContainer receivers,
631  MulticastBeamInfo_t& beamInfo,
632  Ptr<NetDevice>& routerUserOutputDev);
633 
637  void SetNetworkAddresses(BeamUserInfoMap_t& info, uint32_t gwUsers) const;
638 
648  void CheckNetwork(std::string networkName,
649  const Ipv4Address& firstNetwork,
650  const Ipv4Mask& mask,
651  const std::set<uint32_t>& networkAddresses,
652  uint32_t networkCount,
653  uint32_t hostCount) const;
654 
660  void ReadStandard(std::string pathName);
661 };
662 
663 } // namespace ns3
664 
665 #endif /* __SATELLITE_HELPER_H__ */
std::set< Ptr< Node > > MulticastBeamInfoItem_t
std::map< uint32_t, std::set< Ptr< Node > > > MulticastBeamInfo_t
Class that holds information for each beam regarding UTs and their users camped in each beam.
Standard_t
The global standard used.
Build a satellite network set with needed objects and configuration.
Ptr< SatUserHelper > GetUserHelper() const
void LoadConstellationTopology(std::vector< std::string > &tles, std::vector< std::pair< uint32_t, uint32_t >> &isls)
Load a constellation topology.
std::string m_waveformConfDirectoryName
void CreatePredefinedScenario(PreDefinedScenario_t scenario)
Create a pre-defined SatHelper to make life easier when creating Satellite topologies.
Ipv4Mask m_beamNetworkMask
Network mask number of satellite devices.
std::string m_utCreationFileName
File name for UT creation trace output.
SatHelper()
Default constructor.
static void CreationDetailsSink(Ptr< OutputStreamWrapper > stream, std::string context, std::string info)
Sink for creation details traces.
SatEnums::Standard_t m_standard
std::multimap< uint32_t, uint32_t > m_mobileUtsUsersByBeam
List of users by mobile UT by beam ID.
void SetUtMobilityFromPosition(NodeContainer uts, uint32_t satId, uint32_t beamId, std::vector< std::pair< GeoCoordinate, uint32_t >> positionsAndGroupId)
Sets mobility to created UT nodes when position is known.
Ptr< SatSpotBeamPositionAllocator > GetBeamAllocator(uint32_t beamId)
Create a SatSpotBeamPositionAllocator able to generate random position within the given beam.
Ipv4Address m_beamNetworkAddress
Initial network number of satellite devices, e.g., 10.1.1.0.
std::string m_wfConfigFileName
File name for Waveform configurations file.
void CreateLargerScenario()
Creates satellite objects according to larger scenario.
bool m_handoversEnabled
Enable handovers for all UTs and GWs.
void SetGwMobility(NodeContainer gwNodes)
Sets mobilities to created GW nodes.
Ipv4Address m_gwNetworkAddress
Initial network number of GW, router, and GW users, e.g., 10.2.1.0.
Callback< uint32_t > GetNextUtUserCountCallback
Get number of Users for a UT.
void CheckNetwork(std::string networkName, const Ipv4Address &firstNetwork, const Ipv4Mask &mask, const std::set< uint32_t > &networkAddresses, uint32_t networkCount, uint32_t hostCount) const
Check validity of the configured network space.
Ipv4Mask m_utNetworkMask
Network mask number of UT and UT users.
void InstallMobilityObserver(uint32_t satId, NodeContainer nodes) const
Install Satellite Mobility Observer to nodes, if observer doesn't exist already in a node.
void ReadStandard(std::string pathName)
Read to standard use from file given in path.
static TypeId GetTypeId(void)
Get the type ID.
void SetGwAddressInUts()
Set the value of GW address for each UT.
std::string m_scenarioCreationFileName
File name for scenario creation trace output.
BeamUserInfoMap_t m_beamUserInfos
Info for beam creation in user defined scenario.
void DoCreateScenario(BeamUserInfoMap_t &info, uint32_t gwUsers)
Creates satellite objects according to given beam info.
uint32_t m_utsInBeam
Number of UTs created per Beam in full or user-defined scenario.
std::string m_scenarioPath
Scenario folder path.
std::string m_gwPosFileName
Ipv4Address GetUserAddress(Ptr< Node > node)
void SetCustomUtPositionAllocator(Ptr< SatListPositionAllocator > posAllocator)
Set custom position allocator.
void SetGroupHelper(Ptr< SatGroupHelper > groupHelper)
set the group helper.
std::string m_fwdConfFileName
bool m_creationTraces
flag to indicate if creation trace should be enabled for scenario creation.
virtual ~SatHelper()
Destructor for SatHelper.
void SetBeamRoutingConstellations()
Populate the routes, when using constellations.
SatBeamHelper::MulticastBeamInfo_t MulticastBeamInfo_t
static const uint16_t MAX_ADDRESS_PREFIX_LENGTH
TypeId GetInstanceTypeId(void) const
Get the type ID of object instance.
Ptr< SatConf > m_satConf
Configuration for satellite network.
void SetAntennaGainPatterns(Ptr< SatAntennaGainPatternContainer > antennaGainPattern)
Set the antenna gain patterns.
Ptr< OutputStreamWrapper > m_creationTraceStream
Stream wrapper used for creation traces.
bool ConstructMulticastInfo(Ptr< Node > sourceUtNode, NodeContainer receivers, MulticastBeamInfo_t &beamInfo, Ptr< NetDevice > &routerUserOutputDev)
Construct multicast information from source UT node and group receivers.
std::string m_rtnConfFileName
Configuration file names as attributes of this class.
void LoadConstellationScenario(BeamUserInfoMap_t &info, GetNextUtUserCountCallback getNextUtUserCountCallback)
Load satellite objects according to constellation parameters.
bool m_packetTraces
flag to indicate if packet trace should be enabled after scenario creation.
void SetSatMobility(Ptr< Node > node)
Sets mobility to created Sat node.
PreDefinedScenario_t
Values for pre-defined scenarios to be used by helper when building satellite network topology base.
@ LARGER
LARGER Larger scenario used as base.
@ NONE
NONE Not used.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
Ptr< SatAntennaGainPatternContainer > GetAntennaGainPatterns()
TracedCallback< std::string > m_creationSummaryTrace
Trace callback for creation traces (summary)
bool IsSatConstellationEnabled()
void SetUtMobility(NodeContainer uts, uint32_t satId, uint32_t beamId)
Sets mobility to created UT nodes.
void EnableCreationTraces()
Enables creation traces to be written in given file.
bool m_detailedCreationTraces
flag to indicate if detailed creation trace should be enabled for scenario creation.
void CreationSummarySink(std::string title)
Sink for creation summary traces.
std::string CreateCreationSummary(std::string title)
Creates trace summary starting with give title.
Ptr< OutputStreamWrapper > m_utTraceStream
Stream wrapper used for UT position traces.
Ptr< SatUserHelper > m_userHelper
User helper.
void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr< SatListPositionAllocator > posAllocator)
Set custom position allocator for specific beam.
void EnablePacketTrace()
Enable packet traces.
uint32_t GetBeamCount() const
Get count of the beams (configurations).
SatBeamHelper::MulticastBeamInfoItem_t MulticastBeamInfoItem_t
Ptr< SatAntennaGainPatternContainer > m_antennaGainPatterns
Antenna gain patterns for all spot-beams.
void CreateFullScenario()
Creates satellite objects according to full scenario.
std::map< uint32_t, NodeContainer > m_mobileUtsByBeam
List of mobile UTs by beam ID.
Ptr< SatGroupHelper > GetGroupHelper() const
void CreateSimpleScenario()
Creates satellite objects according to simple scenario.
bool m_scenarioCreated
flag to check if scenario is already created.
Ptr< SatGroupHelper > m_groupHelper
Group helper.
std::string m_satPosFileName
void SetNetworkAddresses(BeamUserInfoMap_t &info, uint32_t gwUsers) const
Set configured network addresses to user and beam helpers.
void CreateUserDefinedScenarioFromListPositions(uint32_t satId, BeamUserInfoMap_t &info, std::string inputFileUtListPositions, bool checkBeam)
Creates satellite objects according to user defined scenario.
void SetMulticastRouteToSourceNetwork(Ptr< Node > source, Ptr< Node > destination)
Set multicast traffic to source's nwtwork by finding source network utilizing given destination node.
void LoadMobileUTsFromFolder(const std::string &folderName, Ptr< RandomVariableStream > utUsers)
Load UTs with a SatTracedMobilityModel associated to them from the files found in the given folder.
Ipv4Address m_utNetworkAddress
Initial network number of UT and UT users, e.g., 10.3.1.0.
uint32_t m_utUsers
Number of users created in end user network (behind every UT) in full or user-defined scenario.
Ptr< NetDevice > FindMatchingDevice(Ptr< NetDevice > devA, Ptr< Node > nodeB)
Find given device's counterpart (device belonging to same network) device from given node.
TracedCallback< std::string > m_creationDetailsTrace
Trace callback for creation traces (details)
std::map< std::pair< uint32_t, uint32_t >, SatBeamUserInfo > BeamUserInfoMap_t
definition for beam map key is pair sat ID / beam ID and value is UT/user info.
static const uint16_t MIN_ADDRESS_PREFIX_LENGTH
std::map< uint32_t, Ptr< SatListPositionAllocator > > m_utPositionsByBeam
User defined UT positions by beam ID.
Ipv4Mask m_gwNetworkMask
Network mask number of GW, router, and GW users.
bool FindMatchingDevices(Ptr< Node > nodeA, Ptr< Node > nodeB, std::pair< Ptr< NetDevice >, Ptr< NetDevice >> &matchingDevices)
Find counterpart (device belonging to same network) devices from given nodes.
Ptr< SatBeamHelper > m_beamHelper
Beam helper.
void CreateUserDefinedScenario(BeamUserInfoMap_t &info)
Creates satellite objects according to user defined scenario.
Ptr< Node > LoadMobileUtFromFile(const std::string &filename)
Load an UT with a SatTracedMobilityModel associated to them from the given file.
void DoDispose()
Dispose of this class instance.
std::map< Ptr< NetDevice >, NetDeviceContainer > m_utsDistribution
Map indicating all UT NetDevices associated to each GW NetDevice.
std::map< uint32_t, uint32_t > m_gwSats
Map of closest satellite for each GW.
std::string m_utPosFileName
void SetMulticastGroupRoutes(Ptr< Node > source, NodeContainer receivers, Ipv4Address sourceAddress, Ipv4Address groupAddress)
Set multicast group to satellite network and IP router.
uint32_t m_gwUsers
Number of users created in public network (behind GWs) in full or user-defined scenario.
Ptr< SatBeamHelper > GetBeamHelper() const
bool m_satConstellationEnabled
Use a constellation of satellites.
void EnableDetailedCreationTraces()
Enables creation traces in sub-helpers.
Ptr< SatListPositionAllocator > m_utPositions
User defined UT positions from SatConf (or manually set)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.