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:
56  static TypeId
57  GetTypeId (void);
58  static const uint32_t DSDV_PORT;
59 
61  RoutingProtocol ();
62  virtual
64  virtual void
65  DoDispose ();
66 
67  // From Ipv4RoutingProtocol
71  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
72  virtual void NotifyInterfaceUp (uint32_t interface);
73  virtual void NotifyInterfaceDown (uint32_t interface);
74  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
75  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
76  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
77 
78  // Methods to handle protocol parameters
79  void SetEnableBufferFlag (bool f);
80  bool GetEnableBufferFlag () const;
81  void SetWSTFlag (bool f);
82  bool GetWSTFlag () const;
83  void SetEnableRAFlag (bool f);
84  bool GetEnableRAFlag () const;
85 
94  int64_t AssignStreams (int64_t stream);
95 
96 private:
97 
98  // Protocol parameters.
102  uint32_t Holdtimes;
114  std::map<Ptr<Socket>, Ipv4InterfaceAddress> m_socketAddresses;
122  uint32_t m_maxQueueLen;
132  bool EnableWST;
144 
145 private:
146 
148  void
149  Start ();
151  void
154  void
155  LookForQueuedPackets (void);
161  void
166 
167  // Receive dsdv control packets
169  void
170  RecvDsdv (Ptr<Socket> socket);
171 
172  void
176  LoopbackRoute (const Ipv4Header & header, Ptr<NetDevice> oif) const;
182  Time
185  void
188  void
190  void
193  void
199 
202 };
203 
204 }
205 }
206 
207 #endif /* DSDV_ROUTING_PROTOCOL_H */
void Start()
Start protocol operation.
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...
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.
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.
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.
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:219
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream) const
Print the Routing Table entries.
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)
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
UnicastForwardCallback m_scb
Unicast callback for own packets.
double f(double x, void *params)
Definition: 80211b.c:60
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 untill 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.
void RecvDsdv(Ptr< Socket > socket)
Receive and process dsdv control packet.
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 &)
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
Ptr< NetDevice > m_lo
Loopback device used to defer route requests until a route is found.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Provides uniform random variables.
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.
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...