A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ripng.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Universita' di Firenze, Italy
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18 */
19
20#ifndef RIPNG_H
21#define RIPNG_H
22
23#include "ipv6-interface.h"
24#include "ipv6-l3-protocol.h"
27#include "ripng-header.h"
28
29#include "ns3/inet6-socket-address.h"
30#include "ns3/random-variable-stream.h"
31
32#include <list>
33
34namespace ns3
35{
36
65{
66 public:
71 {
74 };
75
77
87 Ipv6Prefix networkPrefix,
88 Ipv6Address nextHop,
89 uint32_t interface,
90 Ipv6Address prefixToUse);
91
98 RipNgRoutingTableEntry(Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface);
99
100 ~RipNgRoutingTableEntry() override;
101
106 void SetRouteTag(uint16_t routeTag);
107
112 uint16_t GetRouteTag() const;
113
118 void SetRouteMetric(uint8_t routeMetric);
119
124 uint8_t GetRouteMetric() const;
125
130 void SetRouteStatus(Status_e status);
131
136 Status_e GetRouteStatus() const;
137
147 void SetRouteChanged(bool changed);
148
154 bool IsRouteChanged() const;
155
156 private:
157 uint16_t m_tag;
158 uint8_t m_metric;
161};
162
170std::ostream& operator<<(std::ostream& os, const RipNgRoutingTableEntry& route);
171
178{
179 public:
180 // /< C-tor
181 RipNg();
182 ~RipNg() override;
183
188 static TypeId GetTypeId();
189
190 // From Ipv6RoutingProtocol
192 const Ipv6Header& header,
193 Ptr<NetDevice> oif,
194 Socket::SocketErrno& sockerr) override;
196 const Ipv6Header& header,
198 const UnicastForwardCallback& ucb,
199 const MulticastForwardCallback& mcb,
200 const LocalDeliverCallback& lcb,
201 const ErrorCallback& ecb) override;
202 void NotifyInterfaceUp(uint32_t interface) override;
203 void NotifyInterfaceDown(uint32_t interface) override;
204 void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
205 void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override;
207 Ipv6Prefix mask,
208 Ipv6Address nextHop,
209 uint32_t interface,
210 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
212 Ipv6Prefix mask,
213 Ipv6Address nextHop,
214 uint32_t interface,
215 Ipv6Address prefixToUse = Ipv6Address::GetZero()) override;
216 void SetIpv6(Ptr<Ipv6> ipv6) override;
218 Time::Unit unit = Time::S) const override;
219
224 {
228 };
229
238 int64_t AssignStreams(int64_t stream);
239
244 std::set<uint32_t> GetInterfaceExclusions() const;
245
250 void SetInterfaceExclusions(std::set<uint32_t> exceptions);
251
257 uint8_t GetInterfaceMetric(uint32_t interface) const;
258
264 void SetInterfaceMetric(uint32_t interface, uint8_t metric);
265
275 void AddDefaultRouteTo(Ipv6Address nextHop, uint32_t interface);
276
277 protected:
281 void DoDispose() override;
282
286 void DoInitialize() override;
287
288 private:
290 typedef std::list<std::pair<RipNgRoutingTableEntry*, EventId>> Routes;
291
293 typedef std::list<std::pair<RipNgRoutingTableEntry*, EventId>>::const_iterator RoutesCI;
294
296 typedef std::list<std::pair<RipNgRoutingTableEntry*, EventId>>::iterator RoutesI;
297
303 void Receive(Ptr<Socket> socket);
304
315 Ipv6Address senderAddress,
316 uint16_t senderPort,
317 uint32_t incomingInterface,
318 uint8_t hopLimit);
319
329 Ipv6Address senderAddress,
330 uint32_t incomingInterface,
331 uint8_t hopLimit);
332
340 Ptr<Ipv6Route> Lookup(Ipv6Address dest, bool setSource, Ptr<NetDevice> = nullptr);
341
352
361 void AddNetworkRouteTo(Ipv6Address network,
362 Ipv6Prefix networkPrefix,
363 Ipv6Address nextHop,
364 uint32_t interface,
365 Ipv6Address prefixToUse);
366
373 void AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, uint32_t interface);
374
379 void DoSendRouteUpdate(bool periodic);
380
384 void SendRouteRequest();
385
390
395
401
407
416
417 // note: we can not trust the result of socket->GetBoundNetDevice ()->GetIfIndex ();
418 // it is dependent on the interface initialization (i.e., if the loopback is already up).
420 typedef std::map<Ptr<Socket>, uint32_t> SocketList;
422 typedef std::map<Ptr<Socket>, uint32_t>::iterator SocketListI;
424 typedef std::map<Ptr<Socket>, uint32_t>::const_iterator SocketListCI;
425
429
432
434
435 std::set<uint32_t> m_interfaceExclusions;
436 std::map<uint32_t, uint8_t> m_interfaceMetrics;
437
439
441 uint8_t m_linkDown;
442};
443
444} // namespace ns3
445#endif /* RIPNG_H */
An identifier for simulation events.
Definition: event-id.h:55
Describes an IPv6 address.
Definition: ipv6-address.h:49
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
Packet header for IPv6.
Definition: ipv6-header.h:35
IPv6 address associated with an interface.
Describes an IPv6 prefix.
Definition: ipv6-address.h:455
Abstract base class for IPv6 routing protocols.
A record of an IPv6 route.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
RipNgHeader - see RFC 2080
Definition: ripng-header.h:147
RIPng Routing Protocol, defined in RFC 2080.
Definition: ripng.h:178
Ptr< Socket > m_multicastRecvSocket
multicast receive socket
Definition: ripng.h:428
void NotifyInterfaceUp(uint32_t interface) override
Notify when specified interface goes UP.
Definition: ripng.cc:294
void NotifyAddAddress(uint32_t interface, Ipv6InterfaceAddress address) override
Notify when specified interface add an address.
Definition: ripng.cc:404
void NotifyAddRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()) override
Notify a new route.
Definition: ripng.cc:466
void DoSendRouteUpdate(bool periodic)
Send Routing Updates on all interfaces.
Definition: ripng.cc:1191
Time m_startupDelay
Random delay before protocol startup.
Definition: ripng.h:410
void DoDispose() override
Dispose this object.
Definition: ripng.cc:575
std::list< std::pair< RipNgRoutingTableEntry *, EventId > >::const_iterator RoutesCI
Const Iterator for container for the network routes.
Definition: ripng.h:293
SplitHorizonType_e m_splitHorizonStrategy
Split Horizon strategy.
Definition: ripng.h:438
SplitHorizonType_e
Split Horizon strategy type.
Definition: ripng.h:224
@ SPLIT_HORIZON
Split Horizon.
Definition: ripng.h:226
@ POISON_REVERSE
Poison Reverse Split Horizon.
Definition: ripng.h:227
@ NO_SPLIT_HORIZON
No Split Horizon.
Definition: ripng.h:225
EventId m_nextTriggeredUpdate
Next Triggered Update event.
Definition: ripng.h:431
std::list< std::pair< RipNgRoutingTableEntry *, EventId > >::iterator RoutesI
Iterator for container for the network routes.
Definition: ripng.h:296
~RipNg() override
Definition: ripng.cc:57
void NotifyRemoveAddress(uint32_t interface, Ipv6InterfaceAddress address) override
Notify when specified interface add an address.
Definition: ripng.cc:430
Time m_minTriggeredUpdateDelay
Min cooldown delay after a Triggered Update.
Definition: ripng.h:411
void SetInterfaceExclusions(std::set< uint32_t > exceptions)
Set the set of interface excluded from the protocol.
Definition: ripng.cc:1333
Ptr< Ipv6Route > RouteOutput(Ptr< Packet > p, const Ipv6Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr) override
Query routing cache for an existing route, for an outbound packet.
Definition: ripng.cc:200
EventId m_nextUnsolicitedUpdate
Next Unsolicited Update event.
Definition: ripng.h:430
uint8_t m_linkDown
Link down value.
Definition: ripng.h:441
Time m_maxTriggeredUpdateDelay
Max cooldown delay after a Triggered Update.
Definition: ripng.h:412
void DoInitialize() override
Start protocol operation.
Definition: ripng.cc:127
bool m_initialized
flag to allow socket's late-creation.
Definition: ripng.h:440
void RecvUnicastRipng(Ptr< Socket > socket)
Receive and process unicast packet.
SocketList m_unicastSocketList
list of sockets for unicast messages (socket, interface index)
Definition: ripng.h:427
std::map< Ptr< Socket >, uint32_t >::iterator SocketListI
Socket list type iterator.
Definition: ripng.h:422
uint8_t GetInterfaceMetric(uint32_t interface) const
Get the metric for an interface.
Definition: ripng.cc:1341
bool RouteInput(Ptr< const Packet > p, const Ipv6Header &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb) override
Route an input packet (to be forwarded or locally delivered)
Definition: ripng.cc:234
Time m_unsolicitedUpdate
time between two Unsolicited Routing Updates
Definition: ripng.h:413
std::set< uint32_t > m_interfaceExclusions
Set of excluded interfaces.
Definition: ripng.h:435
void SetInterfaceMetric(uint32_t interface, uint8_t metric)
Set the metric for an interface.
Definition: ripng.cc:1354
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: ripng.cc:118
void DeleteRoute(RipNgRoutingTableEntry *route)
Delete a route.
Definition: ripng.cc:756
void AddNetworkRouteTo(Ipv6Address network, Ipv6Prefix networkPrefix, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse)
Add route to network.
Definition: ripng.cc:696
void RecvMulticastRipng(Ptr< Socket > socket)
Receive and process multicast packet.
Time m_garbageCollectionDelay
Delay before deleting an INVALID route.
Definition: ripng.h:415
std::map< uint32_t, uint8_t > m_interfaceMetrics
Map of interface metrics.
Definition: ripng.h:436
RipNg()
Definition: ripng.cc:49
void SendRouteRequest()
Send Routing Request on all interfaces.
Definition: ripng.cc:1365
void NotifyInterfaceDown(uint32_t interface) override
Notify when specified interface goes DOWN.
Definition: ripng.cc:372
std::map< Ptr< Socket >, uint32_t > SocketList
Socket list type.
Definition: ripng.h:420
std::list< std::pair< RipNgRoutingTableEntry *, EventId > > Routes
Container for the network routes - pair RipNgRoutingTableEntry *, EventId (update event)
Definition: ripng.h:290
Ptr< Ipv6 > m_ipv6
IPv6 reference.
Definition: ripng.h:409
Routes m_routes
the forwarding table for network.
Definition: ripng.h:408
std::set< uint32_t > GetInterfaceExclusions() const
Get the set of interface excluded from the protocol.
Definition: ripng.cc:1327
void SendTriggeredRouteUpdate()
Send Triggered Routing Updates on all interfaces.
Definition: ripng.cc:1278
void HandleRequests(RipNgHeader hdr, Ipv6Address senderAddress, uint16_t senderPort, uint32_t incomingInterface, uint8_t hopLimit)
Handle RIPng requests.
Definition: ripng.cc:827
Ptr< UniformRandomVariable > m_rng
Rng stream.
Definition: ripng.h:433
void HandleResponses(RipNgHeader hdr, Ipv6Address senderAddress, uint32_t incomingInterface, uint8_t hopLimit)
Handle RIPng responses.
Definition: ripng.cc:1005
void NotifyRemoveRoute(Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()) override
Notify route removing.
Definition: ripng.cc:477
static TypeId GetTypeId()
Get the type ID.
Definition: ripng.cc:62
void InvalidateRoute(RipNgRoutingTableEntry *route)
Invalidate a route.
Definition: ripng.cc:732
std::map< Ptr< Socket >, uint32_t >::const_iterator SocketListCI
Socket list type const iterator.
Definition: ripng.h:424
void SetIpv6(Ptr< Ipv6 > ipv6) override
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
Definition: ripng.cc:488
void Receive(Ptr< Socket > socket)
Receive RIPng packets.
Definition: ripng.cc:773
void AddDefaultRouteTo(Ipv6Address nextHop, uint32_t interface)
Add a default route to the router through the nextHop located on interface.
Definition: ripng.cc:1399
Time m_timeoutDelay
Delay before invalidating a route.
Definition: ripng.h:414
void SendUnsolicitedRouteUpdate()
Send Unsolicited Routing Updates on all interfaces.
Definition: ripng.cc:1310
void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const override
Print the Routing Table entries.
Definition: ripng.cc:510
Ptr< Ipv6Route > Lookup(Ipv6Address dest, bool setSource, Ptr< NetDevice >=nullptr)
Lookup in the forwarding table for destination.
Definition: ripng.cc:605
RipNg Routing Table Entry.
Definition: ripng.h:65
bool IsRouteChanged() const
Get the route changed status.
Definition: ripng.cc:1510
RipNgRoutingTableEntry()
Definition: ripng.cc:1414
uint16_t GetRouteTag() const
Get the route tag.
Definition: ripng.cc:1466
bool m_changed
route has been updated
Definition: ripng.h:160
uint16_t m_tag
route tag
Definition: ripng.h:157
void SetRouteTag(uint16_t routeTag)
Set the route tag.
Definition: ripng.cc:1456
uint8_t GetRouteMetric() const
Get the route metric.
Definition: ripng.cc:1482
void SetRouteMetric(uint8_t routeMetric)
Set the route metric.
Definition: ripng.cc:1472
uint8_t m_metric
route metric
Definition: ripng.h:158
Status_e m_status
route status
Definition: ripng.h:159
Status_e GetRouteStatus() const
Get the route status.
Definition: ripng.cc:1498
void SetRouteChanged(bool changed)
Set the route as changed.
Definition: ripng.cc:1504
~RipNgRoutingTableEntry() override
Definition: ripng.cc:1451
Status_e
Route status.
Definition: ripng.h:71
@ RIPNG_INVALID
Definition: ripng.h:73
@ RIPNG_VALID
Definition: ripng.h:72
void SetRouteStatus(Status_e status)
Set the route status.
Definition: ripng.cc:1488
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:84
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:111
@ S
second
Definition: nstime.h:116
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159