A Discrete-Event Network Simulator
API
dsdv-routing-protocol.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, Yufei Cheng
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  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
20  *
21  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
22  * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
23  * Information and Telecommunication Technology Center (ITTC)
24  * and Department of Electrical Engineering and Computer Science
25  * The University of Kansas Lawrence, KS USA.
26  *
27  * Work supported in part by NSF FIND (Future Internet Design) Program
28  * under grant CNS-0626918 (Postmodern Internet Architecture),
29  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
30  * US Department of Defense (DoD), and ITTC at The University of Kansas.
31  */
32 
33 #ifndef DSDV_ROUTING_PROTOCOL_H
34 #define DSDV_ROUTING_PROTOCOL_H
35 
36 #include "dsdv-rtable.h"
37 #include "dsdv-packet-queue.h"
38 #include "dsdv-packet.h"
39 #include "ns3/node.h"
40 #include "ns3/random-variable-stream.h"
41 #include "ns3/ipv4-routing-protocol.h"
42 #include "ns3/ipv4-interface.h"
43 #include "ns3/ipv4-l3-protocol.h"
44 #include "ns3/output-stream-wrapper.h"
45 
46 namespace ns3 {
47 namespace dsdv {
48 
54 {
55 public:
60  static TypeId GetTypeId (void);
61  static const uint32_t DSDV_PORT;
62 
64  RoutingProtocol ();
65  virtual
67  virtual void
68  DoDispose ();
69 
70  // From Ipv4RoutingProtocol
85  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
86  virtual void NotifyInterfaceUp (uint32_t interface);
87  virtual void NotifyInterfaceDown (uint32_t interface);
88  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
89  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
90  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
91 
92  // Methods to handle protocol parameters
97  void SetEnableBufferFlag (bool f);
102  bool GetEnableBufferFlag () const;
107  void SetWSTFlag (bool f);
112  bool GetWSTFlag () const;
117  void SetEnableRAFlag (bool f);
122  bool GetEnableRAFlag () const;
123 
132  int64_t AssignStreams (int64_t stream);
133 
134 private:
135  // Protocol parameters.
139  uint32_t Holdtimes;
151  std::map<Ptr<Socket>, Ipv4InterfaceAddress> m_socketAddresses;
159  uint32_t m_maxQueueLen;
169  bool EnableWST;
181 
182 private:
184  void
185  Start ();
193  void
196  void
197  LookForQueuedPackets (void);
203  void
212 
213  // Receive dsdv control packets
218  void
219  RecvDsdv (Ptr<Socket> socket);
221  void
231  LoopbackRoute (const Ipv4Header & header, Ptr<NetDevice> oif) const;
237  Time
240  void
243  void
246  void
249  void
255 
258 };
259 
260 }
261 }
262 
263 #endif /* DSDV_ROUTING_PROTOCOL_H */
void Start()
Start protocol operation.
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:108
static const uint32_t DSDV_PORT
UDP Port for DSDV control traffic.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
bool GetWSTFlag() const
Get weighted settling time (WST) flag.
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketAddresses
Raw socket per each IP interface, map socket -> iface address (IP + mask)
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
Callback template class.
Definition: callback.h:1176
bool EnableRouteAggregation
This is a flag to enable route aggregation.
void MergeTriggerPeriodicUpdates()
Merge periodic updates.
A simple Timer class.
Definition: timer.h:73
Time m_periodicUpdateInterval
PeriodicUpdateInterval specifies the periodic time interval between which the a node broadcasts its e...
bool EnableBuffering
Flag that is used to enable or disable buffering.
ErrorCallback m_ecb
Error callback for own packets.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
bool EnableWST
Flag that is used to enable or disable Weighted Settling Time.
second
Definition: nstime.h:114
virtual void DoDispose()
Destructor implementation.
virtual void NotifyInterfaceDown(uint32_t interface)
double m_weightedFactor
This is the wighted factor to determine the weighted settling time.
void SendPacketFromQueue(Ipv4Address dst, Ptr< Ipv4Route > route)
Send packet from queue.
DSDV routing protocol.
DSDV Packet queue.
void SendPeriodicUpdate()
Broadcasts the entire routing table for every PeriodicUpdateInterval.
bool GetEnableRAFlag() const
Get enable route aggregation (RA) flag.
Packet header for IPv4.
Definition: ipv4-header.h:33
Ptr< Socket > FindSocketWithInterfaceAddress(Ipv4InterfaceAddress iface) const
Find socket with local interface address iface.
The Routing table used by DSDV protocol.
Definition: dsdv-rtable.h:319
uint32_t m_maxQueueLen
The maximum number of packets that we allow a routing protocol to buffer.
Ptr< Ipv4Route > LoopbackRoute(const Ipv4Header &header, Ptr< NetDevice > oif) const
Create loopback route for given header.
bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route input packet.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
static TypeId GetTypeId(void)
Get the type ID.
UnicastForwardCallback m_scb
Unicast callback for own packets.
double f(double x, void *params)
Definition: 80211b.c:72
Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
Time GetSettlingTime(Ipv4Address dst)
Get settlingTime for a destination.
void DeferredRouteOutput(Ptr< const Packet > p, const Ipv4Header &header, UnicastForwardCallback ucb, ErrorCallback ecb)
Queue packet until we find a route.
void LookForQueuedPackets(void)
Look for any queued packets to send them out.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_routeAggregationTime
Parameter that holds the route aggregation time interval.
Timer m_triggeredExpireTimer
Timer used by the trigger updates in case of Weighted Settling Time is used.
PacketQueue m_queue
A "drop front on full" queue used by the routing layer to buffer packets to which it does not have a ...
Time m_maxQueueTime
The maximum period of time that a routing protocol is allowed to buffer a packet for.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
void RecvDsdv(Ptr< Socket > socket)
Receive and process dsdv control packet.
bool GetEnableBufferFlag() const
Get enable buffer flag.
Ipv4Address m_mainAddress
Nodes IP address.
void SendTriggeredUpdate()
Sends trigger update from a node.
uint32_t m_maxQueuedPacketsPerDst
The maximum number of packets that we allow per destination to buffer.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
void Send(Ptr< Ipv4Route >, Ptr< const Packet >, const Ipv4Header &)
Send packet.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
a class to store IPv4 address information on an interface
void SetEnableRAFlag(bool f)
Set enable route aggregation (RA) flag.
Ptr< NetDevice > m_lo
Loopback device used to defer route requests until a route is found.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
void SetEnableBufferFlag(bool f)
Set enable buffer flag.
Abstract base class for IPv4 routing protocols.
Ptr< Ipv4 > m_ipv4
IP protocol.
RoutingTable m_advRoutingTable
Advertised Routing table for the node.
virtual void NotifyInterfaceUp(uint32_t interface)
tuple address
Definition: first.py:37
Timer m_periodicUpdateTimer
Timer to trigger periodic updates from a node.
void SetWSTFlag(bool f)
Set weighted settling time (WST) flag.
RoutingTable m_routingTable
Main Routing table for the node.
void Drop(Ptr< const Packet >, const Ipv4Header &, Socket::SocketErrno)
Notify that packet is dropped for some reason.
a unique identifier for an interface.
Definition: type-id.h:58
Time m_settlingTime
SettlingTime specifies the time for which a node waits before propagating an update.
Callback< void, Ptr< Ipv4Route >, Ptr< const Packet >, const Ipv4Header & > UnicastForwardCallback
Callback for unicast packets to be forwarded.
uint32_t Holdtimes
Holdtimes is the multiplicative factor of PeriodicUpdateInterval for which the node waits since the l...