You are on page 1of 77

Improvement of Network Lifetime by Improving

Route Discovery Phase in Multi-Path DSR Using


Hybrid Ant Colony Optimization
Dissertation submitted in partial fulfillment of the requirement for the degree of

MASTER OF TECHNOLOGY
in
Computer Science & Engineering

Submitted by
RACHNA
Reg. No. 1079162660
Roll No.14M116

Under the Guidance of


Ms. NEHA GOYAL
Asst. Professor

Department of Computer Science & Engineering

Shri Ram College of Engineering and Management,


Palwal, Haryana

MaharshiDayanand University, Rohtak, Haryana

May 2016
CHAPTER 1

For more info: Https://ThesisScientist.com


INTRODUCTION

1.1 INTRODUCTION:
Mobile ad-hoc networks (MANETs) are particular type of networks in which the nodes
mobility is quite high. No node can join or leave to the network any time as there is no
centralized control and static infrastructure in MANETs. All nodes are considered to be
equal in processing power. The network is needed to have self configuration by means of
the cooperation among the mobile devices: all nodes works as routers and are able of
finding and managing paths to forward packets to their destinations node. The mobile
nodes movement needs the help of quite complicated routing algorithms, as routes are not
stable and require to be updated in a continuous way. Because of the dynamic behaviour
of MANETs, route management is quite complex task. Generally, Routing is the
phenomenon of selecting network paths along which the source can forward data packets
to the destination. Routing is a significant part of network communication because the
features i.e. reliability, throughput and congestion based upon the information of routing.
An ideal routing algorithm is one which is capable to send the packet to its destination
node with least network overhead and least amount of delay. The nodes maintain the
routing tables by exchanging routing information between the other network nodes. In
opposite with infrastructure networks, MANETs do not require centralized infrastructures
i.e. base stations. MANETs should be self-configured, self-built and adaptive to dynamic
modifications. In a traditional routing algorithm, which is unknown of energy budget,
links between two nodes are set up among nodes by the shortest path routes. The battery
power of mobile nodes is a restricted resource, and there is no way to permit a device to
live always, thus mechanisms to increase life of battery are relevant. Since, it results in a
frequent reduction of the battery energy of the nodes along the most usually utilized
network routes. A power-awareness routing protocol is the one that maintains the traffic
load inside the network so as to improve the nodes battery lifetime and thus the total
useful life of the ad hoc network.

For more info: Https://ThesisScientist.com


Figure 1.1: Mobile Ad Hoc Network
A mobile Ad - hoc Network is a network that makes from the cooperative engagement of
a set of hosts without any centralized access point. MANETS routing protocols are not
performed by routers, but performed by general hosts. The network configuration will also
change dynamically as the hosts move across the network and so the routing protocol
must be reliable enough to assure that data gets propagated correctly and effectively. Most
protocols show their minimum required behaviour in a highly dynamic configuration. This
has resulted in the requirement for novel routing protocols in MANETS. In some Adhoc
Networks, those two hosts that wish to interact may not be within the wireless
transmission range of each other, but could interact if other hosts between them also
playing role in the Ad hoc Network are wishing to send packets for them.

1.2 CATEGORIES OF AD-HOC ROUTING PROTOCOLS


Recently, the wireless networks that permit communication among mobile devices can be
categorized into the following two classes:
1. Networks having a static infrastructure: an example of this type of network is a cellular
phone network.
2. Networks that do not have a static infrastructure: this is a developing but highly
supporting and promising kind of network communication mechanism. There are various
situations where this type of network would be essential; mostly, in unplanned events i.e.
wars and natural disasters, but also in a planned event. This kind of network can be

For more info: Https://ThesisScientist.com


explained as a network of mobile devices that is generated or destroyed as required and
thus it is known as mobile ad hoc network or MANET. In wireless networks, physical
connections do not available and a single packet transmission will transfer a packet to
several nodes within the communication range of a transmitting node simultaneously. We
cal this inherent broadcast of MANETS local broadcast to differentiate it from global
broadcast.

Figure1.2: Categorization of ad hoc routing protocols


Some routing protocols have been introduced for MANET. These can be classified as
proactive (also called table driven) protocols, reactive (called source initiated or demand-
driven) protocols or the hybrid of the proactive and reactive protocols. A classification of
the high ad hoc routing protocols is depicted in Figure 1.2 Routing protocols in traditional
wired networks normally utilize either link state or distance vector routing algorithms,
both of which need periodic routing advertisements to be forwarded by every router. In
distance vector routing, every router forwards to each of its neighboring routers its view of
the distance to all hosts, and every router evaluates the shortest route to every host
depending on the information advertised by every neighbors. In link state routing, every
router instead forwards to all other routers in the network its status view of each of its
adjacent network connections, and every router then evaluates the shortest distance to
every host depending on the whole picture of the network built from the most recent
connection information from all routers. In addition to its usage in wired networks, the

For more info: Https://ThesisScientist.com


fundamental distance vector algorithm has also been followed for routing in wireless ad
hoc networks, necessarily treating every mobile host as a router.

1.3 DYNAMIC SOURCE ROUTING (DSR) PROTOCOL


The Dynamic Source Routing (DSR) protocol is a robust and simple routing protocol
intended particularly for utilize in multi-hop wireless ad-hoc networks of mobile nodes.
The Dynamic Source Routing protocol (DSR) depends on source routing, which implies
that the originator of every packet finds an ordered list of nodes through which the packet
must pass while propagating to the destination node. The DSR protocol contains two basic
techniques: Route Discovery and Route Maintenance
A. Route Discovery:
Route discovery is utilized only when a source node tries to forward a packet to a
destination and does not already aware of a route to it. To start the Route Discovery, the
source node sends a "Route Request" with a unique ID as a single local broadcast packet.
When some intermediary node obtains this Route Request, at first it detects whether it has
viewed the Route Request or not. If the node has already viewed the Route Request
former, it will drop the packet; otherwise it will examine its Route Cache whether there is
a path to the packet destination.

Figure1.3 (a): Path discovery with RREQ


If it has the path to target in its routing cache, it sends a "Route Reply" to the initiator of
the Route Discovery, providing a copy of the accommodated route record from the Route
Request; otherwise it forwards the Route Request until the Route Request is obtained by
the target .
B. Route Maintenance:
For more info: Https://ThesisScientist.com
DSR protocol carries out the route maintenance technique while communicating the
packets from source node to destination node. But when the communication connection
between the source and the destination node is broken or else a change in network
configuration is observed. It will cause to communication failure between source and
destination node. In this scenario DSR protocols utilizes the route mechanism, to
determine any other possible known route towards the destination node to transmit data. If
the route maintenance fails to detect an alternative known route to set up the interaction
then it will invoke the route discovery to discover the new route to destination node.

Figure1.3 (b): Example path between source and destination

C. ROUTE CACHE:
A host may utilize its route cache to neglect forwarding a route request packet obtained
from another host.
Consider a host obtains a route request packet for which it is not the destination, and is not
already stored in the packet route record, and for which the pair initiator address, request
id is not discovered in its list of currently viewed requests. If the host has a route cache
entry for the destination of the request, it may add this cache route to the accumulated
route record in the packet, and may return this route in a route response packet to the
initiator without forwarding the route request.
Before replying from its route cache a host performs the following actions.
1. Picks a delay period.
2. If packet is obtained by this host at the time of the delay period addressed to the
destination of this route discovery, and If the route length on this packet is less (delay

For more info: Https://ThesisScientist.com


period), then cancel the delay and do not transmit the route response from this host, this
host may infer that the route discovery initiator has already obtained a route response,
providing an equal or better route.
As last optimization including full use of the route cache, we have appended the capability
for the route request initiator to mention in the request packet, the maximum no of hops
over which the packet may be forwarded. If another host close to the initiator has a cache
entry for the destination of the route request, the propagation of some duplicate copies of
the route request can be neglected if the initiator can explicitly restrict the request
propagation when it is originally forwarded. Recently, we utilize this capability during
route discovery as follows.
1. To perform a route discovery, initially forward the route request with a hop limit of one.
We call this as a non propagating route request.
2. If no route response is obtained from this route request after a small time period,
forward a new route request with the hop limit set to a predefined maximum value for
which it is considered that all useful routes in the Ad hoc Network are less than this limit.

1.4 CHARACTERSTICS OF MANETs


A MANET consists of mobile platforms included combined router, host and wireless
communications platforms simply referred to as "nodes", which are free to move
anywhere in the network. The nodes may be located in or on airplanes, ships, trucks, cars,
perhaps even on people, and there may be multiple hosts per router. A MANET is an
autonomous system of mobile nodes. The system may operate in isolation, or may have
gateways to and interface with a fixed network--typically envisioned to operate as a stub
network connecting to a fixed internetwork.
Some salient characteristics of MANETs are as follows:
i. Dynamic Topologies: In MANET, nodes are free to move anywhere. Thus the topology
may change rapidly and randomly.
ii.Bandwidth-constrained, variable capacity links: Wireless links have significantly
lower capacity than their hardwired counterparts. In addition, the realized throughput of
wireless communications is very much less than a radios maximum transmission rate. As
the mobile network is often simply an extension of the fixed network infrastructure,

For more info: Https://ThesisScientist.com


mobile ad hoc users will demand similar services. These demands will keep on to increase
as multimedia computing and collaborative networking applications rise.
iii.Limited Physical Security: Wireless networks are more prone to security issues than
wired networks because comparably less research is done in this area. The high threats of
eavesdropping, spoofing etc. should be carefully considered before setting up such a
network. Although a benefit of MANETs lies in the decentralized approach which they
follow since it provides more robustness to single points of failure of centralized
approaches [12].
iv.Unpredictable link properties: Wireless media is very irregular. Packet collision is
intrinsic to

Figure1.4 (a): Hidden TerminalProblem Figure1.4 (b): Exposed Terminal Problem


Wireless network. Signal propagation faces difficulties such as signal fading, interference
and multi-path cancellation.
V. Hidden and Exposed Terminal Problems: In the MAC layer with the traditional
carrier sense multiple access (CSMA) protocol, multi-hop packet relaying introduces the
hidden terminal and exposed terminal problems. The hidden terminal problem
happens when signals of two, say B and C, which are out of the transmission range of
each other, collide at a common receiver, say node A. An exposed terminal is created
when a node A, is within range of and between two other nodes B and C, which are out of
range of each other. When A wants to transmit to one of them, node B for example, the
other node, C in this case, is still able to transmit to a fourth node, D which is in Cs range
(but out of the range of node A). Here A is an exposed terminal to C but can still transmit
to B [12].
For more info: Https://ThesisScientist.com
1.5 DESIGN ISSUES AND CHALLENGES
Ad hoc wireless networks have the traditional problems of wireless communications, such
as power control, bandwidth optimization, and enhancing the quality of transmission,
while, in addition, multi-hop nature, their mobility, and the lack of infrastructure causes a
number of complexities and design constraints.
(i) Quality of Service: For the successful communication of nodes in the network Quality
of Service (QoS) guarantee is very much essential. The different QoS metrics includes
packet loss, throughput, jitter, delay, and error rate.
(ii) Network Security: Mobile networks are more vulnerable to security threats than fixed-
wirednetworks. Mobile networks are more vulnerable to security threats because it uses
open and shared broadcast wireless channels means nodes with inadequate physical
protection. In addition, because a mobile ad hoc network is a infrastructure-less network,
since there is no centralized security control MANET mainly relies on individual security
solution from each mobile node.
(iii) Robustness and Reliability: MANET is multi-hop network, so network connectivity is
obtained by forwarding and routing among multiple nodes. Although MANET comes with
the advantage of infrastructure-less, it also causes design challenges. Due to various types
of failed links, a node may fail to forward the packet, like overload or acting selfishly.
Unreliable links misbehaving nodes and can have a severe impact on overall performance
of the network. Such types of misbehaviors cannot be find and isolated quickly because of
the lack of centralized monitoring and management mechanisms. This increases the design
complexity significantly.
(iv) Energy Constrained Operation: Each node in MANET is battery powered which
cannot be recharged. So if a node runs out of the energy then this may cause partitioning
of network. Since each node has limited power, energy becomes main threats to the
network lifetime. Additional energy is required to forward packets because each node is
acting as both a router and an end system at the same time .
(v) Limited Link Bandwidth and Quality: Since the mobile nodes communicate to each
other via wireless links it cause bandwidth-constrained, error-prone, variable capacity,

For more info: Https://ThesisScientist.com


since wireless links have significantly lower capacity than wired links and, hence, it
causes network congestion.
(vi) Dynamic Topology: The dynamically nature of ad hoc network causes to the
formation of an unpredicted topology. This topology change causes dropping of packets,
partitioning of the network and frequent changes in route.
(vii) Infrastructure- less network: The key aspect of an ad hoc network is its lack of
infrastructure, and most design issues and challenges come from this characteristic. Also,
it brings added difficulty in fault detection and correction because of lack of centralized
mechanism.

1.6 Ad Hoc On-Demand Distance Vector Routing (AODV)


AODV shares DSRs on-demand characteristics in that it also discovers routes on an as
needed basis via a similar route discovery process. However, AODV adopts a very
different mechanism to maintain routing information. It uses traditional routing tables, one
entry per destination. This is in contrast to DSR, which can maintain multiple route cache
entries for each destination. Without source routing, AODV relies on routing table entries
to propagate an RREP back to the source and, subsequently, to route data packets to the
destination. AODV uses sequence numbers maintained at each destination to determine
freshness of routing information and to prevent routing loops. All routing packets carry
these sequence numbers.
An important feature of AODV is the maintenance of timer-based states in each node,
regarding utilization of individual routing table entries. A routing table entry is expired if
not used recently. A set of predecessor nodes is maintained for each routing table entry,
indicating the set of neighboring nodes which use that entry to route data packets. These
nodes are notified with RERR packets when the next-hop link breaks. Each predecessor
node, in turn, forwards the RERR to its own set of predecessors, thus effectively erasing
all routes using the broken link. In contrast to DSR, RERR packets in AODV are intended
to inform all sources using a link when a failure occurs. Route error propagation in AODV
can be visualized conceptually as a tree whose root is the node at the point of failure and
all sources using the failed link as the leaves.

For more info: Https://ThesisScientist.com


Figure1.5: AODV route discovery

1.6.1 Hybrid Protocols. (Combination of Reactive and Proactive protocols)


Zone Routing Protocol (ZRP)
The Zone Routing Protocol (ZRP) was introduced in 1997 by Haas and Pearlman. It is
either a proactive or reactive protocol. It is a hybrid routing protocol. It combines the
advantages from proactive and reactive routing. It takes the advantage of pro-active
discovery within a node's local neighborhood (Intrazone Routing Protocol (IARP)), and
using a reactive protocol for communication between these neighborhoods
(InterzoneRouting Protocol (IERP)).The Broadcast Resolution Protocol (BRP)is
responsible for the forwarding of a route request. ZRP divides its network in different
zones. That's the nodes local neighborhood. Each node may be within multiple
overlapping zones, and each zone may be of a different size. The size of a zone is not
determined by geographical measurement. It is given by a radius of length, where the
number of hops is the perimeter of the zone. Each node has its own zone.

1.6.2 Comparison of Proactive (Table-driven) and Reactive (On-demand) routing


protocols

Table-driven On-demand

For more info: Https://ThesisScientist.com


Attempt to maintain consistent, up-to date A route is built only when required.
routing information from each node to every
other node in the network.

Constant propagation of routing information No periodic updates. Control information is not


periodically even when topology change does propagated unless there is a change in the
not occur. topology.
First packet latency is less when compared with First-packet latency is more when compared
on-demand protocols with table-driven protocols because a route need
to be built
A route to every other node in ad-hoc network Not available.
is always available
Table1.6.2: Comparison of Proactive and Reactive routing protocols

