Configuring default gateway in a ns3 node

1,661 views
Skip to first unread message

Dani Camps

unread,
May 20, 2010, 6:20:57 AM5/20/10
to ns-3-...@googlegroups.com

Dear all,

I would like to know how to specify a default gateway in a certain node in an ns3 simulation. Currently I use "Ipv4GlobalRoutingHelper::PopulateRoutingTables ();" to populate routing tables, but I do not find the way to establish a default gateway.

Best Regards

Daniel

--
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.
Message has been deleted

Antti Mäkelä

unread,
May 20, 2010, 10:20:47 AM5/20/10
to ns-3-users
On May 20, 1:20 pm, Dani Camps <danicamp...@gmail.com> wrote:
> Dear all,
>
> I would like to know how to specify a default gateway in a certain node in
> an ns3 simulation. Currently I use
> "Ipv4GlobalRoutingHelper::PopulateRoutingTables ();" to populate routing
> tables, but I do not find the way to establish a default gateway.

That's because global routing only cares about existing subnets. You
can either:

Use static routing for that:

Ptr<Node> Node = your node;
Ipv4StaticRoutingHelper helper;
Ptr<Ipv4> ipv4 = Node->GetObject<Ipv4>();
Ptr<Ipv4StaticRouting> Ipv4stat = helper.GetStaticRouting(ipv4);
Ipv4stat->SetDefaultRoute(....)

OR, you can use global routing's external routes, or injection:

PopulateRoutingTables();
Ptr<GlobalRouter> gr = Node->GetObject<GlobalRouter>();
gr->InjectRoute(.....)
Ipv4GlobalRoutingHelper::RecomputeRoutingTables();

See doxygen for parameters.

Pavel Boyko

unread,
May 21, 2010, 2:34:45 AM5/21/10
to ns-3-...@googlegroups.com
Hi, Antti,

I think this answer deserves to be here:
http://www.nsnam.org/wiki/index.php/Category:Samples . Could you do
this?

Pavel

Dani Camps

unread,
May 21, 2010, 4:53:38 AM5/21/10
to ns-3-...@googlegroups.com

Hi Antti,

Thanks for the response, it worked. Only a small addition in case someone else needs to solve a similar problem. I needed to include "ns3/global-router-interface.h" in order to use GlobalRouter.

Best Regards

Daniel

Tom Henderson

unread,
May 21, 2010, 12:46:57 PM5/21/10
to ns-3-...@googlegroups.com
On 5/21/10 1:53 AM, Dani Camps wrote:
>
> Hi Antti,
>
> Thanks for the response, it worked. Only a small addition in case
> someone else needs to solve a similar problem. I needed to include
> "ns3/global-router-interface.h" in order to use GlobalRouter.
>
> Best Regards
>
> Daniel
>

Daniel, I am curious about why you want to install a default route if
global routing already provides a route to every subnet in the scenario?
(I'm just trying to learn more about how people are using global
routing, in practice)

- Tom

Dani Camps

unread,
May 21, 2010, 2:47:05 PM5/21/10
to ns-3-...@googlegroups.com
Hi Tom,

I am using ns3 for emulation. I have two "real" networks connected through an ns3 simulation which has some other subnetworks inside. Therefore, to make the two "real" networks connect to each other I have to tell the ns3 nodes about the them.

Best Regards

Daniel

Siku

unread,
Oct 15, 2013, 1:25:38 PM10/15/13
to ns-3-...@googlegroups.com
 Sir how to set default gateway.....And also how to configure links between nodes and gateway with different configuration,,

Jatin Singh

unread,
Aug 22, 2015, 2:57:02 AM8/22/15
to ns-3-users
thanks for this information .but i am facing still a problem


this my real topology.i want that a real traffic should come from router 1 and traffic comes into ns3 emulation and goes from ns3 to real router R2. am iam not able solve this problem.can anybody help me on this problem.
ns3.PNG
Reply all
Reply to author
Forward
0 new messages