AODV Routing

46 views
Skip to first unread message

Dadi abdalkader

unread,
May 17, 2024, 3:06:26 PMMay 17
to ns-3-users
hi i have this code and when i open The routing file "firstanim_routetable.xml" it show all nodes have 1 hops 
i wanna use Multihops for exemple node 1 send a packet to nodes 2 
i want the packet pass withg multiple intermedry  nodes to arrive to destination 
#include "ns3/csma-module.h"
#include "ns3/netanim-module.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/netanim-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/aodv-module.h"
#include "ns3/internet-stack-helper.h"
#include "ns3/udp-socket-factory.h"
#include "ns3/socket.h"
#include "ns3/csma-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FirstLoggingExample");
int
main (int argc, char *argv[])
{


NodeContainer nodes;
nodes.Create (50);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));

NetDeviceContainer devices;
devices = csma.Install (nodes);
InternetStackHelper stack;

AodvHelper aodv;
stack.SetRoutingHelper (aodv);
stack.Install (nodes);
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("aodv.routes",
std::ios::out);
aodv.PrintRoutingTableAllAt (Seconds (125), routingStream);


Ipv4AddressHelper address;
address.SetBase ("192.168.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
uint64_t port = 9;
UdpEchoServerHelper echoServer (port);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (3));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (3), port);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1000));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.1)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));

Ptr<FlowMonitor> flowmon;
FlowMonitorHelper flowmonHelper;
flowmon = flowmonHelper.InstallAll ();

AnimationInterface anim ("first_animation_demo.xml");
anim.UpdateNodeDescription (3, "UDP Echo Server");
anim.UpdateNodeDescription (0, "UDP Echo Client");

anim.EnablePacketMetadata ();

anim.EnableIpv4RouteTracking ("firstanim_routetable.xml", Seconds (0), Seconds (2),Seconds (0.25));

anim.EnableIpv4L3ProtocolCounters (Seconds (0), Seconds (10));
anim.EnableQueueCounters (Seconds (0), Seconds (10));

Simulator::Stop (Seconds(11.0));
Simulator::Run ();

flowmon->SerializeToXmlFile ("firstanim_flowmetrics.xml", true, true);
Simulator::Destroy ();

}

Tommaso Pecorella

unread,
May 18, 2024, 4:54:25 AMMay 18
to ns-3-users
Do you understand that you did connect all the nodes to the same CSMA network and they're all in the same subnet?

Dadi abdalkader

unread,
May 18, 2024, 11:19:44 AMMay 18
to ns-3-users

so what should i do ??

Tommaso Pecorella

unread,
May 18, 2024, 11:24:29 AMMay 18
to ns-3-users
I don't know... maybe study the examples?
Maybe you'll get some ideas - and maybe (maybe) there's on that shows exactly what you need - perhaps "examples/routing/manet-routing-compare.cc".
I don't know, just saying.

Reply all
Reply to author
Forward
0 new messages