Point to Point network, UDP echo client, and routing

1,283 views
Skip to first unread message

Steve Marotta

unread,
May 13, 2011, 5:35:27 PM5/13/11
to ns-3-users
Hi again,

I've got a simple point-to-point network, and I'm trying to get the
network to route packets across multiple hops from one end of the
network to the other. To do this, I'm using the UDP echo client/server
included with ns-3. Now, I have no expectations that packets will be
correctly routed back to the sender at this point, but I'm not even
seeing my packets getting routed to the right destination node. They
go one hop and then bounce back to the origin.

I'm actually trying to do this with a more complicated TCP app, but I
can't even get it working with a simple echo server. All I want to do
is see my network route packets across the network to their intended
destination. At this point, I don't even care about seeing them echo
back to the client. One complete trip would make me happy. I have been
using NetAnim to visualise what's happening on my network and see what
my packets have been doing. I'd truly appreciate any and all help that
you, the esteemed ns-3 forum, can provide.

At the risk of breaching protocol and making people's lives miserable,
I'm going to copy and paste the source that I'm dealing with, or a
reasonable facsimile:

#include "ns3/core-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/overlay-module.h"
#include <iostream>

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("SimplePhysicalNetwork");

void setNodeLocation(Ptr<Node> node, double x, double y)
{
Ptr<CanvasLocation> loc = node->GetObject<CanvasLocation>();
if (0 == loc)
{
loc = CreateObject<CanvasLocation>();
node->AggregateObject(loc);
}
Vector locVec(x, y, 0);
loc->SetLocation(locVec);
}

void boundingBox(NodeContainer nodes)
{
setNodeLocation(nodes.Get(0), 3.5, 2.5);
setNodeLocation(nodes.Get(1), 7, 2.5);
setNodeLocation(nodes.Get(2), 2.5, 1);
setNodeLocation(nodes.Get(3), 8, 1);
setNodeLocation(nodes.Get(4), 2.5, 4);
setNodeLocation(nodes.Get(5), 8, 4);
setNodeLocation(nodes.Get(6), 1, 1);
setNodeLocation(nodes.Get(7), 9.5, 1);
setNodeLocation(nodes.Get(8), 1, 4);
setNodeLocation(nodes.Get(9), 9.5, 4);
}

int main(int argc, char *argv[])
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);

int NUM_NODES = 10;

NodeContainer nodes;
nodes.Create(NUM_NODES);

// We're probably going to want different bandwidth values on
different links
PointToPointHelper p2p;
p2p.SetDeviceAttribute("DataRate", StringValue("5Mbps"));
p2p.SetChannelAttribute("Delay", StringValue("2ms"));

// Again, we may want to have different connection types.
// Different bandwidths, latencies, connection quality, that sort of
thing.
NetDeviceContainer devices;
devices.Add(p2p.Install(nodes.Get(0), nodes.Get(1)));
devices.Add(p2p.Install(nodes.Get(0), nodes.Get(2)));
devices.Add(p2p.Install(nodes.Get(1), nodes.Get(3)));
devices.Add(p2p.Install(nodes.Get(0), nodes.Get(4)));
devices.Add(p2p.Install(nodes.Get(1), nodes.Get(5)));
devices.Add(p2p.Install(nodes.Get(2), nodes.Get(6)));
devices.Add(p2p.Install(nodes.Get(3), nodes.Get(7)));
devices.Add(p2p.Install(nodes.Get(4), nodes.Get(8)));
devices.Add(p2p.Install(nodes.Get(5), nodes.Get(9)));

InternetStackHelper stack;
stack.Install(nodes);

Ipv4AddressHelper address;
address.SetBase("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer interfaces = address.Assign(devices);

UdpEchoServerHelper echoServer(9);

// Create an application container for the echo servers
ApplicationContainer serverApps;
serverApps.Add(echoServer.Install(nodes.Get(9)));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(interfaces.GetAddress(17), 9);
echoClient.SetAttribute("MaxPackets", UintegerValue(15));
echoClient.SetAttribute("Interval", TimeValue(Seconds(1.0)));
echoClient.SetAttribute("PacketSize", UintegerValue(1024));

// Create an application container for the echo clients
ApplicationContainer clientApps;
clientApps.Add(echoClient.Install(nodes.Get(6)));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));


AnimationInterface anim;
anim.SetOutputFile("simple.tr");

