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);
226  void
227  Send (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header);
228 
237  LoopbackRoute (const Ipv4Header & header, Ptr<NetDevice> oif) const;
243  Time
246  void
249  void
252  void
260  void
261  Drop (Ptr<const Packet> packet, const Ipv4Header & header, Socket::SocketErrno err);
266 
269 };
270 
271 }
272 }
273 
274 #endif /* DSDV_ROUTING_PROTOCOL_H */
double f(double x, void *params)
Definition: 80211b.c:70
Callback template class.
Definition: callback.h:1279
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
Packet header for IPv4.
Definition: ipv4-header.h:34
a class to store IPv4 address information on an interface
Abstract base class for IPv4 routing protocols.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
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
A simple virtual Timer class.
Definition: timer.h:74
a unique identifier for an interface.
Definition: type-id.h:59
DSDV Packet queue.
Timer m_triggeredExpireTimer
Timer used by the trigger updates in case of Weighted Settling Time is used.
void Send(Ptr< Ipv4Route > route, Ptr< const Packet > packet, const Ipv4Header &header)
Send a packet.
bool GetWSTFlag() const
Get weighted settling time (WST) flag.
static const uint32_t DSDV_PORT
UDP Port for DSDV control traffic.
Time m_periodicUpdateInterval
PeriodicUpdateInterval specifies the periodic time interval between which the a node broadcasts its e...
void Start()
Start protocol operation.
bool EnableBuffering
Flag that is used to enable or disable buffering.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
uint32_t m_maxQueuedPacketsPerDst
The maximum number of packets that we allow per destination to buffer.
void SetEnableRAFlag(bool f)
Set enable route aggregation (RA) flag.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
UnicastForwardCallback m_scb
Unicast callback for own packets.
void SendPeriodicUpdate()
Broadcasts the entire routing table for every PeriodicUpdateInterval.
PacketQueue m_queue
A "drop front on full" queue used by the routing layer to buffer packets to which it does not have a ...
void SetEnableBufferFlag(bool f)
Set enable buffer flag.
virtual void NotifyInterfaceDown(uint32_t interface)
void Drop(Ptr< const Packet > packet, const Ipv4Header &header, Socket::SocketErrno err)
Notify that packet is dropped for some reason.
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.
Ptr< NetDevice > m_lo
Loopback device used to defer route requests until a route is found.
bool GetEnableBufferFlag() const
Get enable buffer flag.
void SetWSTFlag(bool f)
Set weighted settling time (WST) flag.
Time GetSettlingTime(Ipv4Address dst)
Get settlingTime for a destination.
Timer m_periodicUpdateTimer
Timer to trigger periodic updates from a node.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
Time m_routeAggregationTime
Parameter that holds the route aggregation time interval.
bool EnableRouteAggregation
This is a flag to enable route aggregation.
void SendPacketFromQueue(Ipv4Address dst, Ptr< Ipv4Route > route)
Send packet from queue.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< Ipv4 > m_ipv4
IP protocol.
ErrorCallback m_ecb
Error callback for own packets.
Time m_maxQueueTime
The maximum period of time that a routing protocol is allowed to buffer a packet for.
virtual void NotifyInterfaceUp(uint32_t interface)
std::map< Ptr< Socket >, Ipv4InterfaceAddress > m_socketAddresses
Raw socket per each IP interface, map socket -> iface address (IP + mask)
Ptr< Ipv4Route > LoopbackRoute(const Ipv4Header &header, Ptr< NetDevice > oif) const
Create loopback route for given header.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
bool GetEnableRAFlag() const
Get enable route aggregation (RA) flag.
bool EnableWST
Flag that is used to enable or disable Weighted Settling Time.
Time m_settlingTime
SettlingTime specifies the time for which a node waits before propagating an update.
Ptr< Socket > FindSocketWithInterfaceAddress(Ipv4InterfaceAddress iface) const
Find socket with local interface address iface.
RoutingTable m_routingTable
Main Routing table for the node.
uint32_t Holdtimes
Holdtimes is the multiplicative factor of PeriodicUpdateInterval for which the node waits since the l...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void RecvDsdv(Ptr< Socket > socket)
Receive and process dsdv control packet.
virtual void DoDispose()
Destructor implementation.
void SendTriggeredUpdate()
Sends trigger update from a node.
RoutingTable m_advRoutingTable
Advertised Routing table for the node.
uint32_t m_maxQueueLen
The maximum number of packets that we allow a routing protocol to buffer.
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.
bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route input packet.
Ipv4Address m_mainAddress
Nodes IP address.
void MergeTriggerPeriodicUpdates()
Merge periodic updates.
double m_weightedFactor
This is the wighted factor to determine the weighted settling time.
The Routing table used by DSDV protocol.
Definition: dsdv-rtable.h:321
address
Definition: first.py:44
Every class exported by the ns3 library is enclosed in the ns3 namespace.