1.6.3AODV vs. DSR


Dynamic Source Routing (DSR)[26] is commonly compared with AODV. Even though is
a multi-hop protocol and reactive protocol, route discovery mechanism is different. The
most prominent difference is that DSR uses the source routing in which each packet
contains the route to the destination in its own header. Therefore, intermediate nodes do
not need to maintain up-to-date routing information in order to forward data packets.
Another unique feature of DSR is packet salvaging. When an intermediate node detects
the broken link to the next hop, the node begins to find an alternative route instead of
discarding the data packet. In our experiments in NS2, we found that the packet salvaging
causes the extension of end-to-end delay.
Routing Overhead
Since more control packets are required at the route discovery phase and extra control
packets are required periodically to monitor the condition of the paths, the routing
overhead of ADSR is slightly higher than that of other protocol. The overhead for path
monitoring can be reduced by piggybacking the pheromone information on data packets if
appropriate traffic exists in opposite direction. Higher mobility causes more links broken
and frequent re-routing and thus causes larger routing overhead. Because of the periodic

For more info: Https://ThesisScientist.com


updates, ADSR requires certain amount of routing overhead constantly. The routing
overhead due to mobility is slightly higher than that of DSR due to the use of FANTs and
BANTs control packets.

1.6.4Comparison table of DSR and ADSR


Paramete DSR ADSR
r

Type On-Demand Routing Protocol On-Demand Routing Protocol

Route Discovery Procedure RREQ and RREP are used Pheromone value is used

Path Discovered Single, partially multipath Multipath

Link failure detection RERR Decrease of Pheromone Value

Type of Agents TCP FANT, BANT

Throughput Low High

Table1.6.4: Comparison of DSR and ADSR

1.7 Features of Mobile Ad hoc Network


The features of mobile Ad hoc networks are as follows:
Autonomous terminal
Distributed operation
Multi-hop routing
Dynamic network topology
Instable link capacity
Thin terminals

For more info: Https://ThesisScientist.com


Autonomous Terminal:Each mobile in a mobile ad-hoc network node is an
autonomous node, which acts as both a host and a router. In other words we can
say, beside the basic processing capability as a host, these mobile nodes can also
perform switching functions as a router. So generally switches and endpoints are
very similar in MANET.
Distributed Operation:As there is no central controller for the network
operations, the control and management of the network is scattered among the
terminals. The nodes which are involved in a MANET should collaborate and
communicate with each other. In MANET, each node acts as a relay as needed, to
implement the particular functions like routing and security [2].

Multi-hop Routing: Single-hop and Multi-hop arethetwomainbasic types of Ad


hoc routing algorithms which are based on hard link layer characteristics and
routing protocols. Single-hop routing is simpler and securer than the multi-hop
routing regarding structure and implementation, with the lesser cost of
applicability and functionality. When a data packets is delivered from source to the
destination out of the direct wireless transmission zone, then the data packets
should be forwarded via one or more median nodes.

Dynamic Network Topology:The network topology may change randomly and


rapidly due to the mobility of nodes and therefore the connectivity among the
terminals may fluctuate with time. MANET should modify the traffic, propagation
conditions as well as the mobility patterns of the mobile network nodes. Mobile
nodes dynamically create routing of their own as they move about, forming their
own network on the flyin the network. Furthermore, a user in a mobile ad-hoc
network not only operates within the Ad hoc network, but also need the access to a
public fixed network for e.g. Internet.

Fluctuating Link Capacity:The wireless connection has a tendency of high bit-


error rates which may be more intense in a MANET. Several sessions shared a one
end-to-end path. Various terminals can communicate over channel which is related
For more info: Https://ThesisScientist.com
to fading, noise, and interference, and has less bandwidth than a wired network. In
fewscenarios, the path between any couple of users can traverse multiple wireless
links and the link itself can be miscellaneous.

Light Weight Terminals:Generally, the MANET nodes are mobile devices which
have less CPU processing capability, less memory size, and low power storage.
These devices require optimized algorithms and procedure that execute the
computing functions andcommunicating.

1.8 Challenges of Mobile Ad hoc Network


Ad hoc networking has become a favored field of study in the last few years. . Every
aspect of the network has been found in one way or other way at various level of problem.
Yet, no permanent solution to any of the problems is found or, at least, agreed upon. In
contrast, more questions have been raised. The topics that require to be solved are as
follows-
Scalability
Routing
Quality of service
Client server model shift
Security
Energy conservation
Node cooperation
Interoperation
The mechanism to solve above aspects has been proposed and possible update solutions
have been discussed. In this current research work one of the aspects the routing has
been reviewed for appropriate protocol which is performing better under the dynamic
condition of network.

Scalability:Most of the innovative thinkers portraying applications which are


anticipated to benefit from the Ad hoc network technology take scalability as

For more info: Https://ThesisScientist.com


granted. For example, assume that, the vision of omnipresent computing where
networks can be of "any size". However, it is doubtful that how such large network
can actually grow. Ad hoc networks can suffer, from the scalability problems in
volume, by nature. The throughput per node decline at a rate 1/N, where N is the
number of nodes, in a non-cooperative network, where Omni-directional antennas
are being utilised. That means, in a network with 110 nodes, a device can get,
maximum, about one tenth of the theoretical network data rate. This problem,
cannot be resolved except by the advancement of physical layer, such as
directional antennas. If the available capacity like bandwidth,radiation pattern of
antenna sets some restrictions for communication. This requires the formation of
new protocols to overcome circumvents. Route acquisition,service location
encryption key exchanges, are some of the examples of tasks that will need
considerable overhead as the network size grows. If the scarcely available
resources are lost with profuse control traffic, then these networks may see never
the day dawn. Hence, scalability is a hot research topic and needs to be taken into
account for the design of solutions for Ad hoc networks.

Routing: Routing in wireless Ad hoc networks is necessary due to highly dynamic


environment. An Ad hoc network is a bunch of wireless mobile nodes differently
creating a temporary network without the use of any centralized administration or
pre-existing network infrastructure. In a typical Ad hoc network, mobile nodes
arise simultaneously for some period of time to exchange information over the
network. During the interchange of information, the nodes may continue to move,
and so the network must be prepared to establish routes continuously among
themselves without any external support.
Quality of Service (QOS):The heterogeneity of existing Internet applications
gave a summon to network designers. These network designers make the network
to serve best-effort service only. Live video, voice and file transfer are some of the
applications having very manifold requirements. Qualities of Service aware
solutions are created to meet the emerging requirements of these applications.
QOS is guaranteed by the network which helps in providing certain performance

For more info: Https://ThesisScientist.com


for a given flow, or a collection of flows regarding QOS parameters like jitter,
bandwidth, delay, packet loss probability, and so on. In spite of the current
research efforts in the QOS area, QOS is still an untraversed area in Ad hoc
networks. Some issues of QOS are robustness, QOS in routing algorithms,policies
and protocols with multipath, and pre-emptive, priorities remain to be addressed.
Client-Server Model Shift:A network client is usually designed to use a server as
its partner for network transactionsin the Internet. These servers can be found
either by static configuration orautomatically. In Ad hoc networks, the network
formation cannot be defined by assembling IP addresses into subnets. There may
not be servers, but the basic services demand still exists. Authentication, name
resolution, service location and address allocation itself are some examples of the
very basic services which are required but their location in the network is possibly
even changing over time andstill unknown. Because of the infrastructure less
nature of these networks and node mobilitya different addressing approach is
required. Besides, it is still unclear that who is responsible for managing various
network services. Hence, while there has been a large scale research initiative in
this area, the issue of shift from the traditional client-server model remains to be
properly addressed.
Security:Security is an essential issue that has to be addressed in Ad hoc
networks. Many applications of MANET such as Military and Confidential
Meetings require intense security against active/passive eavesdropping attacker
andenemies. Ad hoc networks are particularly prone to malicious behaviour. Any
centralized infrastructure or lack of certification authority makes these dynamically
changing wireless structures very vulnerable to infiltration, interference,
eavesdropping and so on. Security is considered to be the main "roadblock" for
commercial application.
Energy Conservation:Within the Ad hoc networking research energy protective
networks have become very popular. At this time, energy preservation is being
addressed in every layer of the protocol stack. There are two main research topics
which are maximization of the lifespan of the whole network and maximization of
existence of a single batterywhich are almost identical. The latter is associated with

For more info: Https://ThesisScientist.com


commercial applications and node cooperation issues while the former is more
fundamental, for example, in military environments where node cooperation is
expected. The goals can be fulfilled either by developing batteries better than
before, or by making the network terminals operation more energy efficient. The
first perspective gives a 50% increase in battery life in the near approach. As to the
power consumption of the device, the primary aspect are achieving to the energy
savings through the low power hardware development using some techniques such
as variable clock speed CPUs, flash memory, and disk spin down. However, from
the networking point of view, our interest should focuses on the device's network
interface, which is often consumes largest power. At the network interface, energy
efficiency can be improved by developing transmission/reception technologies on
the physical layer. Much research has been carried out at three layers which are the
physical, medium access control (MAC) and routing layers, while some little
research has been done at the transport and application layers. Yet, there is still
much more investigation to be carried out.
Node (MH) Cooperation:The node cooperation stands in the way of commercial
application of the technologybecause it isclosely related to the security issues.
There is no alternative to receive the corresponding services from others but one
has to depend on other peoples data. However, when there is a difference found in
amount and priority of the data, the situation becomes further more complicated.
Also, it should not denied access to other nodes because of such limited behaviour.
Encouraging nodes may cooperate which lead to the introduction of billing, similar
to the idea referred for Internet congestion control. Reward could be given to some
well-behaving network members. While malicious node could be charged with
higher rates. The implementation of any kind of billing process is a very
challenging task. These issues are still largely open.
Interoperation:The self-organization of Ad hoc networks is a difficult task when
two independent formed networks come physically close to each other. This is yet
an unexplored research subject that has implications on all levels of the system
design. When two independent Ad hoc networks move into same area whose
interference with each other becomes inevitable. Preferably, the networks would

For more info: Https://ThesisScientist.com


recognize the condition and be merged. However, the issue of joining two
networks is not important. These networks might be using different
synchronization, or even several routing or MAC protocols. However, security is a
major concern. For example; a situation like a military unit moving into an area
covered by a sensor network where different routing protocol can be used by
military moving unit with location information support, whereas the sensor
network would have a easier stable routing protocol. One of the most important
objective of recent research on all wireless networks is to provide smooth
integration of all types of networks.

1.9Issues to be considered when deploying MANET


Some of the main routing issues to be considered when establishing MANETs are as
follows:
Unpredictability of Environment
Reckless nature of Wireless Medium
Amenity-Constrained Nodes
Dynamic Topology
Transmission Errors
Node Failures
Connection Failures
Route malfunction
Overfull Nodes or Links
Unpredictability of Environment: Ad hoc networks may be situated in
dangerous conditions, unknown territories, and even aggressive environments
where tampering or the actual destruction of a node is about to happen. Depending
on the environment, node can be failed frequently.
Unreliability of Wireless Medium: Communication over the wireless medium is
reckless and subjected to errors. The quality of the wireless link is uncertain due to
varying environmental conditions such as inclement weather or high levels of
electro-magnetic interference (EMI).

For more info: Https://ThesisScientist.com


Resource-Constrained Nodes: MANET nodes are generally battery powered as
well as limited in processing and storage capabilities. MANET nodes may be
situated in areas where it is not possible to re- charge and thus they have limited
lifetimes. Due to these constraints, they must have algorithms which are energy
efficient. These algorithms can also be operated with restricted processing and
memory resources. The wireless medium may also have limited bandwidth
because these nodes may not be able to sacrifice the energy consumed by operating
at full link speed.
Dynamic Topology: As nodes are free to move anywhere in an Ad-hoc network,
the topology of the network may change constantly. As nodes can move in and out
of range of each other, some links break while new links are created between
nodes. As a result, MANETs are vulnerable to several types of faults.
Transmission Errors: The unreliability and unpredictability of the wireless
medium and the environment respectively may lead to transmitted packets being
distorted and thus received packet errors.
Node Failures: Due to different types of harmful conditions in the environment,
MANETnodes may fail at any time. MANET nodes may leave the network either
voluntarily or when their energy supply is depleted.
Link Failures: Either changing environmental conditions (e.g., increased levels of
EMI) or node failures may cause links between nodes to break. Because of the link
failures source node has to discover new routes through other links.
Route Breakages: If the network topology is changed due to node/link failures
and/or node/link additions to the network, then the route becomes out-of-date and
thus incorrect. Packets are forwarded through stale routes may either eventually be
dribble or be detained depending upon the network transport protocol.
Congested Nodes or Links: Because of the dynamic topology of the network and
the nature of the routing protocol, certain nodes or links may become over
congested. This will lead to either packet loss or larger delays.

1.10Applications of Mobile Ad hoc Network

For more info: Https://ThesisScientist.com


Ad hoc networks are best suited for use in circumstances where an infrastructure is
unavailable or to deploy one is not cost effective. The following are some of its important
applications.
Business Applications: One of the use of mobile Ad hoc networks is in some
business environments, where the need for Gray Hole computing might be more
important outside the office environment than inside, like in a business meeting
outside the office to brief clients on a given assignment. Work has been done on to
introduce the some basics concepts of game theory and its applications in
telecommunications. Game theory arises from economics and has been
successfully applied in various fields. Gametheory tackles with multi-person
decision making, in which each decision maker tries to maximize its utility. The
coordination among users is necessary to the operation of Adhoc networks; hence,
game theory provides a good basis to analyse the networks. Generally people
playing multi-player games over the Internet, with a remote host. This model is
known as the client-server model. In case of multiple users, each user just connects
to a common server, and the common server forwards the data packets to the
connected users.
Military Applications:Military applications have encouraged early research on
Ad hoc networks. The Ad-hoc networks have the ability to quickly set up a
network among military units in hostile territory without any infrastructure support
and can provide friendly forces with a considerable tactical benefit on the
battlefield. For instance, in the battlefield each soldier can carry a mobile device
that represents one of the mobile nodes in an Ad hoc network linking all soldiers,
tanks, and other vehicles as. Recent improvements in robotics have also gave the
idea of automated battlefields in which unmanned fighting vehicles are sent into
battle. Supporting military applications requires self-organizing and self-
configuring mechanisms that provide robust and reliable communication in
dynamic battle situations.
Emergency Operations:Emergency services are another promising application
area for Ad hoc networks, which includes search, rescue and disaster recovery
operations. For an example of search and rescue, assume an airline which attaches

For more info: Https://ThesisScientist.com


small wireless devices to the life jackets under each seat. Now assume that the
plane has some mechanical problems and has to make an emergency landing in the
water.

CHAPTER 2
LITERATURE REVIEW

2.1 RELATED WORK:


A Systematic literature review is a means of identifying, evaluating and interpreting
all available research relevant to a particular research question, topic or
phenomenon of interest. Systematic reviews aims to present a fair evaluation of a research
topic by using a trustworthy, rigorous and auditable methodology. A systematic literature
review synthesizes existing work in a manner that is fair and seen to be fair. Systematic
review must be undertaken in accordance with a predefined search strategy. The search
strategy must allow the completeness of the research to be assessed. In particular,
researchers performing a systematic review must make every effort to identify and
report research that does not support their preferred research hypothesis as well as
identifying and reporting research that supports it. Systematic reviews are mainly
undertaken to summarize the existing evidence, identifying the gaps in current
research and providing a framework for new research activities.