boundingBox(nodes);

anim.StartAnimation();

Ipv4GlobalRoutingHelper::PopulateRoutingTables();

Simulator::Run();
Simulator::Destroy();
anim.StopAnimation();
return 0;
}

kurnia...@gmail.com

unread,
May 13, 2011, 7:37:53 PM5/13/11
to ns-3-...@googlegroups.com
Hi..

I'm still doing that case too. I also got problem. Btw, can u simulate it using NetAnim? I don't know how to simulate it using NetAnim. I analyze network only using pcap & tr. Btw, I wanna ask again about how to perform such as throughput, packet loss in graph?

Regards, Nia
Powered by Telkomsel BlackBerry®
--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Steve Marotta

unread,
May 13, 2011, 8:23:27 PM5/13/11
to ns-3-users
The code as shown will generate a simple.tr file that you can feed to
NetAnim to get a visualization. As far as installing NetAnim, I defer
to the documentation:

http://www.nsnam.org/wiki/index.php/NetAnim

~ Steve

kurnia...@gmail.com

unread,
May 13, 2011, 8:33:33 PM5/13/11
to ns-3-...@googlegroups.com
I try to run your code, but still error. Btw, I don't have overlay-module.h in ns-3.10. Where can I get it?

Steve Marotta

unread,
May 13, 2011, 9:35:56 PM5/13/11
to ns-3-users
That's from a custom module that I wrote. I removed the code that uses
it, but I forgot to remove the include line. You can safely remove it.

~ Steve

Tom Henderson

unread,
May 14, 2011, 12:32:14 AM5/14/11
to ns-3-...@googlegroups.com
On 05/13/2011 02:35 PM, Steve Marotta wrote:
> Hi again,
>
> I've got a simple point-to-point network, and I'm trying to get the
> network to route packets across multiple hops from one end of the
> network to the other. To do this, I'm using the UDP echo client/server
> included with ns-3. Now, I have no expectations that packets will be
> correctly routed back to the sender at this point, but I'm not even
> seeing my packets getting routed to the right destination node. They
> go one hop and then bounce back to the origin.
>
...

> At the risk of breaching protocol and making people's lives miserable,
> I'm going to copy and paste the source that I'm dealing with, or a
> reasonable facsimile:

It would have been impossible to debug your problem if you hadn't
provided your program.

I believe that the issue is that you are assigning all point-to-point
links to the same IP subnet 10.1.1.0/24. Your packets are looping back
and forth between two nodes because (I'm guessing), from the perspective
of routing, all addresses are reachable from any interface and the nodes
are arbitrarily picking one to send it out on, and the choices happen to
cause a single-hop loop.

I think it will be easier if you keep your NetDeviceContainer separate,
one for each link, and then assign a different prefix to each link. See
how it is done for the routing examples in examples/routing that use
point-to-point topologies.

- Tom

Steve Marotta

unread,
May 16, 2011, 10:49:27 AM5/16/11
to ns-3-...@googlegroups.com

It would have been impossible to debug your problem if you hadn't
provided your program.

Yeah, I realized that after I posted my message. I was originally afraid that the code would be too unwieldy to go through, but I'd pared it down considerably before posting it.

Thanks for your response! I'll take a look at the example code and give that a try.

~ Steve
 

Steve Marotta

unread,
May 18, 2011, 5:29:27 PM5/18/11
to ns-3-users
I put each link on its own subnet, and now packets are being routed
correctly with reckless abandon! Thanks for the tip.

~ Steve

Hojjat

unread,
Nov 14, 2012, 1:04:37 PM11/14/12
to ns-3-...@googlegroups.com
Hi everybody

I'm new user in ns3

i want create 3 nodes like this :

n0-----------n1------------n2

n0 send packet to n2 but n1 receive it and forward it to n2

can you write this script

i need script that like first.cc example

thank you !

Hojjat

unread,
Nov 14, 2012, 1:11:54 PM11/14/12
to ns-3-...@googlegroups.com


On Wednesday, November 14, 2012 10:04:37 AM UTC-8, Hojjat wrote:
Hi everybody

I'm new user in ns3

I need help !
i want create 3 nodes like this :

n0-----------n1------------n2

n0 send packet to n2 but n1 receive it and forward it to n2

can you write this script

i need script that like first.cc example

help me please !

thank you !
Reply all
Reply to author
Forward
0 new messages