satellite-group-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  * Copyright (c) 2018 CNES
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Bastien Tauran <bastien.tauran@viveris.fr>
20  */
21 
22 #ifndef SATELLITE_GROUP_HELPER_H
23 #define SATELLITE_GROUP_HELPER_H
24 
25 #include <ns3/geo-coordinate.h>
26 #include <ns3/mobility-helper.h>
27 #include <ns3/node-container.h>
28 #include <ns3/satellite-handover-module.h>
29 #include <ns3/satellite-mobility-model.h>
30 #include <ns3/satellite-position-allocator.h>
31 #include <ns3/vector.h>
32 
33 #include <algorithm>
34 #include <list>
35 #include <map>
36 #include <set>
37 #include <stdint.h>
38 #include <utility>
39 #include <vector>
40 
41 namespace ns3
42 {
43 
44 class SatHelper;
45 
49 class SatGroupHelper : public Object
50 {
51  public:
56  static TypeId GetTypeId(void);
57 
62  virtual TypeId GetInstanceTypeId(void) const;
63 
68 
72  virtual ~SatGroupHelper()
73  {
74  }
75 
79  void Init();
80 
86  void AddUtNodeToGroup(uint32_t groupId, Ptr<Node> node);
87 
93  void AddUtNodesToGroup(uint32_t groupId, NodeContainer nodes);
94 
102  void CreateGroupFromPosition(uint32_t groupId,
103  NodeContainer nodes,
104  GeoCoordinate center,
105  uint32_t radius);
106 
112  void CreateGroupsUniformly(std::vector<uint32_t> groupIds, NodeContainer nodes);
113 
120  void CreateUtNodesFromPosition(uint32_t groupId,
121  uint32_t nb,
122  GeoCoordinate center,
123  uint32_t radius);
124 
131  void AddNodeToGroupAfterScenarioCreation(uint32_t groupId, Ptr<Node> node);
132 
137  std::vector<std::pair<GeoCoordinate, uint32_t>> GetAdditionalNodesPerBeam();
138 
143  NodeContainer GetUtNodes(uint32_t groupId) const;
144 
149  uint32_t GetN();
150 
155  std::list<uint32_t> GetGroups();
156 
160  virtual void DoDispose();
161 
163 
164  private:
170  bool IsGroupExisting(uint32_t groupId) const;
171 
177  uint32_t GetGroupId(Ptr<Node> node) const;
178 
184  NodeContainer GetNodesNotAddedFromPosition(NodeContainer nodes);
185 
189  std::map<uint32_t, std::set<Ptr<Node>>> m_groupsMap;
190 
194  std::list<uint32_t> m_groupsList;
195 
199  std::vector<std::pair<GeoCoordinate, uint32_t>> m_additionalNodesPerBeam;
200 
201  /*
202  * Map to store node to add to groups after scenario is created
203  */
204  std::map<Ptr<Node>, uint32_t> m_nodesToAdd;
205 
206  /*
207  * Tells if the scenario has been created by simulation helper.
208  * Some methods have to be called before, some after.
209  */
211 
216 };
217 
218 } // namespace ns3
219 
220 #endif /* SATELLITE_GROUP_HELPER_H */
GeoCoordinate class is used to store and operate with geodetic coordinates.
This helper is used to create groups of UTs.
std::list< uint32_t > GetGroups()
Get the list of groups created.
virtual void DoDispose()
Dispose of this class instance.
NodeContainer GetUtNodes(uint32_t groupId) const
uint32_t GetN()
Count the number of groups created.
void AddUtNodesToGroup(uint32_t groupId, NodeContainer nodes)
Add several nodes to a group.
void Init()
Initialize the helper.
void CreateUtNodesFromPosition(uint32_t groupId, uint32_t nb, GeoCoordinate center, uint32_t radius)
Create a new group using a central position and a radius, and create UT nodes inside this area.
static TypeId GetTypeId(void)
Get the type ID.
std::map< Ptr< Node >, uint32_t > m_nodesToAdd
std::map< uint32_t, std::set< Ptr< Node > > > m_groupsMap
Container to associate nodes to the groups.
void AddNodeToGroupAfterScenarioCreation(uint32_t groupId, Ptr< Node > node)
Schedule a node to be added to a group when scenario creation is finished.
std::list< uint32_t > m_groupsList
List of group ID created.
virtual ~SatGroupHelper()
Destructor for SatGroupHelper.
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
bool m_satConstellationEnabled
Use a constellation of satellites.
void CreateGroupsUniformly(std::vector< uint32_t > groupIds, NodeContainer nodes)
Create several groups and distribute nodes among them.
NodeContainer GetNodesNotAddedFromPosition(NodeContainer nodes)
Get list of nodes not created from position by group helper.
bool IsGroupExisting(uint32_t groupId) const
Tells if the groupId is already existing in the database.
std::vector< std::pair< GeoCoordinate, uint32_t > > GetAdditionalNodesPerBeam()
Get the position of nodes to add to the scenario.
SatGroupHelper()
Default constructor for SatGroupHelper.
uint32_t GetGroupId(Ptr< Node > node) const
Get the group to which a node belongs.
void CreateGroupFromPosition(uint32_t groupId, NodeContainer nodes, GeoCoordinate center, uint32_t radius)
Create a new group using a central position and a radius.
std::vector< std::pair< GeoCoordinate, uint32_t > > m_additionalNodesPerBeam
Nodes created by position to add to scenario.
void AddUtNodeToGroup(uint32_t groupId, Ptr< Node > node)
Add a node to a group.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.