Ammar Odeh et al.[1]:In this paper, authors analyze a MANETs performance for two
proactive protocols; Ad Hoc On-Demand Distance Vector (AODV) Protocol, and
Dynamic Source Routing (DSR) Protocol. By using network simulator NS2, we setup and
evaluate the performance of AODV and DSR protocols with respect to the packets size.
The different performance metrics were investigated with respect to packets size. DSR
has shown better performance in terms of efficiency for a packet size less than 700 bytes.

For more info: Https://ThesisScientist.com


In our simulation, we are studying the relation between different MANET performance
parameters with respect to packets size.

Aarti et al.[2]: In this paper, authors explained the characteristics, challenge, application,
security goal and different types of security attacks in mobile ad-hoc network. Ad-Hoc
network routing protocols are commonly divided into three main classes; Proactive ,
reactive and hybrid protocols .In MANET, all networking functions such as routing and
packet forwarding, are performed by nodes themselves in a self-organizing manner.
MANET vulnerable to various kinds of security attacks like warm hole, black hole,
rushing attack. Attacks are classified into two categories. Active attack and passive
attacks.

Chintan kanani et al.[3]: In this paper, authors modified the ad hoc on demand multipath
distance vector (AOMDV) for multipath routing using ant colony for MANET. In these
authors describe the difference between ant-AODV and AOMDV on their working that in
case of ant-AODV, RREQ message packets are sent to single path, in case of ant
AOMDV RREQ message packet are sent to multiple path. The differences between both
protocols are shown by using performance matrices packet delivery fraction, normal
routing load and packet drop. The main focus of the work is to reduce the routing
overhead, congestion and increase the performance Cygurin and NS-allinane 2.34
simulation tool is used.

Dweepna Garg et al.[4]:In this paper, authors present a new routing algorithm for
mobile, multi-hop ad-hoc networks. The protocol is based on swarm intelligence. Ant
colony Algorithms are a subset of swarm intelligence and consider the ability of simple
ants to solve complex problems by cooperation. The biggest challenge in this kind of
networks is to find a path between the communication end points, what is aggravated
through the node mobility. Routing of data packets is only through optimal path which is
generated by route discovery phase as defined by ACOR. Route maintenance is done
periodically to retain optimal path. The main goal in the design of the protocol is to reduce
the overhead for routing and refer to the protocol as the Ant Colony Optimization Routing
(ACOR).

For more info: Https://ThesisScientist.com


Diya Naresh Vadhwani et al.[5]: In this Paper, Authors analysis the performance of DSR
reactive Manet routing protocols is made for throughput and delay using the opnet
simulation tool. The DSR protocol is analyzed on the basis of HTTP traffic because today
the internet applications are more important for secure communication. DSR is reactive
Manet routing protocol. Here the DSR routing protocol is analyzed with HTTP. The
traffic parameters like DSR routing traffic received and Sent are analyzed for 50, 70 and
100 nodes. The HTTP traffic Received and Sent is also analyzed for 50, 70 and 100 nodes.
From the above simulation the performance matrices like throughput and delay are
analyzed for 50, 70 and 100 mobile nodes for dsr Manet routing protocol. From above it is
observed analysis that throughput is more in 100 nodes than 50 and 70.Also the delay is
less for 70 nodes than 50.

Dr. S.S.Dhenakaran et al.[6]:This paper concentrates on routing techniques which is the


most challenging issue due to the dynamic topology of ad hoc networks. There are
different strategies proposed for efficient routing which claimed to provide improved
performance. There are different routing protocols proposed for MANETs which makes it
quite difficult to determine which protocol is suitable for different network conditions
.Authors provides an overview of different routing protocols and also provides a
comparison between them. In this paper a number of routing protocols for MANET,
which are broadly categorized as proactive and reactive and Hybrid protocols. The effort
has been made on the comparative study of Reactive, Proactive and Hybrid routing
protocols has been presented in the form of table.

G.vijaya kumar et al.[7]: In this paper, authors explain the number of routing protocol of
MANET. In MANET, nodes move arbitratily.nodes has limited transmission ranged by
which some nodes cannot communicate directly with each other. Authors describe
proactive and reactive routing protocol. Proactive routing protocol is used when the
network is relatively static, on the other hand, when mobility of nodes in network
increase, reactive protocol is used. In any network, selection of routing protocol is based
on mobility and traffic pattern of the network.

For more info: Https://ThesisScientist.com


M.Sailaja et al.[27]:In this paper authors showed a review on the nature inspired routing
algorithm obtained from the ant colony and bee colonies oriented towards MANETs. The
objective of this survey is to provide better understanding of the potentials of Nature-
inspired routing protocols which is currently far from being fully recognized. MANETs
are highly dynamic and distributed in nature. The researches done have shown that nature
inspired routing protocols can remove at least one or several problems in the area such as
battery life, scalability, maintainability, survivability, adaptability and so on. In this paper
authors presented a survey on the nature inspired routing algorithms derived from the ant
colonies and bee colonies oriented towards the MANETs. Through this work authors tried
to explore the potential of the nature-inspired networking in developing solutions to the
wide array of challenges in routing and network management.

Neha bora et al.[28]: In this paper, authors proposed a new routing algorithm for
MANETs, which combines the idea of ant colony optimization (ACO) with split multipath
routing (SMR) protocol. This new routing algorithm is used to overcome the disadvantage
of single path routing. As single path routing protocol causes increase the call blocking
probability and decrease overall network utilization. to alleviate these problem, new
multipath routing algorithm for MANET is proposed, that is called ACO-SMR routing
algorithm. It based on swarm intelligence and especially on the ant colony based Meta
heuristics. This algorithm improved the performance of network such as delay and packet
delivery ratio than traditional routing algorithm.

N.Umapathi et al.[33]:This paper examined the DSR performance, ACO mechanism


with respect to packet delivery ratio by utilizing OPNET simulator tool. The paper
presents a protocol for routing in ad hoc networks using Dynamic Source Routing (DSR)
and Swarm Intelligence based on Ant Colony Optimization (ACO) to optimize the node
pause time. The simulation results shows that the improved performance of routing in the
network. Ant Colony Optimization is popular among Swarm Intelligent Techniques. Ant
based routing algorithms attracted attention of researchers as they are highly robust,
reliable, and Scalable than conventional routing algorithms. As they do not use extra
message exchanges for path maintenance during network topology change, they suit
MANETs where nodes move dynamically and topology changes regularly. The simulation

For more info: Https://ThesisScientist.com


results show that the algorithm builds routes based on node pause time achieving better
packet delivery ratio and end-to-end delay.

Puneet Mittal et al.[34]:In this paper, authors showed the comparison between 825km,
1000km and 1300km distance in DSR protocol with traffic load FTP with respect to data
dropped, load, media access delay and network load by utilizing OPNET simulator.Inthis
paper, by changing their internodes distances, we compare the performance of Mobile ad
hoc network (MANET). In this paper, we compare protocols DSR by using changing their
internodes distances. The resultsare taken in tabular form as well as graphical form by
using OPNET Simulator 14.5. The results show that which distance area is better for DSR
protocol corresponding to FTP traffic load for some important parameters.

Richa Sharma et al.[36]: Authors explained the mobile adhoc network, dynamic source
routing protocol and ant colony optimization technique.DSR protocol is used for finding
the available route that does not gives the best path to send the packet from source to
destination, for that, to find the best path, ACO technique is used. By using ACO
technique, the efficiency of network or lifetime of network can be increased.ACO is a
natured inspired algorithm. it has been found that ACO gives better result as it is based
upon the technique of swarm intelligence(SI) which is capable for finding the adaptive
routing for such type of network.

Smriti Sofat et al.[47]: In This paper, Authors outlines the experience with the
implementation of Ant colony Technique on reactive routing protocol DSR and improves
the performance of it. In this paper, the comparative analysis of the two routing protocols,
namely DSR and ANT-DSR (ADSR) has been shown. By simulation using network
simulator shows that this method improves the performance of DSR. Authors evaluated
and compared ACO based algorithm to the original ones and obtained better results in
terms of throughput and delay jitter etc. for environments of dynamic topology.

Singh Ajay Vikram et al.[48]: In this research paper, authors proposed a new search
strategy for reactive route discovery which is based on two Qos parameters minimum
bandwidth requirement and maximum allowable end to end delay. DSR has less overhead

For more info: Https://ThesisScientist.com


and require less convergence time if an existing route is failed. In DSR protocol periodic
routing updates or routes advertisement are not disseminated by a node to its neighbors
and DSR does not perform link status sensing, these features make DSR a protocol with
less overhead. In this NS-2 simulation tool is used to compare the performance of the
proposed approach (QUS-DSR) with existing routing protocol (DSR) in scenarios of
increasing speed of node mobility.

Sachin dnyandeo ubarhands et al.[49]: Here authors evaluate the performance of


AODV and DSR routing protocol by taking some performance matrices such as packet
sent ratio and throughput. In this paper, authors had been made to compare the
performance of two prominent on demand reactive routing protocol for MANET: Ad hoc
on demand distance vector (AODV), dynamic source routing (DSR) protocol.DSR and
AODV is a reactive gateway discovery algorithm where a mobile device of MANET
connects by gateway only when it is needed. The performance differentials are analyzed
using varying matrices. These simulations are carried out using the NS-2 network
simulator. From the result, author conclude that as speed of mobile nodes changes low to
high DSR protocol delivered the better performance in terms of less tcp packet dropped
than AODV routing protocol.

CHAPTER 3
BACKGROUND STUDY

3.1 Ad-Hoc Networks


Ad-Hoc networks have no organization where the nodes are free to join and left the
network. The nodes are interconnected with each other via a wireless link. A node can
serve as a router to forward the data to the neighbors nodes. Therefore this type of
network is also recognized as infrastructure less networks. These networks have no
centralized consolidate administration. Ad-Hoc networks have the abilities to handle any
malfunctioning in the nodes or any variations that its know-how due to topology changes.
Whenever a node in the network is down or leaves the network that causes the link among
other nodes is broken. The affected nodes in the network simply request for new routes

For more info: Https://ThesisScientist.com


and new links are established Ad-Hoc network can be considered in to static Ad-Hoc
network (SANET) and Mobile Ad-Hoc network (MANET).

3.2 Static Ad-Hoc Networks


In static Ad-Hoc networks the geographic location of the nodes or the stations are fixed.
There is no flexibility in the nodes of the networks, thats why they are known as static
Ad-Hoc networks.

3.3 Mobile Ad-Hoc Networks


Mobile Ad-Hoc network is an independent system, where nodes/stations are connected
with each other through wireless links. There is no limitations on the nodes to join or
leave the network, therefore the nodes join or leave spontaneously. Mobile Ad-Hoc
network topology is dynamic that can change swiftly because the nodes move freely and
can organize themselves arbitrarily. This property of the nodes makes the mobile Ad-Hoc
networks random from the point of view of scalability and topology.

Figure3.1: Flow of Data Packets in MANET

Mobile Ad-Hoc network topology is active that can change rapidly because the nodes
move freely and can organize themselves randomly. This possession of the nodes makes

For more info: Https://ThesisScientist.com


the mobile Ad-Hoc networks unpredictable from the point of view of scalability and
topology.

3.3.1 Characteristics of MANET


When a node wants to communicate with another node, the destination node must lies
within the radio zone of the source node that wants to initiate the communication. The
intermediate nodes within the network supports in routing the packets for the source node
to the destination node. These networks are fully self-structured, having the ability to
work anywhere without any infrastructure. Nodes are autonomous and play the character
of router and host at the same time. MANET is self governing, where there is no
centralized control and the communication is carried out with blind mutual belief between
the nodes on each other. The network can be set up anywhere without any geographical
limitations. One of the limitations of the MANET is the limited energy resources of the
nodes.

3.3.2 Types of Mobile Ad-Hoc Network


Vehicular Ad-Hoc Networks (VANETs)
Intelligent Vehicular Ad-Hoc Networks ( InVANETs)
Internet Based Mobile Ad-Hoc Networks (iMANETs)

Vehicular Ad-Hoc Networks (VANETs)


It is a type of Mobile Ad-Hoc network where vehicles are fortified with wireless and form
a network without help of any infrastructure. The equipment is located inside vehicles as
well as on the road for providing access to other vehicles in order to establish a network
and interconnect to communicate.
Intelligent Vehicular Ad-Hoc Networks (In-VANETs):
Vehicles that form Mobile Ad-Hoc Network for communication via WiMAX IEEE
802.16 and Wi-Fi 802.11. The main objective of designing In-VANETs is to ignore
vehicle collision so as to retain passengers as safe as possible. This also helps drivers to
retain protected distance among the vehicles as well as contribution them at how much
speed other vehicles are approaching. In-VANETs applications are also active for
military purposes to communicate with each other.

For more info: Https://ThesisScientist.com


Internet Based Mobile Ad-Hoc Networks (i-MANETs):
These are used for connecting up the mobile nodes and fixed internet gateways. In these
networks the normal routing algorithms does not apply [2].

3.3.3 Applications of MANET


The properties of MANET make it so much positive that would bring so many aids. There
are so many research areas in MANET which is under studies now. The most significant
area is vehicle to vehicle communication where the vehicle would communicate with each
other, keeping a secure distance between them as well as collision notices to the drivers.
MANET can be used for automated battlefield and war games. One of the most important
areas where MANETs are applied is emergency services such as disaster recovery and
relief activities, where out-dated wired network is already destroyed. There are so many
other application areas for instance entertainment, education and commercial where
MANETs are playing their vital character for connecting people.

3.3.4 Short comings of Mobile Ad-Hoc Networks


Certain drawbacks of MANETs are as follows.
Limited Resources.
Scalability issues.
No dominant check on the network.
Dynamic topology, where it is hard to find out malevolent nodes.
3.3.5 MANETs Routing Protocols
Mobile Ad-Hoc Network is the swiftly rising technology from the past 20 years. The
advancement in their reputation is because of the ease of deployment, infrastructure less
and their dynamic nature. MANETs fashioned a new set of demands to be implemented
and to provide effective improved end-to-end communication. MANETs mechanism on
TCP/IP structure to provide the means of communication between communicating work
stations. Work stations are portable and they have limited resources, therefore the
traditional TCP/IP model needs to be overhauled or modified, in order to recompense the
MANETs mobility to provide efficient functionality. Therefore the crucial research area
for the researchers is routing in any network. Routing protocols in MANETs are a

For more info: Https://ThesisScientist.com


challenging and striking tasks, researchers are giving marvellous amount of attention to
this key area.
3.3.6 Classification of MANETs Routing Protocols
Routing protocols in MANETs are categorized into three different categories according to
their functionality
A. Reactive protocols
B. Proactive protocols
C. Hybrid protocols
3.3.6.1 Reactive Protocols
Reactive protocols also recognized as on demand driven reactive protocols. The fact they
are identified as reactive protocols is, they do not pledge route discovery by themselves,
till they are wished, when a source node request to discover a route. These protocols setup
routes when required [3, 4]. When a node desires to communicate with another node in the
network, and the source node does not have a route to the node it wants to communicate
with, reactive routing protocols will establish a route for the source to destination node.
Typically reactive protocols
Dont find route until needed
When tries to discover the destination on demand, it uses flooding technique to
broadcast the request.
Do not consume bandwidth for sending information.
As soon as the node starts transmitting the data to the destination node,they
consume bandwidth only.

a.) Ad-Hoc on Demand Distance Vector Protocol (AODV)


AODV is defined in RFC 3561 [5]. Its reactive protocol, when a node needs to start
transmission with another node in the network to which it has no route; AODV will
deliver topology information for the node. AODV use control messages to find a route to
the destination node in the network. Since there are three types of control messages in
AODV which are conversed bellow.
Route Request Message (RREQ)

