A Discrete-Event Network Simulator
API
ripng.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Universita' di Firenze, Italy
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: Tommaso Pecorella <tommaso.pecorella@unifi.it>
19  */
20 
21 #ifndef RIPNG_H
22 #define RIPNG_H
23 
24 #include <list>
25 
26 #include "ns3/ipv6-routing-protocol.h"
27 #include "ns3/ipv6-interface.h"
28 #include "ns3/inet6-socket-address.h"
29 #include "ns3/ipv6-l3-protocol.h"
30 #include "ns3/ipv6-routing-table-entry.h"
31 #include "ns3/random-variable-stream.h"
32 #include "ns3/ripng-header.h"
33 
34 namespace ns3 {
35 
64 {
65 public:
66 
70  enum Status_e {
73  };
74 
76 
85  RipNgRoutingTableEntry (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse);
86 
93  RipNgRoutingTableEntry (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface);
94 
95  virtual ~RipNgRoutingTableEntry ();
96 
101  void SetRouteTag (uint16_t routeTag);
102 
107  uint16_t GetRouteTag (void) const;
108 
113  void SetRouteMetric (uint8_t routeMetric);
114 
119  uint8_t GetRouteMetric (void) const;
120 
125  void SetRouteStatus (Status_e status);
126 
131  Status_e GetRouteStatus (void) const;
132 
142  void SetRouteChanged (bool changed);
143 
149  bool IsRouteChanged (void) const;
150 
151 private:
152  uint16_t m_tag;
153  uint8_t m_metric;
155  bool m_changed;
156 };
157 
165 std::ostream& operator<< (std::ostream& os, RipNgRoutingTableEntry const& route);
166 
167 
168 
175 {
176 public:
177  // /< C-tor
178  RipNg ();
179  virtual ~RipNg ();
180 
185  static TypeId GetTypeId (void);
186 
187  // From Ipv6RoutingProtocol
189  Socket::SocketErrno &sockerr);
190  bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetDevice> idev,
193  virtual void NotifyInterfaceUp (uint32_t interface);
194  virtual void NotifyInterfaceDown (uint32_t interface);
195  virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address);
196  virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address);
197  virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop,
198  uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
199  virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop,
200  uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
201  virtual void SetIpv6 (Ptr<Ipv6> ipv6);
202  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
203 
211  };
212 
221  int64_t AssignStreams (int64_t stream);
222 
227  std::set<uint32_t> GetInterfaceExclusions () const;
228 
233  void SetInterfaceExclusions (std::set<uint32_t> exceptions);
234 
240  uint8_t GetInterfaceMetric (uint32_t interface) const;
241 
247  void SetInterfaceMetric (uint32_t interface, uint8_t metric);
248 
258  void AddDefaultRouteTo (Ipv6Address nextHop, uint32_t interface);
259 
260 protected:
264  virtual void DoDispose ();
265 
269  void DoInitialize ();
270 
271 private:
273  typedef std::list<std::pair <RipNgRoutingTableEntry *, EventId> > Routes;
274 
276  typedef std::list<std::pair <RipNgRoutingTableEntry *, EventId> >::const_iterator RoutesCI;
277 
279  typedef std::list<std::pair <RipNgRoutingTableEntry *, EventId> >::iterator RoutesI;
280 
281 
287  void Receive (Ptr<Socket> socket);
288 
298  void HandleRequests (RipNgHeader hdr, Ipv6Address senderAddress, uint16_t senderPort, uint32_t incomingInterface, uint8_t hopLimit);
299 
308  void HandleResponses (RipNgHeader hdr, Ipv6Address senderAddress, uint32_t incomingInterface, uint8_t hopLimit);
309 
317  Ptr<Ipv6Route> Lookup (Ipv6Address dest, bool setSource, Ptr<NetDevice> = 0);
318 
329 
338  void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse);
339 
346  void AddNetworkRouteTo (Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface);
347 
352  void DoSendRouteUpdate (bool periodic);
353 
357  void SendRouteRequest ();
358 
362  void SendTriggeredRouteUpdate ();
363 
367  void SendUnsolicitedRouteUpdate (void);
368 
374 
379  void DeleteRoute (RipNgRoutingTableEntry *route);
380 
389 
390  // note: we can not trust the result of socket->GetBoundNetDevice ()->GetIfIndex ();
391  // it is dependent on the interface initialization (i.e., if the loopback is already up).
393  typedef std::map< Ptr<Socket>, uint32_t> SocketList;
395  typedef std::map<Ptr<Socket>, uint32_t>::iterator SocketListI;
397  typedef std::map<Ptr<Socket>, uint32_t>::const_iterator SocketListCI;
398 
401 
404 
406 
407  std::set<uint32_t> m_interfaceExclusions;
408  std::map<uint32_t, uint8_t> m_interfaceMetrics;
409 
411 
413  uint8_t m_linkDown;
414 };
415 
416 } // namespace ns3
417 #endif /* RIPNG_H */
418 
ns3::RipNg::m_minTriggeredUpdateDelay
Time m_minTriggeredUpdateDelay
Min cooldown delay after a Triggered Update.
Definition: ripng.h:384
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::RipNg::m_maxTriggeredUpdateDelay
Time m_maxTriggeredUpdateDelay
Max cooldown delay after a Triggered Update.
Definition: ripng.h:385
ns3::Ipv6InterfaceAddress
IPv6 address associated with an interface.
Definition: ipv6-interface-address.h:38
ns3::RipNg::NotifyAddAddress
virtual void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.
Definition: ripng.cc:376
ns3::RipNg::SocketList
std::map< Ptr< Socket >, uint32_t > SocketList
Socket list type.
Definition: ripng.h:393
ns3::RipNgRoutingTableEntry::GetRouteMetric
uint8_t GetRouteMetric(void) const
Get the route metric.
Definition: ripng.cc:1331
ns3::RipNgRoutingTableEntry::m_metric
uint8_t m_metric
route metric
Definition: ripng.h:153
ns3::RipNgRoutingTableEntry::m_status
Status_e m_status
route status
Definition: ripng.h:154
ns3::RipNgRoutingTableEntry::m_changed
bool m_changed
route has been updated
Definition: ripng.h:155
ns3::RipNg::m_routes
Routes m_routes
the forwarding table for network.
Definition: ripng.h:381
ns3::RipNg::SendTriggeredRouteUpdate
void SendTriggeredRouteUpdate()
Send Triggered Routing Updates on all interfaces.
Definition: ripng.cc:1162
ns3::EventId
An identifier for simulation events.
Definition: event-id.h:54
ns3::RipNg::m_initialized
bool m_initialized
flag to allow socket's late-creation.
Definition: ripng.h:412
ns3::Socket::SocketErrno
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::RipNg::m_unsolicitedUpdate
Time m_unsolicitedUpdate
time between two Unsolicited Routing Updates
Definition: ripng.h:386
ns3::RipNg::DoInitialize
void DoInitialize()
Start protocol operation.
Definition: ripng.cc:110
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::RipNgRoutingTableEntry::RIPNG_VALID
@ RIPNG_VALID
Definition: ripng.h:71
ns3::RipNg::HandleRequests
void HandleRequests(RipNgHeader hdr, Ipv6Address senderAddress, uint16_t senderPort, uint32_t incomingInterface, uint8_t hopLimit)
Handle RIPng requests.
Definition: ripng.cc:761
ns3::RipNg::Lookup
Ptr< Ipv6Route > Lookup(Ipv6Address dest, bool setSource, Ptr< NetDevice >=0)
Lookup in the forwarding table for destination.
Definition: ripng.cc:558
ns3::RipNg::m_multicastRecvSocket
Ptr< Socket > m_multicastRecvSocket
multicast receive socket
Definition: ripng.h:400
ns3::RipNg::RecvMulticastRipng
void RecvMulticastRipng(Ptr< Socket > socket)
Receive and process multicast packet.
ns3::RipNg::NotifyAddRoute
virtual void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify a new route.
Definition: ripng.cc:438
ns3::RipNg::POISON_REVERSE
@ POISON_REVERSE
Poison Reverse Split Horizon.
Definition: ripng.h:210
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::RipNgRoutingTableEntry::SetRouteTag
void SetRouteTag(uint16_t routeTag)
Set the route tag.
Definition: ripng.cc:1308
ns3::RipNg::SocketListI
std::map< Ptr< Socket >, uint32_t >::iterator SocketListI
Socket list type iterator.
Definition: ripng.h:395
ns3::RipNg::NO_SPLIT_HORIZON
@ NO_SPLIT_HORIZON
No Split Horizon.
Definition: ripng.h:208
ns3::Ipv6RoutingTableEntry
A record of an IPv6 route.
Definition: ipv6-routing-table-entry.h:39
ns3::RipNg::NotifyInterfaceUp
virtual void NotifyInterfaceUp(uint32_t interface)
Notify when specified interface goes UP.
Definition: ripng.cc:268
ns3::RipNgRoutingTableEntry::GetRouteStatus
Status_e GetRouteStatus(void) const
Get the route status.
Definition: ripng.cc:1345
ns3::Ipv6Header
Packet header for IPv6.
Definition: ipv6-header.h:36
ns3::RipNg::SocketListCI
std::map< Ptr< Socket >, uint32_t >::const_iterator SocketListCI
Socket list type const iterator.
Definition: ripng.h:397
ns3::RipNgRoutingTableEntry::SetRouteStatus
void SetRouteStatus(Status_e status)
Set the route status.
Definition: ripng.cc:1336
ns3::RipNg::SendUnsolicitedRouteUpdate
void SendUnsolicitedRouteUpdate(void)
Send Unsolicited Routing Updates on all interfaces.
Definition: ripng.cc:1192
ns3::RipNg::NotifyRemoveAddress
virtual void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address)
Notify when specified interface add an address.
Definition: ripng.cc:401
ns3::RipNg::RoutesI
std::list< std::pair< RipNgRoutingTableEntry *, EventId > >::iterator RoutesI
Iterator for container for the network routes.
Definition: ripng.h:279
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::RipNg::SplitHorizonType_e
SplitHorizonType_e
Split Horizon strategy type.
Definition: ripng.h:207
ns3::RipNg::NotifyRemoveRoute
virtual void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero())
Notify route removing.
Definition: ripng.cc:444
ns3::RipNgRoutingTableEntry::RIPNG_INVALID
@ RIPNG_INVALID
Definition: ripng.h:72
ns3::RipNg::SendRouteRequest
void SendRouteRequest()
Send Routing Request on all interfaces.
Definition: ripng.cc:1241
ns3::RipNg::~RipNg
virtual ~RipNg()
Definition: ripng.cc:53
ns3::RipNgHeader
RipNgHeader - see RFC 2080
Definition: ripng-header.h:147
ns3::RipNg::m_linkDown
uint8_t m_linkDown
Link down value.
Definition: ripng.h:413
ns3::RipNg::RecvUnicastRipng
void RecvUnicastRipng(Ptr< Socket > socket)
Receive and process unicast packet.
ns3::Ipv6RoutingProtocol
Abstract base class for IPv6 routing protocols.
Definition: ipv6-routing-protocol.h:60
first.address
address
Definition: first.py:44
ns3::RipNg::AddNetworkRouteTo
void AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse)
Add route to network.
Definition: ripng.cc:639
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::RipNg::m_startupDelay
Time m_startupDelay
Random delay before protocol startup.
Definition: ripng.h:383
ns3::RipNgRoutingTableEntry::SetRouteMetric
void SetRouteMetric(uint8_t routeMetric)
Set the route metric.
Definition: ripng.cc:1322
ns3::RipNg::m_splitHorizonStrategy
SplitHorizonType_e m_splitHorizonStrategy
Split Horizon strategy.
Definition: ripng.h:410
ns3::RipNgRoutingTableEntry::RipNgRoutingTableEntry
RipNgRoutingTableEntry(void)
Definition: ripng.cc:1286
ns3::RipNg::AssignStreams
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: ripng.cc:102
ns3::Ipv6Address::GetZero
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Definition: ipv6-address.cc:890
ns3::RipNgRoutingTableEntry::SetRouteChanged
void SetRouteChanged(bool changed)
Set the route as changed.
Definition: ripng.cc:1350
ns3::RipNgRoutingTableEntry::m_tag
uint16_t m_tag
route tag
Definition: ripng.h:152
ns3::RipNgRoutingTableEntry::IsRouteChanged
bool IsRouteChanged(void) const
Get the route changed status.
Definition: ripng.cc:1355
ns3::RipNg::m_interfaceExclusions
std::set< uint32_t > m_interfaceExclusions
Set of excluded interfaces.
Definition: ripng.h:407
ns3::RipNg::GetInterfaceExclusions
std::set< uint32_t > GetInterfaceExclusions() const
Get the set of interface excluded from the protocol.
Definition: ripng.cc:1207
ns3::RipNg::DeleteRoute
void DeleteRoute(RipNgRoutingTableEntry *route)
Delete a route.
Definition: ripng.cc:690
ns3::RipNg::Receive
void Receive(Ptr< Socket > socket)
Receive RIPng packets.
Definition: ripng.cc:707
ns3::RipNgRoutingTableEntry
RipNg Routing Table Entry.
Definition: ripng.h:64
ns3::RipNg::SPLIT_HORIZON
@ SPLIT_HORIZON
Split Horizon.
Definition: ripng.h:209
ns3::RipNg::DoDispose
virtual void DoDispose()
Dispose this object.
Definition: ripng.cc:529
ns3::RipNg::m_nextTriggeredUpdate
EventId m_nextTriggeredUpdate
Next Triggered Update event.
Definition: ripng.h:403
ns3::RipNgRoutingTableEntry::GetRouteTag
uint16_t GetRouteTag(void) const
Get the route tag.
Definition: ripng.cc:1317
ns3::RipNg::AddDefaultRouteTo
void AddDefaultRouteTo(Ipv6Address nextHop, uint32_t interface)
Add a default route to the router through the nextHop located on interface.
Definition: ripng.cc:1274
ns3::RipNg::Routes
std::list< std::pair< RipNgRoutingTableEntry *, EventId > > Routes
Container for the network routes - pair RipNgRoutingTableEntry *, EventId (update event)
Definition: ripng.h:273
ns3::RipNg::m_garbageCollectionDelay
Time m_garbageCollectionDelay
Delay before deleting an INVALID route.
Definition: ripng.h:388
ns3::RipNg::RoutesCI
std::list< std::pair< RipNgRoutingTableEntry *, EventId > >::const_iterator RoutesCI
Const Iterator for container for the network routes.
Definition: ripng.h:276
ns3::RipNg::InvalidateRoute
void InvalidateRoute(RipNgRoutingTableEntry *route)
Invalidate a route.
Definition: ripng.cc:668
ns3::RipNg::m_nextUnsolicitedUpdate
EventId m_nextUnsolicitedUpdate
Next Unsolicited Update event.
Definition: ripng.h:402
ns3::Time::S
@ S
second
Definition: nstime.h:115
ns3::RipNg::RouteInput
bool RouteInput(Ptr< const Packet > p, const Ipv6Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
Definition: ripng.cc:212
ns3::RipNg::m_ipv6
Ptr< Ipv6 > m_ipv6
IPv6 reference.
Definition: ripng.h:382
ns3::RipNg::NotifyInterfaceDown
virtual void NotifyInterfaceDown(uint32_t interface)
Notify when specified interface goes DOWN.
Definition: ripng.cc:345
ns3::RipNg::DoSendRouteUpdate
void DoSendRouteUpdate(bool periodic)
Send Routing Updates on all interfaces.
Definition: ripng.cc:1082
ns3::RipNg
RIPng Routing Protocol, defined in RFC 2080.
Definition: ripng.h:175
ns3::RipNgRoutingTableEntry::~RipNgRoutingTableEntry
virtual ~RipNgRoutingTableEntry()
Definition: ripng.cc:1303
ns3::RipNg::SetInterfaceMetric
void SetInterfaceMetric(uint32_t interface, uint8_t metric)
Set the metric for an interface.
Definition: ripng.cc:1231
ns3::RipNg::RouteOutput
Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
Definition: ripng.cc:182
ns3::RipNg::PrintRoutingTable
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
Definition: ripng.cc:471
ns3::RipNg::SetInterfaceExclusions
void SetInterfaceExclusions(std::set< uint32_t > exceptions)
Set the set of interface excluded from the protocol.
Definition: ripng.cc:1212
ns3::RipNg::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: ripng.cc:58
ns3::RipNg::m_interfaceMetrics
std::map< uint32_t, uint8_t > m_interfaceMetrics
Map of interface metrics.
Definition: ripng.h:408
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
ns3::RipNg::SetIpv6
virtual void SetIpv6(Ptr< Ipv6 > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
Definition: ripng.cc:450
ns3::Ipv6Prefix
Describes an IPv6 prefix.
Definition: ipv6-address.h:456
ns3::RipNgRoutingTableEntry::Status_e
Status_e
Route status.
Definition: ripng.h:70
ns3::RipNg::RipNg
RipNg()
Definition: ripng.cc:47
ns3::RipNg::HandleResponses
void HandleResponses(RipNgHeader hdr, Ipv6Address senderAddress, uint32_t incomingInterface, uint8_t hopLimit)
Handle RIPng responses.
Definition: ripng.cc:926
ns3::Time::Unit
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:110
ns3::RipNg::m_timeoutDelay
Time m_timeoutDelay
Delay before invalidating a route.
Definition: ripng.h:387
ns3::RipNg::m_rng
Ptr< UniformRandomVariable > m_rng
Rng stream.
Definition: ripng.h:405
ns3::RipNg::m_unicastSocketList
SocketList m_unicastSocketList
list of sockets for unicast messages (socket, interface index)
Definition: ripng.h:399
ns3::RipNg::GetInterfaceMetric
uint8_t GetInterfaceMetric(uint32_t interface) const
Get the metric for an interface.
Definition: ripng.cc:1219