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 
217  NodeContainer InstallGw(NodeContainer gw, uint32_t users);
218 
222  NodeContainer GetGwUsers() const;
223 
230  bool IsGwUser(Ptr<Node> node) const;
231 
235  NodeContainer GetUtUsers() const;
236 
241  NodeContainer GetUtUsers(Ptr<Node> ut) const;
242 
246  uint32_t GetGwUserCount() const;
247 
251  uint32_t GetUtUserCount() const;
252 
257  uint32_t GetUtUserCount(Ptr<Node> ut) const;
258 
264  Ptr<Node> GetUtNode(Ptr<Node> utUserNode) const;
265 
269  NodeContainer GetUtNodes() const;
270 
277  void EnableCreationTraces(Ptr<OutputStreamWrapper> stream, CallbackBase& cb);
278 
284  std::string GetRouterInfo() const;
285 
289  Ptr<Node> GetRouter() const;
290 
298  void PopulateBeamRoutings(NodeContainer ut,
299  NetDeviceContainer utNd,
300  Ptr<Node> gw,
301  Ptr<NetDevice> gwNd);
302 
311  void UpdateUtRoutes(Address ut, Address newGateway);
312 
320  void UpdateGwRoutes(Address ut, Address oldGateway, Address newGateway);
321 
322  typedef Callback<Ptr<PropagationDelayModel>, uint32_t, uint32_t, SatEnums::ChannelType_t>
324 
325  private:
332  NetDeviceContainer InstallSubscriberNetwork(const NodeContainer& c) const;
333 
340  NetDeviceContainer InstallBackboneNetwork(const NodeContainer& c) const;
341 
348  NetDeviceContainer InstallSatSimpleNetwork(const NodeContainer& c) const;
349 
356  void InstallRouter(NodeContainer gw, Ptr<Node> router);
357 
358  CsmaHelper m_csma;
359  Ipv4AddressHelper m_ipv4Ut;
360  Ipv4AddressHelper m_ipv4Gw;
361  Ipv4AddressHelper m_ipv4Beam;
362 
363  NodeContainer m_gwUsers;
365  NodeContainer m_allUtUsers;
366 
369 
370  Ptr<Node> m_router;
371 
384  std::map<Ptr<Node>, Ptr<Node>> m_utMap;
385 
389  TracedCallback<std::string> m_creationTrace;
390 
396  std::map<Address, Ptr<NetDevice>> m_utDevices;
397 
403  std::map<Address, Ptr<NetDevice>> m_gwDevices;
404 
410  std::map<Address, Ptr<SatArpCache>> m_arpCachesToGateway;
411 
413 };
414 
415 } // namespace ns3
416 
417 #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
NodeContainer GetUtNodes() const
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...
uint32_t GetGwUserCount() const
NodeContainer GetGwUsers() const
void SetBeamBaseAddress(const Ipv4Address &network, const Ipv4Mask &mask, Ipv4Address base="0.0.0.1")
NodeContainer GetUtUsers() const
NetDeviceContainer InstallSatSimpleNetwork(const NodeContainer &c) const
Install satellite simple network.
static TypeId GetTypeId(void)
Derived from Object.
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.
Ptr< Node > GetUtNode(Ptr< Node > utUserNode) const
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 InstallRouter(NodeContainer gw, Ptr< Node > router)
Install IP router to to Gateways.
void EnableCreationTraces(Ptr< OutputStreamWrapper > stream, CallbackBase &cb)
Enables creation traces to be written in given file.
NodeContainer InstallGw(NodeContainer gw, uint32_t users)
NetDeviceContainer InstallBackboneNetwork(const NodeContainer &c) const
Install network between GW and Router (or users) or Router and its users.
UtUsersContainer_t m_utUsers
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
uint32_t GetUtUserCount() 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.