For more info: Https://ThesisScientist.com


Source node that desires to communicate with another node in the network conveys
RREQ message. AODV floods RREQ message, using expanding ring technique.
There is a time to aware (TTL) value in every RREQ message, the value of TTL
describes the number of hops the RREQ should be communicated.
Route Reply Message (RREP)
A node having a demanded uniqueness or any intermediate node that has a route to
the demanded node generates a route reply RREP message back to the instigator
node.
Route Error Message (RERR)
Each node in the network keeps monitoring the link status to its neighbors nodes
during active routes. As soon as the node notices a link crack in an active route,
(RERR) message is generated by the node in order to notify other nodes that the link
is down.

Route Discovery Mechanism in AODV


When a node A wants to pledge broadcast with another node G as shown in the Fig.
3.3.6.1, it will produce a route request message (RREQ). This message is broadcasted
through a limited flooding to other nodes. This control message is promoted to the
neighbours, and those nodes advancing the control message to their neighbours nodes.
This procedure of finding destination node goes on until it finds a node that has a new
enough route to the destination or destination node is situated itself. As soon as the
destination node is located or an intermediate node with enough fresh routes is located,
they start generating control message route reply message (RREP) towards the source
node. When RREP ranges the source node, a route is established between the source node
A and destination node G. Once the route is recognized among A and G, node
A and G can communicate with each other. Fig. signifies the exchange of control
messages between source node and destination node.

For more info: Https://ThesisScientist.com


Fig 3.2: AODV Route Discovery
Once there is a link down or a link between destinations is broken that causes one or more
than one links unreachable from the source node or from the neighbours nodes, the RERR
message is directed towards the source node. When RREQ message is broadcasted for
finding the destination node i.e. from the node A to the neighbours nodes, at node E
the link is broken between E and G, so a route error RERR message is generated at
node E and transmitted to the source node informing the source node a route fault,
where A is source node and G is the destination node.

b.) Dynamic Source Routing Protocol:


Dynamic source routing protocol abbreviated by means of DSR is also a reactive protocol.
DSR use to update its route caches by finding new routes. It keep informed its cache with
new route discovered or when there exist a direct route between source and destination
node. When a node wants to transmit data, it describes a route for the transmission and
then starts transmitting data through the defined route. There are two procedures for route
discovery and maintenance which are described below.
Route Discovery Process
Once a source node wants to start data transmission with another node in the network, it
checks its routing cache. Once there is no route available to the destination in its cache or
a route is expired, it broadcast RREQ. When the destination is located or any middle node
that has fresh enough route to the destination node, RREP is generated [15]. Once the
source node accepts the RREP it updates its caches and the traffic is routed through the
route.
Route Maintenance Process

For more info: Https://ThesisScientist.com


When the transmission of data started, it is the duty of the node that is transmitting data to
confirm the next hop acknowledged the data along with source route. The node generates
a route error message, if it does not receive any authorization to the originator node. The
originator node again performs new route discovery process.

3.3.6.2 Proactive Protocols:


Proactive routing protocols works as compared to reactive routing protocols. These
protocols continuously preserve the updated topology of the network. Every node in the
network recognizes about the other node in advance, in other words the whole network is
acknowledged to all the nodes making that network. All the routing information is usually
reserved in tables [6]. Each time there is a change in the network topology, these tables are
updated according to the change. The nodes interchange topology information with each
other; they can have route information any time when they required [6].
a.) Optimized Link State Routing Protocol (OLSR):
The Optimized Link State Routing (OLSR) protocol is termed in RFC3626 [7]. OLSR
is proactive routing protocol that is also called as table driven protocol by the detail
that it updates its routing tables. OLSR has also three types of control messages which
are detailed bellow.
Hello: This control message is communicated for sensing the neighbour and for Multi
Point Distribution Relays (MPR) calculations.
Topology Control (TC):These are connection state signaling that is achieved by
OLSR. MPRs are used to enhance theses messaging.
Multiple Interface Declaration (MID):MID messages comprehends the list of all IP
addresses used through any node in the network. All the nodes running OLSR spread
these messages on more than one interface.
OLSR Working Multi Point Relaying (MPR): OLSR disperses the network
topology information by flooding the packets throughout the network. The flooding is
done in such technique that each node that received the packets retransmits the
received packets. These packets contain a sequence number so as to evade loops. The
receiver nodes record this sequence number making sure that the packet is

For more info: Https://ThesisScientist.com


retransmitted after. The simple concept of MPR is to reduce the duplication or loops of
retransmissions of the packets.
Individual MPR nodes broadcast route packets. The nodes inside the network keep a
list of MPR nodes. MPR nodes are nominated with in the vicinity of the source node.
The assortment of MPR is based on HELLO message sent between the neighbour
nodes. The selection of MPR is such that, a path exist to each of its 2 hop neighbours
via MPR node. Routes are established, once it is done the source node that wants to
initiate communication can start sending data.

Figure 3.3: Flooding Packets using MPR


The whole process can be understoodthrough looking into the Fig. 3.4 below. The
nodes shown in the figure are neighbours. A transmits a HELLO message to the
neighbour node B. As soon as node B receives this message, the link is distorted.
The similar is the case when B send HELLO message to A. When there is two way
communications between both of the nodes we call the link as symmetric link. HELLO
message has all the information about the neighbours. MPR node transmits topology
control (TC) message, along through link status information at a predetermined TC
interval.

For more info: Https://ThesisScientist.com


Fig 3.4: Hello Message Exchange

3.3.6.3 Hybrid protocols


It exploits the strengths of both reactive and proactive protocols, and combines them
together to get better results. The network is distributed into zones, and use different
protocols in two different zones i.e. one protocol is used within zone, and the other
protocol is used among them. Zone Routing Protocol (ZRP) is the example of Hybrid
Routing Protocol. ZRP practices proactive mechanism for route establishment within the
nodes neighborhood, and for communication between the neighborhood it takes the
benefit of reactive protocols. These local neighborhoods are known as zones, and the
protocol is named for the same motive as zone routing protocol. Each zone can have
different size and each node may be within numerous overlapping zones. The size of zone
is given by radius of length P, where P is number of hops to the perimeter of the zone [8].

3.4 Basic Security Concepts


To understand security issues it is vital to know the attribute or basic concepts on which a
network security is judged. These attribute associated to security are the desired objectives
of Cryptographic mechanism. Cryptography can be defined in several ways, in it is
defined as Cryptography terminologies, key concepts; types are summarized in. Following
are the attributes or security services on which the security of the networks is evaluated.
3.4.1 Non-Repudiation
Non-repudiation ensures that an entity in a dispute cannot falsely deny its action or reject
the validity of the contact. For example, during a transmission non repudiation service
prevents the sender from denying sending a message which he sent earlier, or a receiver
cannot claim to have received the message falsely.
3.4.2 Availability
Availability is another very important attribute, referring to ensuring that system resources
and services are available for use by authorized users of the system. It is imperative to
make sure all the network services remain available for its users given that an intruder can
attempt to deny services in the network through denial of service attacks, and that a
network without desired services is as bad as having no network. MANETs are especially

For more info: Https://ThesisScientist.com


vulnerable to different types of denial of service attacks due to their inherent
characteristics. To achieve these security attributes or services in fixed networks several
cryptographic mechanism are proposed using trusted third party (TIP). TIP is an entity in
the network trusted by all users in the system for example Certificate Authority (CA) or
Key Distribution Centers (KDC). They are mainly used to provide key management
services such as creating ,distributing, updating and revoking keying material for both
symmetric (involve the use of single key) and asymmetric key (involve the use of two
keys) systems. Security mechanisms developed using TIP are not directly implantable in
MANETs because they lack a trusted infrastructure and absence of centralized control.
However, some proposals based on modified approaches of key management for
MANETs can be found in the literature for example approaches in [15] suggest use of
identity-based public key management systems for MANETS. In [12] authors use identity
based signcryption (combines the functionality of digital signature and symmetric key
encryption) and threshold secret sharing(allows sharing of secret information among
group of entities) to provide various security services in MANETs. Recently the concept
of threshold cryptography i.e. protecting secret information by distributing it among a set
of nodes or entities has proven to be an effective scheme for key management in
MANETs.
MANETs are vulnerable in their functionality: intruders can compromise the network
operations by either attacking at physical, MAC or network layer. MANETs are
susceptible to eavesdropping, active interfering and frequency jamming attacks because of
wireless links. Frequency jamming is a common physical layer attack on MANETs.
Researchers have looked at MAC layer misbehavior in MANETs in a presence of
compromised or selfish nodes. However, this thesis focuses on network layer
vulnerabilities. Network layer especially routing protocols for MANETs are more
vulnerable in their routing operations because of the following:

Use of cooperative routing algorithm: Because each node in MANETs has to act as
a router i.e. forward packets for other nodes, participate in route discovery and
route maintenance procedures. Nodes with harmful intention can cause severe
disruption exploiting this property of routing protocols.

For more info: Https://ThesisScientist.com


Rely on exhaustible batteries: most nodes in ad hoc network rely on exhaustible
batteries; hence, their processing capabilities are limited. Intruder can exploit this
property by forcing a node to process unnecessary packets in an attempt to exhaust
their batteries within the rules of routing protocols. Any service offered by the
victim nodes can be denied through this intrusive activity.
Limited computational ability: nodes in such networks generally have limited
computational capabilities having low processing frequencies and smaller memory
size which also adds to the existing vulnerabilities.
Easy theft of nodes: location of nodes in such networks is not permanent as they
are allowed to move arbitrarily which makes them vulnerable to being physically
captured. From a routing perspective, this means that a node can be compromised
easily.
Transient nature of services: because the topology of the network is dynamic as
nodes move frequently, therefore any specific service provided by nodes is
transient, this adds to the uncertainty in these networks. This makes it difficult to
distinguish between acceptable or malicious behavior. Cryptography key
management scheme for MAENTs and their simulation results show the
advantages and suitability of the idea in MANETS.

3.5 Vulnerability of MANET Routing Protocols


Vulnerability, threat, and attacks are the terms used often in computer network security.
We begin this subsection with defining these terms:

3.5.1 Confidentiality
Confidentiality is also known as secrecy or privacy. Confidentiality is the process of
concealing information on the network, i.e. it ensures that information content cannot be
revealed by unauthorized entities that are normally known as internal or external attacker
or intruders. It can also be described as a security service that ensures only intended
receivers could interpret the information transmitted on the network. Confidentiality is
very important security service in MANETs considering wireless links in such networks
are easily susceptible to eavesdropping. In a security protocol for reliable data delivery is

For more info: Https://ThesisScientist.com


proposed to improve the confidentiality service in MANETs. They propose to split the
encrypted message into separate shares and these shares should be transmitted through
independent multiple paths so making it difficult for the attacker because now he has to
eavesdrop all pieces of message and has to decrypt all of them successfully to understand
the message. In Seng et.al proposes secure routing mechanism which provides data
confidentiality using shared secret key.
3.5.2 Integrity
Integrity ensures that data packets are unaltered during transition from source to
destination i.e. unauthorized user could not manipulate data through insertion,
substitution, deletion or forging data. To maintain integrity, data is usually signed by the
source and the receiver verifies the digital signature to be assured of integrity of the data.
Such mechanism will incur extra overhead for nodes in MANETs with limited processing
abilities and also because nodes relay data for other nodes, so integrity cheeks needs to
carried out at every hop. In [20] Gavidia et.al realize the cost of guaranteeing data
integrity mechanism for MANETs and proposed a solution based on probabilistic integrity
checks and traffic analysis. They prove that probablistic verification is an effective method
to restrict the amount of corrupted content and their spread i.e. ensures data integrity in
MANETs.
3.5.3 Authentication
Authentication is a process that allows node to verify the identity of the other nodes with it
is communicating. Two types of authentication are entity and data authentication [36].
Entity authentication ensures that other communicating parties are who they claim to be
and data authentication is focused on providing a guarantee as to the origin of the data.

3.6 Flaws in MANET


MANETs are very flexible for the nodes i.e. nodes can freely link and leave the network.
There is no main body that keeps watching on the nodes entering and leaving the network.
All these feebleness of MANETs make it vulnerable to attacks and these are discussed
bellow.
3.6.1 Non Secure Boundaries

For more info: Https://ThesisScientist.com


MANET is vulnerable to different kind of attacks due to no clear secure borderline. The
nature of MANET is that the nodes have the freedom to link and leave inside the network.
Node canlink a network automatically if the network is in the radio range of the node,
hence it can communicate with supplementary nodes in the network. As a result of no
secure boundaries, MANET is more vulnerable to attacks. The attacks may be passive or
active, leakage of information, false message reply, denial of service or changing the data
reliability. The links are cooperated and are open to many link attacks. Attacks on the link
interfere between the nodes and then attacking the link, destroying the link after
performing malevolent behaviour. There is no defence against attacks like firewalls or
access control, which result the susceptibility of MANET to attacks. Spoofing of nodes
individuality, data tempering, confidential information leakage and impersonating node
are the consequences of such attacks the minute security is compromised [10].
3.6.2 Compromised Node
Various attacks are to get admittance inside the network in order to get control over the
node in the network using unfair means to carry out their malevolent activities. Mobile
nodes in MANET are free to travel, link or leave the network in other words the mobile
nodes are independent [11]. Because of this autonomous factor for mobile nodes it is very
difficult for the nodes to prevent malevolent activity it is communicating with. Ad-hoc
network mobility makes it easier for a compromised node to change its position so
commonly making it more difficult and troublesome to track the malevolent activity. It
can be understood that these threats from compromised nodes inside the network is more
dangerous than attacking threats from external the network.

3.6.3 No Central Management


MANET is a self-configurable network, which consists of Mobile nodes where the
communication between these mobile nodes is done short of a central control. Each and
every node act as router and can forward and collect packets [12]. MANET works without
any pre-existing infrastructure. This deficiency of centralized management leads MANET
more susceptible to attacks. Detecting attacks and monitoring the traffic in highly active
and for large scale Ad-Hoc network is very tough due to no central organization. While

For more info: Https://ThesisScientist.com


there is a central object taking care of the network by applying proper security,
authentication which node can join and which cant. The node assign which each other on
the basis of blind mutual trust on each other, a central entity can accomplish this by
applying a filter on the nodes to find out the suspicious one, and let the other nodes know
which node is doubtful.
3.6.4 Problem of Scalability
In traditional networks, where the network is built and each machine is connected to the
other machine with assistance of wire. The network topology and the scale of the network,
while designing it is distinct and it do not change much during its life. In other words we
can say that the scalability of the network is defined in the beginning phase of the
designing of the network. The case is quite opposite in MANETs because the nodes are
moveable and due to their mobility in MANETs, the scale of the MANETs is changing. It
is too hard to know and forecast the numbers of nodes in the MANETs in the future. The
nodes are free to move in and out of the Ad-Hoc network which varieties the Ad-Hoc
network very much ascendable anddevisable. Keeping this property of the MANET, the
protocols and all the services that a MANET provides must be elastic to such changes.

3.7 ANT COLONY OPTIMIZATION


Ant colony optimization (ACO) obtains inspiration from the foraging nature of some ant
species. These ants deposit pheromone on the ground for marking some favourable route
that should be adopted by other colony members. Ant colony optimization exploits a same
technique for solving optimization issues. Ant colony optimization (ACO) is a population-
based meta- heuristic technique. As the name represents the mechanism was inspired by
the nature of real'' ants. Ant colonies are capable to discover the shortest path between
their nest and a food source by depositing and reacting to chase of pheromone which offer
support to future ants towards optimum routes to food. Ants on arriving the destination;
initiate a new path backward towards the source nest by adopting the similar path and
biases the route by depositing more pheromone on the shorter path. As time progresses,
the pheromone on non-optimum paths evaporate while the pheromone on near-optimum
paths is built. The general principle of ACO algorithms can also be employed to some
other combinatorial optimization issues.

