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/trace-helper.h>
43 
44 #include <string>
45 
46 namespace ns3
47 {
48 
49 class SatGroupHelper;
50 
55 class SatHelper : public Object
56 {
57  public:
61  typedef std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> BeamUserInfoMap_t;
62 
67  typedef enum
68  {
69  NONE,
72  FULL
74 
79  static TypeId GetTypeId(void);
80 
85  TypeId GetInstanceTypeId(void) const;
86 
90  SatHelper();
91 
95  SatHelper(std::string scenarioName);
96 
100  virtual ~SatHelper()
101  {
102  }
103 
108  typedef Callback<uint32_t> GetNextUtUserCountCallback;
109 
114 
121 
132  void CreateUserDefinedScenarioFromListPositions(uint32_t satId,
133  BeamUserInfoMap_t& info,
134  bool checkBeam);
135 
143  GetNextUtUserCountCallback getNextUtUserCountCallback);
144 
149  void SetGwAddressInUt();
150 
155 
161  uint32_t GetClosestSat(GeoCoordinate position);
162 
168  Ipv4Address GetUserAddress(Ptr<Node> node);
169 
173  NodeContainer GetUtUsers() const;
174 
179  NodeContainer GetUtUsers(Ptr<Node> utNode) const;
180 
185  NodeContainer GetUtUsers(NodeContainer utNodes) const;
186 
190  NodeContainer GetGwUsers() const;
191 
195  Ptr<SatBeamHelper> GetBeamHelper() const;
196 
200  Ptr<SatGroupHelper> GetGroupHelper() const;
201 
205  void SetGroupHelper(Ptr<SatGroupHelper> groupHelper);
206 
211  void SetAntennaGainPatterns(Ptr<SatAntennaGainPatternContainer> antennaGainPattern);
212 
216  Ptr<SatAntennaGainPatternContainer> GetAntennaGainPatterns();
217 
221  Ptr<SatUserHelper> GetUserHelper() const;
222 
228  uint32_t GetBeamCount() const;
229 
234  void SetCustomUtPositionAllocator(Ptr<SatListPositionAllocator> posAllocator);
235 
242  void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr<SatListPositionAllocator> posAllocator);
243 
252  void LoadMobileUTsFromFolder(uint32_t satId,
253  const std::string& folderName,
254  Ptr<RandomVariableStream> utUsers);
255 
262  Ptr<Node> LoadMobileUtFromFile(uint32_t satId, const std::string& filename);
263 
272  void SetMulticastGroupRoutes(Ptr<Node> source,
273  NodeContainer receivers,
274  Ipv4Address sourceAddress,
275  Ipv4Address groupAddress);
276 
277  inline NodeContainer GwNodes()
278  {
279  return m_beamHelper->GetGwNodes();
280  }
281 
282  inline NodeContainer UtNodes()
283  {
284  return m_beamHelper->GetUtNodes();
285  }
286 
287  inline NodeContainer GeoSatNodes()
288  {
289  return m_beamHelper->GetGeoSatNodes();
290  }
291 
295  void DoDispose();
296 
303  Ptr<SatSpotBeamPositionAllocator> GetBeamAllocator(uint32_t beamId);
304 
306  {
308  }
309 
314  void PrintTopology(std::ostream& os) const;
315 
316  private:
317  static const uint16_t MIN_ADDRESS_PREFIX_LENGTH = 1;
318  static const uint16_t MAX_ADDRESS_PREFIX_LENGTH = 31;
319 
322 
326  std::string m_rtnConfFileName;
327  std::string m_fwdConfFileName;
328  std::string m_gwPosFileName;
329  std::string m_geoPosFileName;
331 
336 
341 
346 
351 
352  /*
353  * The global standard used. Can be either DVB or Lora
354  */
356 
360  Ptr<SatUserHelper> m_userHelper;
361 
365  Ptr<SatBeamHelper> m_beamHelper;
366 
370  Ptr<SatGroupHelper> m_groupHelper;
371 
375  NodeContainer m_gwUser;
376 
380  Ptr<SatConf> m_satConf;
381 
385  TracedCallback<std::string> m_creationDetailsTrace;
386 
391  TracedCallback<std::string> m_creationSummaryTrace;
392 
396  Ptr<OutputStreamWrapper> m_creationTraceStream;
397 
401  Ptr<OutputStreamWrapper> m_utTraceStream;
402 
403  Ipv4Address
405  Ipv4Address
407  Ipv4Address m_utNetworkAddress;
408 
409  Ipv4Mask m_beamNetworkMask;
410  Ipv4Mask m_gwNetworkMask;
411  Ipv4Mask m_utNetworkMask;
412 
417 
422 
427 
432 
436  uint32_t m_utsInBeam;
437 
441  uint32_t m_gwUsers;
442 
447  uint32_t m_utUsers;
448 
457 
462 
466  std::string m_utCreationFileName;
467 
471  std::string m_wfConfigFileName;
472 
476  Ptr<SatAntennaGainPatternContainer> m_antennaGainPatterns;
477 
482  std::map<uint32_t, Ptr<SatListPositionAllocator>> m_utPositionsByBeam;
483 
487  Ptr<SatListPositionAllocator> m_utPositions;
488 
492  std::map<uint32_t, NodeContainer> m_mobileUtsByBeam;
493 
497  std::multimap<uint32_t, uint32_t> m_mobileUtsUsersByBeam;
498 
502  std::map<uint32_t, uint32_t> m_gwSats;
503 
507  std::map<Ptr<Node>, Ptr<Node>> m_gwDistribution;
508 
512  std::map<Ptr<NetDevice>, NetDeviceContainer> m_utsDistribution;
513 
517  void EnableCreationTraces();
518 
523 
527  void EnablePacketTrace();
528 
535  void LoadConstellationTopology(std::string path,
536  std::vector<std::string>& tles,
537  std::vector<std::pair<uint32_t, uint32_t>>& isls);
538 
545  static void CreationDetailsSink(Ptr<OutputStreamWrapper> stream,
546  std::string context,
547  std::string info);
552  void CreationSummarySink(std::string title);
556  void CreateSimpleScenario();
560  void CreateLargerScenario();
564  void CreateFullScenario();
565 
571  void DoCreateScenario(BeamUserInfoMap_t& info, uint32_t gwUsers);
572 
578  std::string CreateCreationSummary(std::string title);
579 
587  void SetGwMobility(uint32_t satId, Ptr<Node> gw, uint32_t gwIndex);
588 
594  void SetGeoSatMobility(Ptr<Node> node);
595 
601  void SetSatMobility(Ptr<Node> node, std::string tle = "");
602 
611  void SetUtMobility(NodeContainer uts, uint32_t satId, uint32_t beamId);
612 
623  NodeContainer uts,
624  uint32_t satId,
625  uint32_t beamId,
626  std::vector<std::pair<GeoCoordinate, uint32_t>> positionsAndGroupId);
627 
634  void InstallMobilityObserver(uint32_t satId, NodeContainer nodes) const;
635 
644  Ptr<NetDevice> FindMatchingDevice(Ptr<NetDevice> devA, Ptr<Node> nodeB);
645 
647 
656  bool FindMatchingDevices(Ptr<Node> nodeA,
657  Ptr<Node> nodeB,
658  std::pair<Ptr<NetDevice>, Ptr<NetDevice>>& matchingDevices);
659 
670  void SetMulticastRouteToSourceNetwork(Ptr<Node> source, Ptr<Node> destination);
671 
682  bool ConstructMulticastInfo(Ptr<Node> sourceUtNode,
683  NodeContainer receivers,
684  MulticastBeamInfo_t& beamInfo,
685  Ptr<NetDevice>& routerUserOutputDev);
686 
690  void SetNetworkAddresses(BeamUserInfoMap_t& info, uint32_t gwUsers) const;
691 
701  void CheckNetwork(std::string networkName,
702  const Ipv4Address& firstNetwork,
703  const Ipv4Mask& mask,
704  const std::set<uint32_t>& networkAddresses,
705  uint32_t networkCount,
706  uint32_t hostCount) const;
707 };
708 
709 } // namespace ns3
710 
711 #endif /* __SATELLITE_HELPER_H__ */
GeoCoordinate class is used to store and operate with geodetic coordinates.
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.
void PrintTopology(std::ostream &os) const
Print all the satellite topology.
void CreateConstellationScenario(BeamUserInfoMap_t &info, GetNextUtUserCountCallback getNextUtUserCountCallback)
Creates satellite objects according to constellation parameters.
void LoadMobileUTsFromFolder(uint32_t satId, const std::string &folderName, Ptr< RandomVariableStream > utUsers)
Load UTs with a SatTracedMobilityModel associated to them from the files found in the given folder.
void LoadConstellationTopology(std::string path, std::vector< std::string > &tles, std::vector< std::pair< uint32_t, uint32_t >> &isls)
Load a constellation topology.
Ptr< SatUserHelper > GetUserHelper() const
void CreatePredefinedScenario(PreDefinedScenario_t scenario)
Create a pre-defined SatHelper to make life easier when creating Satellite topologies.
Ptr< Node > LoadMobileUtFromFile(uint32_t satId, const std::string &filename)
Load an UT with a SatTracedMobilityModel associated to them from the given file.
Ipv4Mask m_beamNetworkMask
Network mask number of satellite devices.
std::string m_utCreationFileName
File name for UT creation trace output.
SatHelper()
Create a base SatHelper for creating customized Satellite topologies.
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.
NodeContainer m_gwUser
Gateway container.
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.
static TypeId GetTypeId(void)
Get the type ID.
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.
bool m_satMobilitySGP4Enabled
The satellite moves following a SGP4 model.
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
NodeContainer GwNodes()
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
std::map< Ptr< Node >, Ptr< Node > > m_gwDistribution
Map indicating the GW node associated to each UT node.
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.
bool m_packetTraces
flag to indicate if packet trace should be enabled after scenario creation.
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.
void SetGwMobility(uint32_t satId, Ptr< Node > gw, uint32_t gwIndex)
Sets mobilities to created GW nodes.
Ptr< SatUserHelper > m_userHelper
User helper.
NodeContainer GetGwUsers() const
SatHelper(std::string scenarioName)
Create a base SatHelper for creating customized Satellite topologies.
std::string m_geoPosFileName
NodeContainer UtNodes()
void SetUtPositionAllocatorForBeam(uint32_t beamId, Ptr< SatListPositionAllocator > posAllocator)
Set custom position allocator for specific beam.
void EnablePacketTrace()
Enable packet traces.
void SetGeoSatMobility(Ptr< Node > node)
Sets mobility to created Sat Geo node.
uint32_t GetBeamCount() const
Get count of the beams (configurations).
SatBeamHelper::MulticastBeamInfoItem_t MulticastBeamInfoItem_t
void CreateUserDefinedScenarioFromListPositions(uint32_t satId, BeamUserInfoMap_t &info, bool checkBeam)
Creates satellite objects according to user defined scenario.
void SetSatMobility(Ptr< Node > node, std::string tle="")
Sets SGP4 mobility to created Sat node.
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.
void SetNetworkAddresses(BeamUserInfoMap_t &info, uint32_t gwUsers) const
Set configured network addresses to user and beam helpers.
void SetMulticastRouteToSourceNetwork(Ptr< Node > source, Ptr< Node > destination)
Set multicast traffic to source's nwtwork by finding source network utilizing given destination node.
Ipv4Address m_utNetworkAddress
Initial network number of UT and UT users, e.g., 10.3.1.0.
uint32_t GetClosestSat(GeoCoordinate position)
Get closest satellite to a ground station.
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.
void SetGwAddressInUt()
Set the value of GW address for each UT.
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.
NodeContainer GetUtUsers() const
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.
std::string m_waveformConfFileName
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.
std::string m_satMobilitySGP4TleFileName
TLE input filename used for SGP4 mobility.
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.
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.
std::string m_satConstellationFolder
Folder where are stored satellite constellation data.
NodeContainer GeoSatNodes()
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.