A Discrete-Event Network Simulator
API
dsdv-rtable.h
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2010 Hemanth Narra
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: Hemanth Narra <hemanth@ittc.ku.com>
19 *
20 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22 * Information and Telecommunication Technology Center (ITTC)
23 * and Department of Electrical Engineering and Computer Science
24 * The University of Kansas Lawrence, KS USA.
25 *
26 * Work supported in part by NSF FIND (Future Internet Design) Program
27 * under grant CNS-0626918 (Postmodern Internet Architecture),
28 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29 * US Department of Defense (DoD), and ITTC at The University of Kansas.
30 */
31
32#ifndef DSDV_RTABLE_H
33#define DSDV_RTABLE_H
34
35#include <cassert>
36#include <map>
37#include <sys/types.h>
38#include "ns3/ipv4.h"
39#include "ns3/ipv4-route.h"
40#include "ns3/timer.h"
41#include "ns3/net-device.h"
42#include "ns3/output-stream-wrapper.h"
43
44namespace ns3 {
45namespace dsdv {
47{
48 VALID = 0, // !< VALID
49 INVALID = 1, // !< INVALID
50};
51
57{
58public:
74 Time lifetime = Simulator::Now (), Time SettlingTime = Simulator::Now (), bool changedEntries = false);
75
83 {
84 return m_ipv4Route->GetDestination ();
85 }
91 GetRoute () const
92 {
93 return m_ipv4Route;
94 }
99 void
101 {
102 m_ipv4Route = route;
103 }
108 void
110 {
111 m_ipv4Route->SetGateway (nextHop);
112 }
118 GetNextHop () const
119 {
120 return m_ipv4Route->GetGateway ();
121 }
126 void
128 {
129 m_ipv4Route->SetOutputDevice (device);
130 }
137 {
138 return m_ipv4Route->GetOutputDevice ();
139 }
146 {
147 return m_iface;
148 }
153 void
155 {
156 m_iface = iface;
157 }
162 void
163 SetSeqNo (uint32_t sequenceNumber)
164 {
165 m_seqNo = sequenceNumber;
166 }
172 GetSeqNo () const
173 {
174 return m_seqNo;
175 }
180 void
181 SetHop (uint32_t hopCount)
182 {
183 m_hops = hopCount;
184 }
190 GetHop () const
191 {
192 return m_hops;
193 }
198 void
199 SetLifeTime (Time lifeTime)
200 {
201 m_lifeTime = lifeTime;
202 }
207 Time
208 GetLifeTime () const
209 {
210 return (Simulator::Now () - m_lifeTime);
211 }
216 void
217 SetSettlingTime (Time settlingTime)
218 {
219 m_settlingTime = settlingTime;
220 }
225 Time
227 {
228 return (m_settlingTime);
229 }
234 void
236 {
237 m_flag = flag;
238 }
244 GetFlag () const
245 {
246 return m_flag;
247 }
252 void
253 SetEntriesChanged (bool entriesChanged)
254 {
255 m_entriesChanged = entriesChanged;
256 }
261 bool
263 {
264 return m_entriesChanged;
265 }
271 bool
272 operator== (Ipv4Address const destination) const
273 {
274 return (m_ipv4Route->GetDestination () == destination);
275 }
281 void
282 Print (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
283
284private:
285 // Fields
313
314};
315
321{
322public:
324 RoutingTable ();
330 bool
337 bool
345 bool
354 bool
355 LookupRoute (Ipv4Address id, RoutingTableEntry & rt, bool forRouteInput);
361 bool
368 void
369 GetListOfDestinationWithNextHop (Ipv4Address nxtHp, std::map<Ipv4Address, RoutingTableEntry> & dstList);
374 void
375 GetListOfAllRoutes (std::map<Ipv4Address, RoutingTableEntry> & allRoutes);
380 void
383 void
385 {
386 m_ipv4AddressEntry.clear ();
387 }
392 void
393 Purge (std::map<Ipv4Address, RoutingTableEntry> & removedAddresses);
399 void
400 Print (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
414 bool
421 bool
429 bool
437 bool
444 EventId
446
452 {
453 return m_holddownTime;
454 }
460 {
461 m_holddownTime = t;
462 }
463
464private:
465 // Fields
467 std::map<Ipv4Address, RoutingTableEntry> m_ipv4AddressEntry;
469 std::map<Ipv4Address, EventId> m_ipv4Events;
472
473};
474}
475}
476#endif /* DSDV_RTABLE_H */
An identifier for simulation events.
Definition: event-id.h:54
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
a class to store IPv4 address information on an interface
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:109
@ S
second
Definition: nstime.h:114
Routing table entry.
Definition: dsdv-rtable.h:57
void SetHop(uint32_t hopCount)
Set hop.
Definition: dsdv-rtable.h:181
bool operator==(Ipv4Address const destination) const
Compare destination address.
Definition: dsdv-rtable.h:272
uint32_t m_seqNo
Destination Sequence Number.
Definition: dsdv-rtable.h:287
void SetLifeTime(Time lifeTime)
Set lifetime.
Definition: dsdv-rtable.h:199
Ptr< NetDevice > GetOutputDevice() const
Get output device.
Definition: dsdv-rtable.h:136
void Print(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print routing table entry.
Definition: dsdv-rtable.cc:198
Time m_lifeTime
Expiration or deletion time of the route Lifetime field in the routing table plays dual role – for an...
Definition: dsdv-rtable.h:296
RouteFlags GetFlag() const
Get route flags.
Definition: dsdv-rtable.h:244
bool GetEntriesChanged() const
Get entries changed.
Definition: dsdv-rtable.h:262
void SetEntriesChanged(bool entriesChanged)
Set entries changed indicator.
Definition: dsdv-rtable.h:253
Time GetSettlingTime() const
Get settling time.
Definition: dsdv-rtable.h:226
Ipv4Address GetDestination() const
Get destination IP address.
Definition: dsdv-rtable.h:82
void SetSettlingTime(Time settlingTime)
Set settling time.
Definition: dsdv-rtable.h:217
Ptr< Ipv4Route > GetRoute() const
Get route.
Definition: dsdv-rtable.h:91
RouteFlags m_flag
Routing flags: valid, invalid or in search.
Definition: dsdv-rtable.h:307
void SetOutputDevice(Ptr< NetDevice > device)
Set output device.
Definition: dsdv-rtable.h:127
~RoutingTableEntry()
Definition: dsdv-rtable.cc:64
uint32_t m_entriesChanged
Flag to show if any of the routing table entries were changed with the routing update.
Definition: dsdv-rtable.h:312
void SetNextHop(Ipv4Address nextHop)
Set next hop.
Definition: dsdv-rtable.h:109
void SetRoute(Ptr< Ipv4Route > route)
Set route.
Definition: dsdv-rtable.h:100
Ipv4InterfaceAddress m_iface
Output interface address.
Definition: dsdv-rtable.h:305
Ipv4InterfaceAddress GetInterface() const
Get interface address.
Definition: dsdv-rtable.h:145
Ptr< Ipv4Route > m_ipv4Route
Ip route, include.
Definition: dsdv-rtable.h:303
Time m_settlingTime
Time for which the node retains an update with changed metric before broadcasting it.
Definition: dsdv-rtable.h:310
uint32_t GetSeqNo() const
Get sequence number.
Definition: dsdv-rtable.h:172
Time GetLifeTime() const
Get lifetime.
Definition: dsdv-rtable.h:208
void SetFlag(RouteFlags flag)
Set route flags.
Definition: dsdv-rtable.h:235
uint32_t GetHop() const
Get hop.
Definition: dsdv-rtable.h:190
uint32_t m_hops
Hop Count (number of hops needed to reach destination)
Definition: dsdv-rtable.h:289
Ipv4Address GetNextHop() const
Get next hop.
Definition: dsdv-rtable.h:118
void SetInterface(Ipv4InterfaceAddress iface)
Set interface address.
Definition: dsdv-rtable.h:154
void SetSeqNo(uint32_t sequenceNumber)
Set sequence number.
Definition: dsdv-rtable.h:163
RoutingTableEntry(Ptr< NetDevice > dev=0, Ipv4Address dst=Ipv4Address(), uint32_t seqNo=0, Ipv4InterfaceAddress iface=Ipv4InterfaceAddress(), uint32_t hops=0, Ipv4Address nextHop=Ipv4Address(), Time lifetime=Simulator::Now(), Time SettlingTime=Simulator::Now(), bool changedEntries=false)
c-tor
Definition: dsdv-rtable.cc:41
The Routing table used by DSDV protocol.
Definition: dsdv-rtable.h:321
bool LookupRoute(Ipv4Address dst, RoutingTableEntry &rt)
Lookup routing table entry with destination address dst.
Definition: dsdv-rtable.cc:72
Time m_holddownTime
hold down time of an expired route
Definition: dsdv-rtable.h:471
bool DeleteRoute(Ipv4Address dst)
Delete routing table entry with destination address dst, if it exists.
Definition: dsdv-rtable.cc:111
bool ForceDeleteIpv4Event(Ipv4Address address)
Force delete an update waiting for settling time to complete as a better update to same destination w...
Definition: dsdv-rtable.cc:330
void Clear()
Delete all entries from routing table.
Definition: dsdv-rtable.h:384
bool AddRoute(RoutingTableEntry &r)
Add routing table entry if it doesn't yet exist in routing table.
Definition: dsdv-rtable.cc:128
void Setholddowntime(Time t)
Set hold down time (time until an invalid route may be deleted)
Definition: dsdv-rtable.h:459
bool DeleteIpv4Event(Ipv4Address address)
Clear up the entry from the map after the event is completed.
Definition: dsdv-rtable.cc:345
bool Update(RoutingTableEntry &rt)
Updating the routing Table with routing table entry rt.
Definition: dsdv-rtable.cc:136
Time Getholddowntime() const
Get hold down time (time until an invalid route may be deleted)
Definition: dsdv-rtable.h:451
std::map< Ipv4Address, RoutingTableEntry > m_ipv4AddressEntry
an entry in the routing table.
Definition: dsdv-rtable.h:467
void GetListOfDestinationWithNextHop(Ipv4Address nxtHp, std::map< Ipv4Address, RoutingTableEntry > &dstList)
Lookup list of addresses for which nxtHp is the next Hop address.
Definition: dsdv-rtable.cc:183
void Print(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print routing table.
Definition: dsdv-rtable.cc:270
void DeleteAllRoutesFromInterface(Ipv4InterfaceAddress iface)
Delete all route from interface with address iface.
Definition: dsdv-rtable.cc:148
EventId GetEventId(Ipv4Address address)
Get the EcentId associated with that address.
Definition: dsdv-rtable.cc:372
bool AddIpv4Event(Ipv4Address address, EventId id)
Add an event for a destination address so that the update to for that destination is sent after the e...
Definition: dsdv-rtable.cc:298
uint32_t RoutingTableSize()
Provides the number of routes present in that nodes routing table.
Definition: dsdv-rtable.cc:122
std::map< Ipv4Address, EventId > m_ipv4Events
an entry in the event table.
Definition: dsdv-rtable.h:469
bool AnyRunningEvent(Ipv4Address address)
Force delete an update waiting for settling time to complete as a better update to same destination w...
Definition: dsdv-rtable.cc:306
void Purge(std::map< Ipv4Address, RoutingTableEntry > &removedAddresses)
Delete all outdated entries if Lifetime is expired.
Definition: dsdv-rtable.cc:226
void GetListOfAllRoutes(std::map< Ipv4Address, RoutingTableEntry > &allRoutes)
Lookup list of all addresses in the routing table.
Definition: dsdv-rtable.cc:170
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.