For more info: Https://ThesisScientist.com


ACO is a metaheuristic algorithm. Metaheuristic is a set of general algorithmic framework
which is nature inspired and they are designed to solve complex optimization problems
ACO is one of the most used and successful algorithm of metaheuristic field. The concept
of ACO is related to biological ants and their foraging behavior, while searching for food
they find routes from nest to food source [14]. Ants tend to find a random route which
turns out to be good in terms of shortness, time travel etc. so their foraging behavior finds
out an optimization problem out of a search space.
The main success of optimization is explained by how ants communicate and by the
decision of where to go. While searching for food, ants deposit some chemical called
pheromone concentrations. While exploring the routes, it may be a longer or shorter route,
Ant randomly walks on a path for food and in case they selects a shorter route , they
deposit pheromone which will helpful for future ants to select the optimum path[11]. In
return, they accumulate more pheromone on the route compared to longer route.
Subsequent ants tend to follow the shorter route because it has more pheromone
concentration on that path. ACO are usually encoded by construction graph G= (V, A),
where V are number of nodes of a fully connected graph and Arc A is connection between
them. Finding a solution is equal to constructing a feasible walk on graph G [26].
The Main mechanisms on which ACO works are as follows:
Construct ant solution
Apply local search
Update pheromone

3.8 ACO BASED TECHNIQUE


AntNet is an adaptive routing algorithm inspired by ant colonies to solve routing problems
in wired networks. An AntNet node maintains probabilistic entries in the routing table,
indicating the goodness of path. Each node periodically sends a forward ant packet to find
paths to a random destination. Forward ants find the network for a feasible and lowcost
path, recording every node it visits. Once it arrives at the destination, it is converted into a
backward ant. The backward ant returns to the source node following the path in reverse.
For more info: Https://ThesisScientist.com
Each intermediate node updates its routing tables with the information from the backward
ant. Ants interact and communicate indirectly by updating the routing tables, thus
collaboratively solve the global network routing optimization problem.

3.8.1 Antnet Algorithm


At regular intervals, from every network node, a forward ant is launched with a
randomly selected destination node. While travelling towards their destination
node.
The forward ants store their paths and the traffic conditions. At each node, each
forward ant chooses the next node.
If all the neighboring nodes have not been visited, then the next neighbor is chosen
among the nodes that have not been visited.
If all the neighboring nodes have been visited previously, then the next node is
chosen uniformly among all the neighbors. The forward ant is forced to return to a
previously visited node.
With a small probability, the next node may be chosen uniformly among all the
neighboring nodes.
If a cycle is detected, that is, if the ant is forced to return to an already visited node.
When the destination node is reached, the forward ant generates a backward ant.
The backward ant takes the same path as the corresponding forward ant, but in the
opposite direction.
Arriving at a node coming from a neighbor node, the backward ant updates the
routing table Tr, for all the entries corresponding to the destination node.

3.9 ANT DYNAMIC SOURCE ROUTING (ADSR)


This paper proposes an enhanced version of DSR based on Ant Colony Optimization
(ACO) called Ant Dynamic Source Routing (ADSR) and it takes into consideration of
three QoS parameters delay, jitter and energy.
3.9.1 Ant Colony Optimization (ACO)

For more info: Https://ThesisScientist.com


Two of the most successful swarm intelligence techniques are Ant Colony Optimization
(ACO)and Particle Swarm Optimization (PSO). ACO is a meta-heuristic optimization
algorithm that can be used to find approximate solutions to difficult combinatorial
optimization problems. In ACO artificial ants build solutions by moving on the problem
graph and they, mimicking real ants, International Journal of Computer Science and
Security, volume (2) issue (3) deposit artificial pheromone on the graph in such a way that
future artificial ants can build better solutions. ACO has been applied successfully to an
impressive number of optimization problems.PSO is a global minimization technique for
dealing with problems in which a best solution can be represented as a point or surface in
an n-dimensional space.ACO is application of ants behavior to complex computational
optimization problems. ACO is inspired by the foraging behavior of ant colonies, wherein
they are able to find shortest path between two points through collective learning.
Learning is achieved by deposition of a chemical called pheromone. ACO is based on real
ants behavior in finding a route to food nest. It has been observed that of available routes,
ants find shortest route to food nest. To achieve this, ant communicates through deposition
of chemical substance called pheromone along the route. Shortest path has highest
concentration leading to more and more ants using this route.

3.9.2 Basic Ant Algorithm


The basic idea of the ant colony optimization Meta heuristic is taken from the food
searching behavior of real ants. Figure3.9.2 shows a scenario with two routes from the
nest to the food place.At the intersection, the first ants randomly select the next branch.
Since the route below is shorterthan the upper one, the ants that take this path will reach
the food place first.On their way back to the nest, the ants again have to select a path.
After a short time the pheromone concentration on the shorter path will be higher than on
the longer path, because theants using the shorter path will increase the pheromone
concentration faster. The shortest path will thus be identified and eventually all ants will
only use this one. This behavior of the ants canbe used to find the shortest path in
networks. Especially, the dynamic component of this methodallows a high adaptation to
changes in mobile ad hoc network topology, since in these networksthe existence of links
are not guaranteed and link changes occur very often.

For more info: Https://ThesisScientist.com


NEST FOOD

Figure 3.5: Ants take the shortest path after an initial searching time

3.9.3 Ant Dynamic Source Routing (ADSR)


Dynamic Source Routing (DSR) protocol is an on-demand routing protocol that is based
on theidea of source routing [12]. Mobile nodes are required to maintain route caches that
contain the source routes of which the mobile is aware. Entries in the route cache are
continually updated asnew routes are learnt. The protocol consists of two major phases:
route discovery and routemaintenance.
Route Request
When a mobile node has a packet to send to the destination, it first consults its route cache
todetermine whether it previously has a route to the destination. If it has an unexpired
route to thedestination, it will use this route to send the packet. On the other hand, if the
node does not havesuch a route, it initiates route discovery by broadcasting a route request
packet. This routerequest contains the address of the destination, along with the source
node's address and aunique identification number. Each node receiving the packet checks
whether it knows of a routeto the destination. If it does not, it adds its own address to the
route record of the packet and thenforwards the packet along its outgoing links.
Route Reply
A route reply is generated when the route request either reaches the destination itself, or
reachesan intermediate node which contains in its route cache an unexpired route to the
destination. Bythe time the packet reaches either the destination or such an intermediate
node, it contains a route record yielding the sequence of hops taken. If the node generating
the route reply is the destination, it places the route record contained in the route request
into the route reply. If the responding node is an intermediate node, it will append its
cached route to the route record and then generate the route reply. To return the route
reply, the responding node must have a route to the initiator. If it has a route to the

For more info: Https://ThesisScientist.com


initiator in its route cache, it may use that route. Otherwise, ifsymmetric links are
supported, the node may reverse the route in the route record. If symmetriclinks are not
supported, the node may initiate its own route discovery and piggyback the routereply on
the new route request.
Route maintenance
Route maintenance is accomplished through the use of route error packets and
acknowledgments. Route error packets are generated at a node when the data link layer
encounters a transmission problem. When a route error packet is received, the hop in error
is removed from the node's route cache and all routes containing the hop are truncated at
that point. In addition to route error messages, acknowledgments are used to verify the
correct operation of the route links. Such acknowledgments include passive
acknowledgments, where a mobile is able to hear the next hop forwarding the packet
along the route.
In Ant DSR (ADSR) the Forward ant (FANT) and backward ant (BANT) packets are
added in the route request and route reply of DSR. FANT and BANT packets are used in
this route discovery process. Forward ants are used to explore new paths in the network.
Ants measure the current network state for instance by trip times, hop count or Euclidean
distance traveled. Backward ants serve the purpose of informing the originating node
about the information collected by the forward ant. The ant routing has two types of
feedback: positive feedback increases the pheromone levels on routes actively carrying ant
packets and negative feedback periodically decreases pheromone values to limit the
effects of stale information. Routing decisions tend to support paths with higher
pheromone levels and, when allowed to converge, shortest end-to-end paths are
empirically observed to be favored. Modified ant mechanism algorithm that uses energy,
delay and jitter metrics to perform updates of pheromone levels is proposed. Assuming
acontrol packet containing energy, delay and jitter metrics, a separate pheromone level
will be maintained for each metric.
In the algorithm, ant packet headers have fields that:
1. Track the minimum residual energy of the nodes that relay them and
2. Track the cumulative delay and jitter based on backlog information of queued packets
destined to the packets source.

For more info: Https://ThesisScientist.com


Thus, energy, delay and jitter pheromone levels will be maintained at each node.

APPENDIX A

Implementation Code for Enhance Dynamic Source Routing Protocol

#include "dsr_hello.h"
#include "dsr_timeout.h"
#include "dsr_rrep.h"
#include "dsr_rreq.h"
#include "routing_table.h"
#include "timer_queue.h"
#include "params.h"
#include "dsr_socket.h"
#include "defs.h"
#include "debug.h"

extern int unidir_hack, receive_n_hellos, hello_jittering, optimized_hellos;


static struct timer hello_timer;

#endif
long NS_CLASS hello_jitter()
{
if (hello_jittering) {
#ifdef NS_PORT
return (long) (((float) Random::integer(RAND_MAX + 1) / RAND_MAX - 0.5)
* JITTER_INTERVAL);
#else
return (long) (((float) random() / RAND_MAX - 0.5) * JITTER_INTERVAL);
#endif
} else
return 0;
}

void NS_CLASS hello_start()


{
if (hello_timer.used)
return;

gettimeofday(&this_host.fwd_time, NULL);

DEBUG(LOG_DEBUG, 0, "Starting to send HELLOs!");


timer_init(&hello_timer, &NS_CLASS hello_send, NULL);

hello_send(NULL);
}

void NS_CLASS hello_stop()

For more info: Https://ThesisScientist.com


{
DEBUG(LOG_DEBUG, 0,
"No active forwarding routes - stopped sending HELLOs!");
timer_remove(&hello_timer);
}

void NS_CLASS hello_send(void *arg)


{
RREP *rrep;
DSR_ext *ext = NULL;
u_int8_t flags = 0;
struct in_addr dest;
long time_diff, jitter;
struct timeval now;
int msg_size = RREP_SIZE;
int i;

gettimeofday(&now, NULL);

if (optimized_hellos &&
timeval_diff(&now, &this_host.fwd_time) > ACTIVE_ROUTE_TIMEOUT) {
hello_stop();
return;
}

time_diff = timeval_diff(&now, &this_host.bcast_time);


jitter = hello_jitter();

if (time_diff >= HELLO_INTERVAL) {

for (i = 0; i < MAX_NR_INTERFACES; i++) {


if (!DEV_NR(i).enabled)
continue;
#ifdef DEBUG_HELLO
DEBUG(LOG_DEBUG, 0, "sending Hello to 255.255.255.255");
#endif
rrep = rrep_create(flags, 0, 0, DEV_NR(i).ipaddr,
this_host.seqno,
DEV_NR(i).ipaddr,
ALLOWED_HELLO_LOSS * HELLO_INTERVAL);

/* Assemble a RREP extension which contain our neighbor set... */


if (unidir_hack) {
int i;

if (ext)
ext = DSR_EXT_NEXT(ext);
else
ext = (DSR_ext *) ((char *) rrep + RREP_SIZE);

ext->type = RREP_HELLO_NEIGHBOR_SET_EXT;
ext->length = 0;

for (i = 0; i < RT_TABLESIZE; i++) {


list_t *pos;

For more info: Https://ThesisScientist.com


list_foreach(pos, &rt_tbl.tbl[i]) {
rt_table_t *rt = (rt_table_t *) pos;

if (rt->hello_timer.used) {
#ifdef DEBUG_HELLO
DEBUG(LOG_INFO, 0,
"Adding %s to hello neighbor set ext",
ip_to_str(rt->dest_addr));
#endif
memcpy(DSR_EXT_DATA(ext), &rt->dest_addr,
sizeof(struct in_addr));
ext->length += sizeof(struct in_addr);
}
}
}
if (ext->length)
msg_size = RREP_SIZE + DSR_EXT_SIZE(ext);
}
dest.s_addr = DSR_BROADCAST;
dsr_socket_send((DSR_msg *) rrep, dest, msg_size, 1, &DEV_NR(i));
}

timer_set_timeout(&hello_timer, HELLO_INTERVAL + jitter);


} else {
if (HELLO_INTERVAL - time_diff + jitter < 0)
timer_set_timeout(&hello_timer,
HELLO_INTERVAL - time_diff - jitter);
else
timer_set_timeout(&hello_timer,
HELLO_INTERVAL - time_diff + jitter);
}
}

/* Process a hello message */


void NS_CLASS hello_process(RREP * hello, int rreplen, unsigned int ifindex)
{
u_int32_t hello_seqno, timeout, hello_interval = HELLO_INTERVAL;
u_int8_t state, flags = 0;
struct in_addr ext_neighbor, hello_dest;
rt_table_t *rt;
DSR_ext *ext = NULL;
int i;
struct timeval now;

gettimeofday(&now, NULL);

hello_dest.s_addr = hello->dest_addr;
hello_seqno = ntohl(hello->dest_seqno);

rt = rt_table_find(hello_dest);

if (rt)
flags = rt->flags;

if (unidir_hack)

For more info: Https://ThesisScientist.com


flags |= RT_UNIDIR;

/* Check for hello interval extension: */


ext = (DSR_ext *) ((char *) hello + RREP_SIZE);

while (rreplen > (int) RREP_SIZE) {


switch (ext->type) {
case RREP_HELLO_INTERVAL_EXT:
if (ext->length == 4) {
memcpy(&hello_interval, DSR_EXT_DATA(ext), 4);
hello_interval = ntohl(hello_interval);
#ifdef DEBUG_HELLO
DEBUG(LOG_INFO, 0, "Hello extension interval=%lu!",
hello_interval);
#endif

} else
alog(LOG_WARNING, 0,
__FUNCTION__, "Bad hello interval extension!");
break;
case RREP_HELLO_NEIGHBOR_SET_EXT:

#ifdef DEBUG_HELLO
DEBUG(LOG_INFO, 0, "RREP_HELLO_NEIGHBOR_SET_EXT");
#endif
for (i = 0; i < ext->length; i = i + 4) {
ext_neighbor.s_addr =
*(in_addr_t *) ((char *) DSR_EXT_DATA(ext) + i);

if (ext_neighbor.s_addr == DEV_IFINDEX(ifindex).ipaddr.s_addr)
flags &= ~RT_UNIDIR;
}
break;
default:
alog(LOG_WARNING, 0, __FUNCTION__,
"Bad extension!! type=%d, length=%d", ext->type, ext->length);
ext = NULL;
break;
}
if (ext == NULL)
break;

rreplen -= DSR_EXT_SIZE(ext);
ext = DSR_EXT_NEXT(ext);
}

#ifdef DEBUG_HELLO
DEBUG(LOG_DEBUG, 0, "rcvd HELLO from %s, seqno %lu",
ip_to_str(hello_dest), hello_seqno);
#endif
/* This neighbor should only be valid after receiving 3
consecutive hello messages... */
if (receive_n_hellos)
state = INVALID;
else
state = VALID;

For more info: Https://ThesisScientist.com


timeout = ALLOWED_HELLO_LOSS * hello_interval + ROUTE_TIMEOUT_SLACK;

if (!rt) {

rt = rt_table_insert(hello_dest, hello_dest, 1,
hello_seqno, timeout, state, flags, ifindex);

if (flags & RT_UNIDIR) {


DEBUG(LOG_INFO, 0, "%s new NEIGHBOR, link UNI-DIR",
ip_to_str(rt->dest_addr));
} else {
DEBUG(LOG_INFO, 0, "%s new NEIGHBOR!", ip_to_str(rt->dest_addr));
}
rt->hello_cnt = 1;

} else {

if ((flags & RT_UNIDIR) && rt->state == VALID && rt->hcnt > 1) {


goto hello_update;
}

if (receive_n_hellos && rt->hello_cnt < (receive_n_hellos - 1)) {


if (timeval_diff(&now, &rt->last_hello_time) <
(long) (hello_interval + hello_interval / 2))
rt->hello_cnt++;
else
rt->hello_cnt = 1;

memcpy(&rt->last_hello_time, &now, sizeof(struct timeval));


return;
}
rt_table_update(rt, hello_dest, 1, hello_seqno, timeout, VALID, flags);
}

hello_update:

hello_update_timeout(rt, &now, ALLOWED_HELLO_LOSS * hello_interval);


return;
}

