satellite-user-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: Sami Rantanen <sami.rantanen@magister.fi>
20  * Author: Mathias Ettinger <mettinger@toulouse.viveris.com>
21  */
22 
23 #ifndef SAT_USER_HELPER_H
24 #define SAT_USER_HELPER_H
25 
26 #include "ns3/csma-helper.h"
27 #include "ns3/ipv4-address-helper.h"
28 #include "ns3/node-container.h"
29 #include "ns3/satellite-enums.h"
30 #include "ns3/traced-callback.h"
31 
32 #include <map>
33 #include <set>
34 #include <stdint.h>
35 #include <string>
36 
37 namespace ns3
38 {
39 
40 class PropagationDelayModel;
41 class SatArpCache;
42 class NetDevice;
43 class Node;
44 
49 class SatUserHelper : public Object
50 {
51  public:
56  {
59  };
60 
64  typedef std::map<Ptr<Node>, NodeContainer> UtUsersContainer_t;
65 
69  static TypeId GetTypeId(void);
70 
74  TypeId GetInstanceTypeId(void) const;
79  SatUserHelper();
80  virtual ~SatUserHelper();
81 
99  void SetCsmaQueue(std::string type,
100  std::string name1 = "",
101  const AttributeValue& value1 = EmptyAttributeValue(),
102  std::string name2 = "",
103  const AttributeValue& value2 = EmptyAttributeValue(),
104  std::string name3 = "",
105  const AttributeValue& value3 = EmptyAttributeValue(),
106  std::string name4 = "",
107  const AttributeValue& value4 = EmptyAttributeValue());
108 
119  void SetCsmaDeviceAttribute(std::string name, const AttributeValue& value);
120 
131  void SetCsmaChannelAttribute(std::string name, const AttributeValue& value);
132 
144  void SetUtBaseAddress(const Ipv4Address& network,
145  const Ipv4Mask& mask,
146  Ipv4Address base = "0.0.0.1");
147 
159  void SetGwBaseAddress(const Ipv4Address& network,
160  const Ipv4Mask& mask,
161  Ipv4Address base = "0.0.0.1");
162 
174  void SetBeamBaseAddress(const Ipv4Address& network,
175  const Ipv4Mask& mask,
176  Ipv4Address base = "0.0.0.1");
177 
189  NodeContainer InstallUt(NodeContainer ut, uint32_t users);
190 
202  NodeContainer InstallUt(Ptr<Node> ut, uint32_t users);
203 
214  void InstallGw(uint32_t users);
215 
222  bool IsGwUser(Ptr<Node> node) const;
223 
230  void EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb);
231 
237  std::string GetRouterInfo() const;
238 
242  Ptr<Node> GetRouter() const;
243 
251  void PopulateBeamRoutings(NodeContainer ut,
252  NetDeviceContainer utNd,
253  Ptr<Node> gw,
254  Ptr<NetDevice> gwNd);
255 
264  void UpdateUtRoutes(Address ut, Address newGateway);
265 
273  void UpdateGwRoutes(Address ut, Address oldGateway, Address newGateway);
274 
275  typedef Callback<Ptr<PropagationDelayModel>, uint32_t, uint32_t, SatEnums::ChannelType_t>
277 
278  private:
285  NetDeviceContainer InstallSubscriberNetwork(const NodeContainer& c) const;
286 
293  NetDeviceContainer InstallBackboneNetwork(const NodeContainer& c) const;
294 
301  NetDeviceContainer InstallSatSimpleNetwork(const NodeContainer& c) const;
302 
308  void InstallRouter(Ptr<Node> router);
309 
310  CsmaHelper m_csma;
311  Ipv4AddressHelper m_ipv4Ut;
312  Ipv4AddressHelper m_ipv4Gw;
313  Ipv4AddressHelper m_ipv4Beam;
314 
317 
318  Ptr<Node> m_router;
319 
332  std::map<Ptr<Node>, Ptr<Node>> m_utMap;
333 
337  TracedCallback<std::string> m_creationTrace;
338 
344  std::map<Address, Ptr<NetDevice>> m_utDevices;
345 
351  std::map<Address, Ptr<NetDevice>> m_gwDevices;
352 
358  std::map<Address, Ptr<SatArpCache>> m_arpCachesToGateway;
359 
361 };
362 
363 } // namespace ns3
364 
365 #endif /* SAT_USER_HELPER_H */
ChannelType_t
Types of channel.
Build a set of user nodes and links channels between user nodes and satellite nodes.
std::map< Ptr< Node >, NodeContainer > UtUsersContainer_t
Define UT user container.
Callback< Ptr< PropagationDelayModel >, uint32_t, uint32_t, SatEnums::ChannelType_t > PropagationDelayCallback
Ipv4AddressHelper m_ipv4Gw
void InstallGw(uint32_t users)
void SetCsmaDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each CsmaNetDevice object created by the helper.
NetworkType m_subscriberNetworkType
std::map< Address, Ptr< NetDevice > > m_utDevices
Container of UT SatNetDevice accessible by MAC address.
void UpdateGwRoutes(Address ut, Address oldGateway, Address newGateway)
Update ARP cache and default route on the terrestrial network so packets are properly routed to the U...
void SetBeamBaseAddress(const Ipv4Address &network, const Ipv4Mask &mask, Ipv4Address base="0.0.0.1")
NetDeviceContainer InstallSatSimpleNetwork(const NodeContainer &c) const
Install satellite simple network.
static TypeId GetTypeId(void)
Derived from Object.
void InstallRouter(Ptr< Node > router)
Install IP router to to Gateways.
TracedCallback< std::string > m_creationTrace
Trace callback for creation traces.
std::map< Ptr< Node >, Ptr< Node > > m_utMap
Container of UT users and their corresponding UT.
void SetCsmaQueue(std::string type, std::string name1="", const AttributeValue &value1=EmptyAttributeValue(), std::string name2="", const AttributeValue &value2=EmptyAttributeValue(), std::string name3="", const AttributeValue &value3=EmptyAttributeValue(), std::string name4="", const AttributeValue &value4=EmptyAttributeValue())
Set the type and the attribute values to be associated with each Queue object in each CsmaNetDevice c...
std::map< Address, Ptr< SatArpCache > > m_arpCachesToGateway
Container of ARP tables to reach a gateway accessible by MAC address.
void SetCsmaChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each CsmaChannel object created by the helper.
std::string GetRouterInfo() const
Get router information.
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
NetDeviceContainer InstallBackboneNetwork(const NodeContainer &c) const
Install network between GW and Router (or users) or Router and its users.
void SetGwBaseAddress(const Ipv4Address &network, const Ipv4Mask &mask, Ipv4Address base="0.0.0.1")
Ipv4AddressHelper m_ipv4Beam
std::map< Address, Ptr< NetDevice > > m_gwDevices
Container of GW SatNetDevice accessible by MAC address.
Ptr< Node > GetRouter() const
NetworkType
Network types in user networks (subscriber or backbone)
void PopulateBeamRoutings(NodeContainer ut, NetDeviceContainer utNd, Ptr< Node > gw, Ptr< NetDevice > gwNd)
Set needed routings of satellite network and fill ARP cache for the network.
SatUserHelper::PropagationDelayCallback m_propagationDelayCallback
bool IsGwUser(Ptr< Node > node) const
Check if node is GW user or not.
TypeId GetInstanceTypeId(void) const
Derived from Object.
NodeContainer InstallUt(NodeContainer ut, uint32_t users)
void UpdateUtRoutes(Address ut, Address newGateway)
Update ARP cache and default route on an UT so packets are properly routed to the new GW as their nex...
SatUserHelper()
Create a SatUserHelper to make life easier when creating Users and their connections to satellite net...
Ipv4AddressHelper m_ipv4Ut
NetDeviceContainer InstallSubscriberNetwork(const NodeContainer &c) const
Install network between UT and its users.
void SetUtBaseAddress(const Ipv4Address &network, const Ipv4Mask &mask, Ipv4Address base="0.0.0.1")
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.