Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

to handle routing replies ( RREP ) , errors ( RERR ) , topology control ( TC ) , MPT , and neighbor discovery according

to handle routing replies (RREP), errors (RERR), topology control (TC), MPT, and neighbor discovery according to your hybrid routing protocol specifications. Writ eme code of it.//...(Previous code)
// Function to send a specified number of hybrid RREQ packets
void SendHybridRREQ(Ptr source, Ipv4Address destAddress, uint32_t numPackets){
for (uint32_t i =0; i < numPackets; ++i){
CustomAODVRouteRequest(source, destAddress);
}
}
// Function to measure PDR, E2ED, throughput, and routing overhead
void MeasurePerformance(uint32_t numNodes, uint32_t numPackets){
//...(Your measurement logic goes here)
// Perform simulations with different numbers of nodes and packets
}
int main(){
//...(Previous code)
// Send 100,1000,5000 hybrid RREQ packets for 20,30,50,100 nodes
for (uint32_t numNodes : {20,30,50,100}){
NodeContainer nodes;
nodes.Create(numNodes);
//...(Rest of the setup logic)
// Send hybrid RREQ packets
Ipv4Address destAddress("192.168.1.2");
SendHybridRREQ(nodes.Get(0), destAddress, 100);
SendHybridRREQ(nodes.Get(0), destAddress, 1000);
SendHybridRREQ(nodes.Get(0), destAddress, 5000);
//...(Run simulation, measure performance, etc.)
}
// Perform additional simulations and measurements as requested
MeasurePerformance(10,1000);
MeasurePerformance(20,1000);
MeasurePerformance(30,1000);
MeasurePerformance(50,1000);
MeasurePerformance(100,1000);
MeasurePerformance(1000,1000);
//...(Rest of the main function)
}b#include
"
ns
3
/
core
-
module.h
"
#include
"
ns
3
/
network
-
module.h
"
#include
"
ns
3
/
mobility
-
module.h
"
#include
"
ns
3
/
internet
-
module.h
"
#include
"
ns
3
/
applications
-
module.h
"
#include
"
ns
3
/
aodv
-
module.h
"
#include
"
ns
3
/
olsr
-
module.h
"
using namespace ns
3
;
enum RoutingProtocol
{
AODV, OLSR, HYBRID
}
;
struct RouteEntry
{
Ipv
4
Address dest;
Ipv
4
Address nextHop;
RoutingProtocol protocol;
RouteEntry
(
Ipv
4
Address dest, Ipv
4
Address nextHop, RoutingProtocol protocol
)
: dest
(
dest
)
,
nextHop
(
nextHop
)
,
protocol
(
protocol
)
{
}
}
;
std::vector routingTable;
bool IsAODVZone
(
Ptr node
)
{
/
/
Placeholder logic for AODV zone determination
return false;
}
void CustomAODVRouteRequest
(
Ptr source, Ipv
4
Address destAddress
)
{
Ptr packet
=
Create
(
)
;
Ipv
4
Header ipvHeader;
ipvHeader.SetSource
(
source
-
>
GetObject
(
)
-
>
GetAddress
(
1
,
0
)
.
GetLocal
(
)
)
;
ipvHeader.SetDestination
(
destAddress
)
;
packet
-
>
AddHeader
(
ipvHeader
)
;
packet
-
>
AddHeader
(
AodvHeader
(
)
)
;
source
-
>
Send
(
packet
)
;
}
void CustomAODVRouteReply
(
Ptr node, RouteEntry route
)
{
Ptr reply
=
Create
(
)
;
reply
-
>
AddHeader
(
route
)
;
node
-
>
Send
(
reply
)
;
}
void HybridRoutingLogic
(
Ptr node, Ipv
4
Address destAddress
)
{
if
(
IsAODVZone
(
node
)
)
{
CustomAODVRouteRequest
(
node
,
destAddress
)
;
}
else
{
/
/
Placeholder for OLSR logic
/
/
You can implement your OLSR routing logic here
/
/
For simplicity, this example does not include detailed OLSR logic
/
/
For now, let's assume OLSR does nothing
}
}
class PacketMonitor
{
public:
PacketMonitor
(
)
: lostPackets
(
0
)
{
}
void CheckForLostPackets
(
Ptr packet
)
{
if
(
!
packet
-
>
Received
(
)
)
{
lostPackets
+
+
;
}
}
int GetLostPackets
(
)
{
return lostPackets;
}
private:
int lostPackets;
}
;
int main
(
)
{
NodeContainer nodes;
nodes.Create
(
10
)
;
MobilityHelper mobility;
mobility.SetMobilityModel
(
"
ns
3
::RandomWalk
2
dMobilityModel",
"MinSpeed", StringValue
(
"
1.0
"
)
,
"MaxSpeed", StringValue
(
"
10.0
"
)
)
;
mobility.Install
(
nodes
)
;
InternetStackHelper internet;
internet.Install
(
nodes
)
;
AodvHelper aodv;
OlsrHelper olsr;
Ipv
4
StaticRoutingHelper staticRouting;
Ipv
4
AddressHelper address;
RoutingProtocol currentProtocol
=
AODV;
PacketMonitor monitor;
Ipv
4
Address destAddress
(
"
192.168
.
1.2
"
)
;
/
/
Assign IP addresses
address.SetBase
(
"
192.168
.
1.0
"
,
"
255.255
.
255.0
"
)
;
Ipv
4
InterfaceContainer interfaces

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

Find the Jacobian of the transformation. x = pe q , y = qe p

Answered: 1 week ago

Question

How can emotions cause communication breakdown?

Answered: 1 week ago

Question

2. What are the prospects for these occupations?pg 87

Answered: 1 week ago