#define HELLO_DELAY 50 /* The extra time we should allow an hello


message to take (due to processing) before
assuming lost . */

NS_INLINE void NS_CLASS hello_update_timeout(rt_table_t * rt,


struct timeval *now, long time)
{
timer_set_timeout(&rt->hello_timer, time + HELLO_DELAY);
memcpy(&rt->last_hello_time, now, sizeof(struct timeval));
}

extern int unidir_hack, optimized_hellos, llfeedback;

For more info: Https://ThesisScientist.com


#endif

RREP *NS_CLASS rrep_create(u_int8_t flags,


u_int8_t prefix,
u_int8_t hcnt,
struct in_addr dest_addr,
u_int32_t dest_seqno,
struct in_addr orig_addr, u_int32_t life)
{
RREP *rrep;

rrep = (RREP *) dsr_socket_new_msg();


rrep->type = DSR_RREP;
rrep->res1 = 0;
rrep->res2 = 0;
rrep->prefix = prefix;
rrep->hcnt = hcnt;
rrep->dest_addr = dest_addr.s_addr;
rrep->dest_seqno = htonl(dest_seqno);
rrep->orig_addr = orig_addr.s_addr;
rrep->lifetime = htonl(life);

if (flags & RREP_REPAIR)


rrep->r = 1;
if (flags & RREP_ACK)
rrep->a = 1;

/* Don't print information about hello messages... */


#ifdef DEBUG_OUTPUT
if (rrep->dest_addr != rrep->orig_addr) {
DEBUG(LOG_DEBUG, 0, "Assembled RREP:");
log_pkt_fields((DSR_msg *) rrep);
}
#endif

return rrep;
}

RREP_ack *NS_CLASS rrep_ack_create()


{
RREP_ack *rrep_ack;

rrep_ack = (RREP_ack *) dsr_socket_new_msg();


rrep_ack->type = DSR_RREP_ACK;

DEBUG(LOG_DEBUG, 0, "Assembled RREP_ack");

return rrep_ack;
}

void NS_CLASS rrep_ack_process(RREP_ack * rrep_ack, int rrep_acklen,


struct in_addr ip_src, struct in_addr ip_dst)
{
rt_table_t *rt;

For more info: Https://ThesisScientist.com


rt = rt_table_find(ip_src);

if (rt == NULL) {
DEBUG(LOG_WARNING, 0, "No RREP_ACK expected for %s", ip_to_str(ip_src));

return;
}
DEBUG(LOG_DEBUG, 0, "Received RREP_ACK from %s", ip_to_str(ip_src));

/* Remove unexpired timer for this RREP_ACK */


timer_remove(&rt->ack_timer);
}

DSR_ext *NS_CLASS rrep_add_ext(RREP * rrep, int type, unsigned int offset,


int len, char *data)
{
DSR_ext *ext = NULL;

if (offset < RREP_SIZE)


return NULL;

ext = (DSR_ext *) ((char *) rrep + offset);

ext->type = type;
ext->length = len;

memcpy(DSR_EXT_DATA(ext), data, len);

return ext;
}

void NS_CLASS rrep_send(RREP * rrep, rt_table_t * rev_rt,


rt_table_t * fwd_rt, int size)
{
u_int8_t rrep_flags = 0;
struct in_addr dest;

if (!rev_rt) {
DEBUG(LOG_WARNING, 0, "Can't send RREP, rev_rt = NULL!");
return;
}

dest.s_addr = rrep->dest_addr;

/* Check if we should request a RREP-ACK */


if ((rev_rt->state == VALID && rev_rt->flags & RT_UNIDIR) ||
(rev_rt->hcnt == 1 && unidir_hack)) {
rt_table_t *neighbor = rt_table_find(rev_rt->next_hop);

if (neighbor && neighbor->state == VALID && !neighbor->ack_timer.used) {

rrep_flags |= RREP_ACK;
neighbor->flags |= RT_UNIDIR;

timer_remove(&neighbor->hello_timer);

For more info: Https://ThesisScientist.com


neighbor_link_break(neighbor);

DEBUG(LOG_DEBUG, 0, "Link to %s is unidirectional!",


ip_to_str(neighbor->dest_addr));

timer_set_timeout(&neighbor->ack_timer, NEXT_HOP_WAIT);
}
}

DEBUG(LOG_DEBUG, 0, "Sending RREP to next hop %s about %s->%s",


ip_to_str(rev_rt->next_hop), ip_to_str(rev_rt->dest_addr),
ip_to_str(dest));

dsr_socket_send((DSR_msg *) rrep, rev_rt->next_hop, size, MAXTTL,


&DEV_IFINDEX(rev_rt->ifindex));

/* Update precursor lists */


if (fwd_rt) {
precursor_add(fwd_rt, rev_rt->next_hop);
precursor_add(rev_rt, fwd_rt->next_hop);
}

if (!llfeedback && optimized_hellos)


hello_start();
}

void NS_CLASS rrep_forward(RREP * rrep, int size, rt_table_t * rev_rt,


rt_table_t * fwd_rt, int ttl)
{
/* Sanity checks... */
if (!fwd_rt || !rev_rt) {
DEBUG(LOG_WARNING, 0, "Could not forward RREP because of NULL route!");
return;
}

if (!rrep) {
DEBUG(LOG_WARNING, 0, "No RREP to forward!");
return;
}

DEBUG(LOG_DEBUG, 0, "Forwarding RREP to %s", ip_to_str(rev_rt->next_hop));

rt_table_t *neighbor;

if (rev_rt->dest_addr.s_addr != rev_rt->next_hop.s_addr)
neighbor = rt_table_find(rev_rt->next_hop);
else
neighbor = rev_rt;

if (neighbor && !neighbor->ack_timer.used) {

rrep->a = 1;
neighbor->flags |= RT_UNIDIR;

For more info: Https://ThesisScientist.com


timer_set_timeout(&neighbor->ack_timer, NEXT_HOP_WAIT);
}
}

rrep = (RREP *) dsr_socket_queue_msg((DSR_msg *) rrep, size);


rrep->hcnt = fwd_rt->hcnt; /* Update the hopcount */

dsr_socket_send((DSR_msg *) rrep, rev_rt->next_hop, size, ttl,


&DEV_IFINDEX(rev_rt->ifindex));

precursor_add(fwd_rt, rev_rt->next_hop);
precursor_add(rev_rt, fwd_rt->next_hop);

rt_table_update_timeout(rev_rt, ACTIVE_ROUTE_TIMEOUT);
}

void NS_CLASS rrep_process(RREP * rrep, int rreplen, struct in_addr ip_src,


struct in_addr ip_dst, int ip_ttl,
unsigned int ifindex)
{
u_int32_t rrep_lifetime, rrep_seqno, rrep_new_hcnt;
u_int8_t pre_repair_hcnt = 0, pre_repair_flags = 0;
rt_table_t *fwd_rt, *rev_rt;
DSR_ext *ext;
unsigned int extlen = 0;
int rt_flags = 0;
struct in_addr rrep_dest, rrep_orig;
#ifdef CONFIG_GATEWAY
struct in_addr inet_dest_addr;
int inet_rrep = 0;
#endif

/* Convert to correct byte order on affeected fields: */


rrep_dest.s_addr = rrep->dest_addr;
rrep_orig.s_addr = rrep->orig_addr;
rrep_seqno = ntohl(rrep->dest_seqno);
rrep_lifetime = ntohl(rrep->lifetime);
/* Increment RREP hop count to account for intermediate node... */
rrep_new_hcnt = rrep->hcnt + 1;

if (rreplen < (int) RREP_SIZE) {


alog(LOG_WARNING, 0, __FUNCTION__,
"IP data field too short (%u bytes)"
" from %s to %s", rreplen, ip_to_str(ip_src), ip_to_str(ip_dst));
return;
}

/* Ignore messages which aim to a create a route to one self */


if (rrep_dest.s_addr == DEV_IFINDEX(ifindex).ipaddr.s_addr)
return;

DEBUG(LOG_DEBUG, 0, "from %s about %s->%s",


ip_to_str(ip_src), ip_to_str(rrep_orig), ip_to_str(rrep_dest));
#ifdef DEBUG_OUTPUT
log_pkt_fields((DSR_msg *) rrep);

For more info: Https://ThesisScientist.com


#endif

/* Determine whether there are any extensions */


ext = (DSR_ext *) ((char *) rrep + RREP_SIZE);

while ((rreplen - extlen) > RREP_SIZE) {


switch (ext->type) {
case RREP_EXT:
DEBUG(LOG_INFO, 0, "RREP include EXTENSION");
/* Do something here */
break;
#ifdef CONFIG_GATEWAY
case RREP_INET_DEST_EXT:
if (ext->length == sizeof(u_int32_t)) {

memcpy(&inet_dest_addr, DSR_EXT_DATA(ext), ext->length);

DEBUG(LOG_DEBUG, 0, "RREP_INET_DEST_EXT: <%s>",


ip_to_str(inet_dest_addr));
/* This was a RREP from a gateway */
rt_flags |= RT_GATEWAY;
inet_rrep = 1;
break;
}
#endif
default:
alog(LOG_WARNING, 0, __FUNCTION__, "Unknown or bad extension %d",
ext->type);
break;
}
extlen += DSR_EXT_SIZE(ext);
ext = DSR_EXT_NEXT(ext);
}

fwd_rt = rt_table_find(rrep_dest);
rev_rt = rt_table_find(rrep_orig);

if (!fwd_rt) {
/* We didn't have an existing entry, so we insert a new one. */
fwd_rt = rt_table_insert(rrep_dest, ip_src, rrep_new_hcnt, rrep_seqno,
rrep_lifetime, VALID, rt_flags, ifindex);
} else if (fwd_rt->dest_seqno == 0 ||
(int32_t) rrep_seqno > (int32_t) fwd_rt->dest_seqno ||
(rrep_seqno == fwd_rt->dest_seqno &&
(fwd_rt->state == INVALID || fwd_rt->flags & RT_UNIDIR ||
rrep_new_hcnt < fwd_rt->hcnt))) {
pre_repair_hcnt = fwd_rt->hcnt;
pre_repair_flags = fwd_rt->flags;

fwd_rt = rt_table_update(fwd_rt, ip_src, rrep_new_hcnt, rrep_seqno,


rrep_lifetime, VALID,
rt_flags | fwd_rt->flags);
} else {
if (fwd_rt->hcnt > 1) {
DEBUG(LOG_DEBUG, 0,

For more info: Https://ThesisScientist.com


"Dropping RREP, fwd_rt->hcnt=%d fwd_rt->seqno=%ld",
fwd_rt->hcnt, fwd_rt->dest_seqno);
}
return;
}

RREP_ack *rrep_ack;

rrep_ack = rrep_ack_create();
dsr_socket_send((DSR_msg *) rrep_ack, fwd_rt->next_hop,
NEXT_HOP_WAIT, MAXTTL, &DEV_IFINDEX(fwd_rt->ifindex));
/* Remove RREP_ACK flag... */
rrep->a = 0;
}

if (rrep_orig.s_addr == DEV_IFINDEX(ifindex).ipaddr.s_addr) {
#ifdef CONFIG_GATEWAY
if (inet_rrep) {
rt_table_t *inet_rt;
inet_rt = rt_table_find(inet_dest_addr);

if (!inet_rt)
rt_table_insert(inet_dest_addr, rrep_dest, rrep_new_hcnt, 0,
rrep_lifetime, VALID, RT_INET_DEST, ifindex);
else if (inet_rt->state == INVALID || rrep_new_hcnt < inet_rt->hcnt) {
rt_table_update(inet_rt, rrep_dest, rrep_new_hcnt, 0,
rrep_lifetime, VALID, RT_INET_DEST |
inet_rt->flags);
} else {
DEBUG(LOG_DEBUG, 0, "INET Response, but no update %s",
ip_to_str(inet_dest_addr));
}
}
#endif
if (pre_repair_flags & RT_REPAIR) {
if (fwd_rt->hcnt > pre_repair_hcnt) {
RERR *rerr;
u_int8_t rerr_flags = 0;
struct in_addr dest;

dest.s_addr = DSR_BROADCAST;

rerr_flags |= RERR_NODELETE;
rerr = rerr_create(rerr_flags, fwd_rt->dest_addr,
fwd_rt->dest_seqno);

if (fwd_rt->nprec)
dsr_socket_send((DSR_msg *) rerr, dest,
RERR_CALC_SIZE(rerr), 1,
&DEV_IFINDEX(fwd_rt->ifindex));
}
}
} else {
if (rev_rt && rev_rt->state == VALID) {

For more info: Https://ThesisScientist.com


rrep_forward(rrep, rreplen, rev_rt, fwd_rt, --ip_ttl);
} else {
DEBUG(LOG_DEBUG, 0, "Could not forward RREP - NO ROUTE!!!");
}
}

if (!llfeedback && optimized_hellos)


hello_start();
}

int rrep_add_hello_ext(RREP * rrep, int offset, u_int32_t interval)


{
DSR_ext *ext;

ext = (DSR_ext *) ((char *) rrep + RREP_SIZE + offset);


ext->type = RREP_HELLO_INTERVAL_EXT;
ext->length = sizeof(interval);
memcpy(DSR_EXT_DATA(ext), &interval, sizeof(interval));

return (offset + DSR_EXT_SIZE(ext));


}

endif /* NS_PORT */

#ifndef NS_PORT
#define SO_RECVBUF_SIZE 256*1024

static char recv_buf[RECV_BUF_SIZE];


static char send_buf[SEND_BUF_SIZE];

extern int wait_on_reboot, hello_qual_threshold, ratelimit;

static void dsr_socket_read(int fd);

static struct cmsghdr *__cmsg_nxthdr_fix(void *__ctl, size_t __size,


struct cmsghdr *__cmsg)
{
struct cmsghdr *__ptr;

__ptr = (struct cmsghdr *) (((unsigned char *) __cmsg) +


CMSG_ALIGN(__cmsg->cmsg_len));
if ((unsigned long) ((char *) (__ptr + 1) - (char *) __ctl) > __size)
return NULL;

return __ptr;
}

struct cmsghdr *cmsg_nxthdr_fix(struct msghdr *__msg, struct cmsghdr *__cmsg)


{
return __cmsg_nxthdr_fix(__msg->msg_control, __msg->msg_controllen, __cmsg);
}

#endif /* NS_PORT */

void NS_CLASS dsr_socket_init()

For more info: Https://ThesisScientist.com


