A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
68  // \{
72  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
73  virtual void NotifyInterfaceUp (uint32_t interface);
74  virtual void NotifyInterfaceDown (uint32_t interface);
75  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
76  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
77  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
78  // \}
80  // \{
81  void SetEnableBufferFlag (bool f);
82  bool GetEnableBufferFlag () const;
83  void SetWSTFlag (bool f);
84  bool GetWSTFlag () const;
85  void SetEnableRAFlag (bool f);
86  bool GetEnableRAFlag () const;
87  // \}
88 
97  int64_t AssignStreams (int64_t stream);
98 
99 private:
101  // \{
105  uint32_t Holdtimes;
117  std::map<Ptr<Socket>, Ipv4InterfaceAddress> m_socketAddresses;
125  uint32_t m_maxQueueLen;
135  bool EnableWST;
147  // \}
148 
149 private:
151  void
152  Start ();
154  void
157  void
158  LookForQueuedPackets (void);
164  void
170  // \{
172  void
173  RecvDsdv (Ptr<Socket> socket);
174  // \}
175  void
179  LoopbackRoute (const Ipv4Header & header, Ptr<NetDevice> oif) const;
185  Time
188  void
191  void
193  void
196  void
202 
205 };
206 
207 }
208 }
209 
210 #endif /* DSDV_ROUTING_PROTOCOL_H */
void Start()
Start protocol operation.
static const uint32_t DSDV_PORT
UDP Port for DSDV control traffic.
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
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)
Callback template class.
Definition: callback.h:920
bool EnableRouteAggregation
This is a flag to enable route aggregation.
a simple Timer class
Definition: timer.h:45
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()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual void NotifyInterfaceDown(uint32_t interface)
double m_weightedFactor
This is the wighted factor to determine the weighted settling time.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
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:31
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.
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.
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:38
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:49
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...