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.