{
#ifndef NS_PORT
struct sockaddr_in dsr_addr;
struct ifreq ifr;
int i, retval = 0;
int on = 1;
int tos = IPTOS_LOWDELAY;
int bufsize = SO_RECVBUF_SIZE;
socklen_t optlen = sizeof(bufsize);

/* Create a UDP socket */

if (this_host.nif == 0) {
fprintf(stderr, "No interfaces configured\n");
exit(-1);
}

/* Open a socket for every DSR enabled interface */


for (i = 0; i < MAX_NR_INTERFACES; i++) {
if (!DEV_NR(i).enabled)
continue;

/* DSR socket */
DEV_NR(i).sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (DEV_NR(i).sock < 0) {
perror("");
exit(-1);
}
#ifdef CONFIG_GATEWAY
/* Data packet send socket */
DEV_NR(i).psock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW);

if (DEV_NR(i).psock < 0) {
perror("");
exit(-1);
}
#endif
/* Bind the socket to the DSR port number */
memset(&dsr_addr, 0, sizeof(dsr_addr));
dsr_addr.sin_family = AF_INET;
dsr_addr.sin_port = htons(DSR_PORT);
dsr_addr.sin_addr.s_addr = htonl(INADDR_ANY);

retval = bind(DEV_NR(i).sock, (struct sockaddr *) &dsr_addr,


sizeof(struct sockaddr));

if (retval < 0) {
perror("Bind failed ");
exit(-1);
}
if (setsockopt(DEV_NR(i).sock, SOL_SOCKET, SO_BROADCAST,
&on, sizeof(int)) < 0) {
perror("SO_BROADCAST failed ");
exit(-1);
}

For more info: Https://ThesisScientist.com


memset(&ifr, 0, sizeof(struct ifreq));
strcpy(ifr.ifr_name, DEV_NR(i).ifname);

if (setsockopt(DEV_NR(i).sock, SOL_SOCKET, SO_BINDTODEVICE,


&ifr, sizeof(ifr)) < 0) {
fprintf(stderr, "SO_BINDTODEVICE failed for %s", DEV_NR(i).ifname);
perror(" ");
exit(-1);
}

if (setsockopt(DEV_NR(i).sock, SOL_SOCKET, SO_PRIORITY,


&tos, sizeof(int)) < 0) {
perror("Setsockopt SO_PRIORITY failed ");
exit(-1);
}

if (setsockopt(DEV_NR(i).sock, SOL_IP, IP_RECVTTL,


&on, sizeof(int)) < 0) {
perror("Setsockopt IP_RECVTTL failed ");
exit(-1);
}

if (setsockopt(DEV_NR(i).sock, SOL_IP, IP_PKTINFO,


&on, sizeof(int)) < 0) {
perror("Setsockopt IP_PKTINFO failed ");
exit(-1);
}
#ifdef CONFIG_GATEWAY
if (setsockopt(DEV_NR(i).psock, SOL_SOCKET, SO_BINDTODEVICE,
&ifr, sizeof(ifr)) < 0) {
fprintf(stderr, "SO_BINDTODEVICE failed for %s", DEV_NR(i).ifname);
perror(" ");
exit(-1);
}

bufsize = 4 * 65535;

if (setsockopt(DEV_NR(i).psock, SOL_SOCKET, SO_SNDBUF,


(char *) &bufsize, optlen) < 0) {
DEBUG(LOG_NOTICE, 0, "Could not set send socket buffer size");
}
if (getsockopt(DEV_NR(i).psock, SOL_SOCKET, SO_SNDBUF,
(char *) &bufsize, &optlen) == 0) {
alog(LOG_NOTICE, 0, __FUNCTION__,
"RAW send socket buffer size set to %d", bufsize);
}
#endif
/* Set max allowable receive buffer size... */
for (;; bufsize -= 1024) {
if (setsockopt(DEV_NR(i).sock, SOL_SOCKET, SO_RCVBUF,
(char *) &bufsize, optlen) == 0) {
alog(LOG_NOTICE, 0, __FUNCTION__,
"Receive buffer size set to %d", bufsize);
break;
}
if (bufsize < RECV_BUF_SIZE) {

For more info: Https://ThesisScientist.com


alog(LOG_ERR, 0, __FUNCTION__,
"Could not set receive buffer size");
exit(-1);
}
}

retval = attach_callback_func(DEV_NR(i).sock, dsr_socket_read);

if (retval < 0) {
perror("register input handler failed ");
exit(-1);
}
}
#endif /* NS_PORT */

num_rreq = 0;
num_rerr = 0;
}

void NS_CLASS dsr_socket_process_packet(DSR_msg * dsr_msg, int len,


struct in_addr src,
struct in_addr dst,
int ttl, unsigned int ifindex)
{

/* If this was a HELLO message... Process as HELLO. */


if ((dsr_msg->type == DSR_RREP && ttl == 1 &&
dst.s_addr == DSR_BROADCAST)) {
hello_process((RREP *) dsr_msg, len, ifindex);
return;
}

/* Make sure we add/update neighbors */


neighbor_add(dsr_msg, src, ifindex);

switch (dsr_msg->type) {

case DSR_RREQ:
rreq_process((RREQ *) dsr_msg, len, src, dst, ttl, ifindex);
break;
case DSR_RREP:
DEBUG(LOG_DEBUG, 0, "Received RREP");
rrep_process((RREP *) dsr_msg, len, src, dst, ttl, ifindex);
break;
case DSR_RERR:
DEBUG(LOG_DEBUG, 0, "Received RERR");
rerr_process((RERR *) dsr_msg, len, src, dst);
break;
case DSR_RREP_ACK:
DEBUG(LOG_DEBUG, 0, "Received RREP_ACK");
rrep_ack_process((RREP_ack *) dsr_msg, len, src, dst);
break;
default:
alog(LOG_WARNING, 0, __FUNCTION__,
"Unknown msg type %u rcvd from %s to %s", dsr_msg->type,
ip_to_str(src), ip_to_str(dst));

For more info: Https://ThesisScientist.com


}
}

#ifdef NS_PORT
void NS_CLASS recvDSRUUPacket(Packet * p)
{
int len, i, ttl = 0;
struct in_addr src, dst;
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);
hdr_dsruu *ah = HDR_DSRUU(p);

src.s_addr = ih->saddr();
dst.s_addr = ih->daddr();
len = ch->size() - IP_HDR_LEN;
ttl = ih->ttl();

DSR_msg *dsr_msg = (DSR_msg *) recv_buf;

/* Only handle DSRUU packets */


assert(ch->ptype() == PT_DSRUU);

/* Only process incoming packets */


assert(ch->direction() == hdr_cmn::UP);

/* Copy message to receive buffer */


memcpy(recv_buf, ah, RECV_BUF_SIZE);

/* Deallocate packet, we have the information we need... */


Packet::free(p);

/* Ignore messages generated locally */


for (i = 0; i < MAX_NR_INTERFACES; i++)
if (this_host.devs[i].enabled &&
memcmp(&src, &this_host.devs[i].ipaddr,
sizeof(struct in_addr)) == 0)
return;

dsr_socket_process_packet(dsr_msg, len, src, dst, ttl, NS_IFINDEX);


}
#else
static void dsr_socket_read(int fd)
{
struct in_addr src, dst;
int i, len, ttl = -1;
DSR_msg *dsr_msg;
struct dev_info *dev;
struct msghdr msgh;
struct cmsghdr *cmsg;
struct iovec iov;
char ctrlbuf[CMSG_SPACE(sizeof(int)) +
CMSG_SPACE(sizeof(struct in_pktinfo))];
struct sockaddr_in src_addr;

dst.s_addr = -1;

For more info: Https://ThesisScientist.com


iov.iov_base = recv_buf;
iov.iov_len = RECV_BUF_SIZE;
msgh.msg_name = &src_addr;
msgh.msg_namelen = sizeof(src_addr);
msgh.msg_iov = &iov;
msgh.msg_iovlen = 1;
msgh.msg_control = ctrlbuf;
msgh.msg_controllen = sizeof(ctrlbuf);

len = recvmsg(fd, &msgh, 0);

if (len < 0) {
alog(LOG_WARNING, 0, __FUNCTION__, "receive ERROR len=%d!", len);
return;
}

src.s_addr = src_addr.sin_addr.s_addr;

/* Get the ttl and destination address from the control message */
for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
cmsg = CMSG_NXTHDR_FIX(&msgh, cmsg)) {
if (cmsg->cmsg_level == SOL_IP) {
switch (cmsg->cmsg_type) {
case IP_TTL:
ttl = *(CMSG_DATA(cmsg));
break;
case IP_PKTINFO:
{
struct in_pktinfo *pi = (struct in_pktinfo *)CMSG_DATA(cmsg);
dst.s_addr = pi->ipi_addr.s_addr;
}
}
}
}

if (ttl < 0) {
DEBUG(LOG_DEBUG, 0, "No TTL, packet ignored!");
return;
}

/* Ignore messages generated locally */


for (i = 0; i < MAX_NR_INTERFACES; i++)
if (this_host.devs[i].enabled &&
memcmp(&src, &this_host.devs[i].ipaddr,
sizeof(struct in_addr)) == 0)
return;

dsr_msg = (DSR_msg *) recv_buf;

dev = devfromsock(fd);

if (!dev) {
DEBUG(LOG_ERR, 0, "Could not get device info!\n");
return;
}

For more info: Https://ThesisScientist.com


dsr_socket_process_packet(dsr_msg, len, src, dst, ttl, dev->ifindex);
}
#endif /* NS_PORT */

void NS_CLASS dsr_socket_send(DSR_msg * dsr_msg, struct in_addr dst,


int len, u_int8_t ttl, struct dev_info *dev)
{
int retval = 0;
struct timeval now;
/* Rate limit stuff: */

#ifndef NS_PORT

struct sockaddr_in dst_addr;

if (wait_on_reboot &&dsr_msg->type == DSR_RREP)


return;

memset(&dst_addr, 0, sizeof(dst_addr));
dst_addr.sin_family = AF_INET;
dst_addr.sin_addr = dst;
dst_addr.sin_port = htons(DSR_PORT);

/* Set ttl */
if (setsockopt(dev->sock, SOL_IP, IP_TTL, &ttl, sizeof(ttl)) < 0) {
alog(LOG_WARNING, 0, __FUNCTION__, "ERROR setting ttl!");
return;
}
#else

Packet *p = allocpkt();
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_ip *ih = HDR_IP(p);
hdr_dsruu *ah = HDR_DSRUU(p);

// Clear DSRUU part of packet


memset(ah, '\0', ah->size());

// Copy message contents into packet


memcpy(ah, dsr_msg, len);

// Set common header fields


ch->ptype() = PT_DSRUU;
ch->direction() = hdr_cmn::DOWN;
ch->size() += len + IP_HDR_LEN;
ch->iface() = -2;
ch->error() = 0;
ch->prev_hop_ = (nsaddr_t) dev->ipaddr.s_addr;

// Set IP header fields


ih->saddr() = (nsaddr_t) dev->ipaddr.s_addr;
ih->daddr() = (nsaddr_t) dst.s_addr;
ih->ttl() = ttl;

// Note: Port number for routing agents, not DSR port number!
ih->sport() = RT_PORT;

For more info: Https://ThesisScientist.com


ih->dport() = RT_PORT;

// Fake success
retval = len;
#endif
gettimeofday(&now, NULL);

switch (dsr_msg->type) {
case DSR_RREQ:
if (num_rreq == (RREQ_RATELIMIT - 1)) {
if (timeval_diff(&now, &rreq_ratel[0]) < 1000) {
DEBUG(LOG_DEBUG, 0, "RATELIMIT: Dropping RREQ %ld ms",
timeval_diff(&now, &rreq_ratel[0]));
#ifdef NS_PORT
Packet::free(p);
#endif
return;
} else {
memmove(rreq_ratel, &rreq_ratel[1],
sizeof(struct timeval) * (num_rreq - 1));
memcpy(&rreq_ratel[num_rreq - 1], &now,
sizeof(struct timeval));
}
} else {
memcpy(&rreq_ratel[num_rreq], &now, sizeof(struct timeval));
num_rreq++;
}
break;
case DSR_RERR:
if (num_rerr == (RERR_RATELIMIT - 1)) {
if (timeval_diff(&now, &rerr_ratel[0]) < 1000) {
DEBUG(LOG_DEBUG, 0, "RATELIMIT: Dropping RERR %ld ms",
timeval_diff(&now, &rerr_ratel[0]));
#ifdef NS_PORT
Packet::free(p);
#endif
return;
} else {
memmove(rerr_ratel, &rerr_ratel[1],
sizeof(struct timeval) * (num_rerr - 1));
memcpy(&rerr_ratel[num_rerr - 1], &now,
sizeof(struct timeval));
}
} else {
memcpy(&rerr_ratel[num_rerr], &now, sizeof(struct timeval));
num_rerr++;
}
break;
}
}

if (dst.s_addr == DSR_BROADCAST) {

gettimeofday(&this_host.bcast_time, NULL);

#ifdef NS_PORT

For more info: Https://ThesisScientist.com


ch->addr_type() = NS_AF_NONE;

sendPacket(p, dst, 0.0);


#else

retval = sendto(dev->sock, send_buf, len, 0,


(struct sockaddr *) &dst_addr, sizeof(dst_addr));

if (retval < 0) {

alog(LOG_WARNING, errno, __FUNCTION__, "Failed send to bc %s",


ip_to_str(dst));
return;
}
#endif

} else {

#ifdef NS_PORT
ch->addr_type() = NS_AF_INET;
/* We trust the decision of next hop for all DSR messages... */

if (dst.s_addr == DSR_BROADCAST)
sendPacket(p, dst, 0.001 * Random::uniform());
else
sendPacket(p, dst, 0.0);
#else
retval = sendto(dev->sock, send_buf, len, 0,
(struct sockaddr *) &dst_addr, sizeof(dst_addr));

if (retval < 0) {
alog(LOG_WARNING, errno, __FUNCTION__, "Failed send to %s",
ip_to_str(dst));
return;
}
#endif
}

/* Do not print hello msgs... */


if (!(dsr_msg->type == DSR_RREP && (dst.s_addr == DSR_BROADCAST)))
DEBUG(LOG_INFO, 0, "DSR msg to %s ttl=%d size=%u",
ip_to_str(dst), ttl, retval, len);

return;
}

DSR_msg *NS_CLASS dsr_socket_new_msg(void)


{
memset(send_buf, '\0', SEND_BUF_SIZE);
return (DSR_msg *) (send_buf);
}

DSR_msg *NS_CLASS dsr_socket_queue_msg(DSR_msg * dsr_msg, int size)


{
memcpy((char *) send_buf, dsr_msg, size);
return (DSR_msg *) send_buf;

For more info: Https://ThesisScientist.com


}

void dsr_socket_cleanup(void)
{
#ifndef NS_PORT
int i;

for (i = 0; i < MAX_NR_INTERFACES; i++) {


if (!DEV_NR(i).enabled)
continue;
close(DEV_NR(i).sock);
}
#endif /* NS_PORT */
}

oid NS_CLASS rt_table_init()


{
int i;

rt_tbl.num_entries = 0;
rt_tbl.num_active = 0;

/* We do a for loop here... NS does not like us to use memset() */


for (i = 0; i < RT_TABLESIZE; i++) {
INIT_LIST_HEAD(&rt_tbl.tbl[i]);
}
}

void NS_CLASS rt_table_destroy()


{
int i;
list_t *tmp = NULL, *pos = NULL;

for (i = 0; i < RT_TABLESIZE; i++) {


list_foreach_safe(pos, tmp, &rt_tbl.tbl[i]) {
rt_table_t *rt = (rt_table_t *) pos;

rt_table_delete(rt);
}
}
}

/* Calculate a hash value and table index given a key... */


unsigned int hashing(struct in_addr *addr, hash_value * hash)
{
/* *hash = (*addr & 0x7fffffff); */
*hash = (hash_value) addr->s_addr;

return (*hash & RT_TABLEMASK);


}

rt_table_t *NS_CLASS rt_table_insert(struct in_addr dest_addr,


struct in_addr next,
u_int8_t hops, u_int32_t seqno,
u_int32_t life, u_int8_t state,
u_int16_t flags, unsigned int ifindex)

For more info: Https://ThesisScientist.com


{
hash_value hash;
unsigned int index;
list_t *pos;
rt_table_t *rt;
struct in_addr nm;
nm.s_addr = 0;

/* Calculate hash key */


index = hashing(&dest_addr, &hash);

/* Check if we already have an entry for dest_addr */


list_foreach(pos, &rt_tbl.tbl[index]) {
rt = (rt_table_t *) pos;
if (memcmp(&rt->dest_addr, &dest_addr, sizeof(struct in_addr))
== 0) {
DEBUG(LOG_INFO, 0, "%s already exist in routing table!",
ip_to_str(dest_addr));

return NULL;
}
}

if ((rt = (rt_table_t *) malloc(sizeof(rt_table_t))) == NULL) {


fprintf(stderr, "Malloc failed!\n");
exit(-1);
}

memset(rt, 0, sizeof(rt_table_t));

rt->dest_addr = dest_addr;
rt->next_hop = next;
rt->dest_seqno = seqno;
rt->flags = flags;
rt->hcnt = hops;
rt->ifindex = ifindex;
rt->hash = hash;
rt->state = state;

timer_init(&rt->rt_timer, &NS_CLASS route_expire_timeout, rt);

timer_init(&rt->ack_timer, &NS_CLASS rrep_ack_timeout, rt);

timer_init(&rt->hello_timer, &NS_CLASS hello_timeout, rt);

rt->last_hello_time.tv_sec = 0;
rt->last_hello_time.tv_usec = 0;
rt->hello_cnt = 0;

rt->nprec = 0;
INIT_LIST_HEAD(&rt->precursors);

/* Insert first in bucket... */

rt_tbl.num_entries++;

For more info: Https://ThesisScientist.com


DEBUG(LOG_INFO, 0, "Inserting %s (bucket %d) next hop %s",
ip_to_str(dest_addr), index, ip_to_str(next));

list_add(&rt_tbl.tbl[index], &rt->l);

if (state == INVALID) {

if (flags & RT_REPAIR) {


rt->rt_timer.handler = &NS_CLASS local_repair_timeout;
life = ACTIVE_ROUTE_TIMEOUT;
} else {
rt->rt_timer.handler = &NS_CLASS route_delete_timeout;
life = DELETE_PERIOD;
}

} else {
rt_tbl.num_active++;
#ifndef NS_PORT
nl_send_add_route_msg(dest_addr, next, hops, life, flags,
ifindex);
#endif
}

#ifdef CONFIG_GATEWAY_DISABLE
if (rt->flags & RT_GATEWAY)
rt_table_update_inet_rt(rt, life);
#endif

//#ifdef NS_PORT
DEBUG(LOG_INFO, 0, "New timer for %s, life=%d",
ip_to_str(rt->dest_addr), life);

if (life != 0)
timer_set_timeout(&rt->rt_timer, life);
//#endif
/* In case there are buffered packets for this destination, we
* send them on the new route. */
if (rt->state == VALID && seek_list_remove(seek_list_find(dest_addr))) {
#ifdef NS_PORT
if (rt->flags & RT_INET_DEST)
packet_queue_set_verdict(dest_addr, PQ_ENC_SEND);
else
packet_queue_set_verdict(dest_addr, PQ_SEND);
#endif
}
return rt;
}

rt_table_t *NS_CLASS rt_table_update(rt_table_t * rt, struct in_addr next,


u_int8_t hops, u_int32_t seqno,
u_int32_t lifetime, u_int8_t state,
u_int16_t flags)
{
struct in_addr nm;
nm.s_addr = 0;

For more info: Https://ThesisScientist.com


if (rt->state == INVALID && state == VALID) {

rt_tbl.num_active++;

if (rt->flags & RT_REPAIR)


flags &= ~RT_REPAIR;

#ifndef NS_PORT
nl_send_add_route_msg(rt->dest_addr, next, hops, lifetime,
flags, rt->ifindex);
#endif

} else if (rt->next_hop.s_addr != 0 &&


rt->next_hop.s_addr != next.s_addr) {

DEBUG(LOG_INFO, 0, "rt->next_hop=%s, new_next_hop=%s",


ip_to_str(rt->next_hop), ip_to_str(next));

#ifndef NS_PORT
nl_send_add_route_msg(rt->dest_addr, next, hops, lifetime,
flags, rt->ifindex);
#endif
}

if (hops > 1 && rt->hcnt == 1) {


rt->last_hello_time.tv_sec = 0;
rt->last_hello_time.tv_usec = 0;
rt->hello_cnt = 0;
timer_remove(&rt->hello_timer);

neighbor_link_break(rt);
}

rt->flags = flags;
rt->dest_seqno = seqno;
rt->next_hop = next;
rt->hcnt = hops;

#ifdef CONFIG_GATEWAY
if (rt->flags & RT_GATEWAY)
rt_table_update_inet_rt(rt, lifetime);
#endif

//#ifdef NS_PORT
rt->rt_timer.handler = &NS_CLASS route_expire_timeout;

if (!(rt->flags & RT_INET_DEST))


rt_table_update_timeout(rt, lifetime);
//#endif

/* Finally, mark as VALID */


rt->state = state;

if (rt->state == VALID

For more info: Https://ThesisScientist.com


&& seek_list_remove(seek_list_find(rt->dest_addr))) {
#ifdef NS_PORT
if (rt->flags & RT_INET_DEST)
packet_queue_set_verdict(rt->dest_addr, PQ_ENC_SEND);
else
packet_queue_set_verdict(rt->dest_addr, PQ_SEND);
#endif
}
return rt;
}

NS_INLINE rt_table_t *NS_CLASS rt_table_update_timeout(rt_table_t * rt,


u_int32_t lifetime)
{
struct timeval new_timeout;

if (!rt)
return NULL;

if (rt->state == VALID) {

gettimeofday(&new_timeout, NULL);
timeval_add_msec(&new_timeout, lifetime);

if (timeval_diff(&rt->rt_timer.timeout, &new_timeout) < 0)


timer_set_timeout(&rt->rt_timer, lifetime);
} else
timer_set_timeout(&rt->rt_timer, lifetime);

return rt;
}

/* Update route timeouts in response to an incoming or outgoing data packet. */


void NS_CLASS rt_table_update_route_timeouts(rt_table_t * fwd_rt,
rt_table_t * rev_rt)
{
rt_table_t *next_hop_rt = NULL;

if (fwd_rt && fwd_rt->state == VALID) {

if (llfeedback || fwd_rt->flags & RT_INET_DEST ||


fwd_rt->hcnt != 1 || fwd_rt->hello_timer.used)
rt_table_update_timeout(fwd_rt, ACTIVE_ROUTE_TIMEOUT);

next_hop_rt = rt_table_find(fwd_rt->next_hop);

if (next_hop_rt && next_hop_rt->state == VALID &&


next_hop_rt->dest_addr.s_addr != fwd_rt->dest_addr.s_addr &&
(llfeedback || fwd_rt->hello_timer.used))
rt_table_update_timeout(next_hop_rt,
ACTIVE_ROUTE_TIMEOUT);

For more info: Https://ThesisScientist.com


if (rev_rt && rev_rt->state == VALID) {

if (llfeedback || rev_rt->hcnt != 1 || rev_rt->hello_timer.used)


rt_table_update_timeout(rev_rt, ACTIVE_ROUTE_TIMEOUT);

next_hop_rt = rt_table_find(rev_rt->next_hop);

if (next_hop_rt && next_hop_rt->state == VALID && rev_rt &&


next_hop_rt->dest_addr.s_addr != rev_rt->dest_addr.s_addr &&
(llfeedback || rev_rt->hello_timer.used))
rt_table_update_timeout(next_hop_rt,
ACTIVE_ROUTE_TIMEOUT);

rt_table_t *NS_CLASS rt_table_find(struct in_addr dest_addr)


{
hash_value hash;
unsigned int index;
list_t *pos;

if (rt_tbl.num_entries == 0)
return NULL;

/* Calculate index */
index = hashing(&dest_addr, &hash);

/* Handle collisions: */
list_foreach(pos, &rt_tbl.tbl[index]) {
rt_table_t *rt = (rt_table_t *) pos;

if (rt->hash != hash)
continue;

if (memcmp(&dest_addr, &rt->dest_addr, sizeof(struct in_addr))


== 0)
return rt;

}
return NULL;
}

rt_table_t *NS_CLASS rt_table_find_gateway()


{
rt_table_t *gw = NULL;
int i;

for (i = 0; i < RT_TABLESIZE; i++) {


list_t *pos;
list_foreach(pos, &rt_tbl.tbl[i]) {
rt_table_t *rt = (rt_table_t *) pos;

if (rt->flags & RT_GATEWAY && rt->state == VALID) {


if (!gw || rt->hcnt < gw->hcnt)
gw = rt;
}

For more info: Https://ThesisScientist.com


}
}
return gw;
}

#ifdef CONFIG_GATEWAY
int NS_CLASS rt_table_update_inet_rt(rt_table_t * gw, u_int32_t life)
{
int n = 0;
int i;

if (!gw)
return -1;

for (i = 0; i < RT_TABLESIZE; i++) {


list_t *pos;
list_foreach(pos, &rt_tbl.tbl[i]) {
rt_table_t *rt = (rt_table_t *) pos;

if (rt->flags & RT_INET_DEST && rt->state == VALID) {


rt_table_update(rt, gw->dest_addr, gw->hcnt, 0,
life, VALID, rt->flags);
n++;
}
}
}
return n;
}
#endif /* CONFIG_GATEWAY_DISABLED */

/* Route expiry and Deletion. */


int NS_CLASS rt_table_invalidate(rt_table_t * rt)
{
struct timeval now;

gettimeofday(&now, NULL);

if (rt == NULL)
return -1;

/* If the route is already invalidated, do nothing... */


if (rt->state == INVALID) {
DEBUG(LOG_DEBUG, 0, "Route %s already invalidated!!!",
ip_to_str(rt->dest_addr));
return -1;
}

if (rt->hello_timer.used) {
DEBUG(LOG_DEBUG, 0, "last HELLO: %ld",
timeval_diff(&now, &rt->last_hello_time));
}

/* Remove any pending, but now obsolete timers. */


timer_remove(&rt->rt_timer);
timer_remove(&rt->hello_timer);
timer_remove(&rt->ack_timer);

For more info: Https://ThesisScientist.com


/* Mark the route as invalid */
rt->state = INVALID;
rt_tbl.num_active--;

rt->hello_cnt = 0;

/* When the lifetime of a route entry expires, increase the sequence


number for that entry. */
seqno_incr(rt->dest_seqno);

rt->last_hello_time.tv_sec = 0;
rt->last_hello_time.tv_usec = 0;

#ifndef NS_PORT
nl_send_del_route_msg(rt->dest_addr, rt->next_hop, rt->hcnt);
#endif

#ifdef CONFIG_GATEWAY

if (rt->flags & RT_GATEWAY) {


int i;

rt_table_t *gw = rt_table_find_gateway();

for (i = 0; i < RT_TABLESIZE; i++) {


list_t *pos;
list_foreach(pos, &rt_tbl.tbl[i]) {
rt_table_t *rt2 = (rt_table_t *) pos;

if (rt2->state == VALID
&& (rt2->flags & RT_INET_DEST)
&& (rt2->next_hop.s_addr ==
rt->dest_addr.s_addr)) {
if (0) {
DEBUG(LOG_DEBUG, 0,
"Invalidated GW %s but found new GW %s for
%s",
ip_to_str(rt->dest_addr),
ip_to_str(gw->dest_addr),
ip_to_str(rt2->
dest_addr));
rt_table_update(rt2,
gw->dest_addr,
gw->hcnt, 0,
timeval_diff
(&rt->rt_timer.
timeout, &now),
VALID,
rt2->flags);
} else {
rt_table_invalidate(rt2);
precursor_list_destroy(rt2);
}
}

For more info: Https://ThesisScientist.com


}
}
}
#endif

if (rt->flags & RT_REPAIR) {


/* Set a timeout for the repair */

rt->rt_timer.handler = &NS_CLASS local_repair_timeout;


timer_set_timeout(&rt->rt_timer, ACTIVE_ROUTE_TIMEOUT);

DEBUG(LOG_DEBUG, 0, "%s kept for repairs during %u msecs",


ip_to_str(rt->dest_addr), ACTIVE_ROUTE_TIMEOUT);
} else {

/* Schedule a deletion timer */


rt->rt_timer.handler = &NS_CLASS route_delete_timeout;
timer_set_timeout(&rt->rt_timer, DELETE_PERIOD);

DEBUG(LOG_DEBUG, 0, "%s removed in %u msecs",


ip_to_str(rt->dest_addr), DELETE_PERIOD);
}

return 0;
}

void NS_CLASS rt_table_delete(rt_table_t * rt)


{
if (!rt) {
DEBUG(LOG_ERR, 0, "No route entry to delete");
return;
}

list_detach(&rt->l);

precursor_list_destroy(rt);

if (rt->state == VALID) {

#ifndef NS_PORT
nl_send_del_route_msg(rt->dest_addr, rt->next_hop, rt->hcnt);
#endif
rt_tbl.num_active--;
}
/* Make sure timers are removed... */
timer_remove(&rt->rt_timer);
timer_remove(&rt->hello_timer);
timer_remove(&rt->ack_timer);

rt_tbl.num_entries--;

free(rt);
return;
}

void NS_CLASS precursor_add(rt_table_t * rt, struct in_addr addr)

For more info: Https://ThesisScientist.com


{
precursor_t *pr;
list_t *pos;

/* Sanity check */
if (!rt)
return;

list_foreach(pos, &rt->precursors) {
pr = (precursor_t *) pos;

if (pr->neighbor.s_addr == addr.s_addr)
return;
}

if ((pr = (precursor_t *) malloc(sizeof(precursor_t))) == NULL) {


perror("Could not allocate memory for precursor node!!\n");
exit(-1);
}

DEBUG(LOG_INFO, 0, "Adding precursor %s to rte %s",


ip_to_str(addr), ip_to_str(rt->dest_addr));

pr->neighbor.s_addr = addr.s_addr;

/* Insert in precursors list */

list_add(&rt->precursors, &pr->l);
rt->nprec++;

return;
}

void NS_CLASS precursor_remove(rt_table_t * rt, struct in_addr addr)


{
list_t *pos;

/* Sanity check */
if (!rt)
return;

list_foreach(pos, &rt->precursors) {
precursor_t *pr = (precursor_t *) pos;
if (pr->neighbor.s_addr == addr.s_addr) {
DEBUG(LOG_INFO, 0, "Removing precursor %s from rte %s",
ip_to_str(addr), ip_to_str(rt->dest_addr));

list_detach(pos);
rt->nprec--;
free(pr);
return;
}
}
}

void precursor_list_destroy(rt_table_t * rt)

For more info: Https://ThesisScientist.com


{
list_t *pos, *tmp;

/* Sanity check */
if (!rt)
return;

list_foreach_safe(pos, tmp, &rt->precursors) {


precursor_t *pr = (precursor_t *) pos;
list_detach(pos);
rt->nprec--;
free(pr);
}
}

For more info: Https://ThesisScientist.com

You might also like