Hi everyone, I'm new to ns3 and I have problem when building a point to point star topology.
I tried to make a simple network with 1 router and 2 nodes like the diagram:
# n0 r n1
# | _ |
# ====|_|====
# router
So apparently, I want to create the network with the address of router is, for example, 10.1.1.1, and 2 nodes are 10.1.1.2 and 10.1.1.3.
However, since I have to put the pairs (router - node 0) and (router - node 1) in different NetDeviceContainer, then when I use Ipv4InterfaceContainer to assign address. it appears that each net device container has to have different network number ( like 10.1.1.0 and 10.1.2.0)... Anyone can help me on this?
This is the code I did by myself
// Create 3 nodes: n0, n1 and router r
// router: c:[1]; no: c[0], n1: c[2];
NodeContainer c;
c.Create (3);
NodeContainer n0r = NodeContainer (c.Get (0), c.Get (1));
NodeContainer n1r = NodeContainer (c.Get (1), c.Get (2));
// install internet stack to 3 nodes
InternetStackHelper internet;
internet.Install (c);
// create p2p link
PointToPointHelper p2p;
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer d0r = p2p.Install (n0r);
NetDeviceContainer d1r = p2p.Install (n1r);
NS_LOG_INFO ("====================Creating Topology=========================");
// assign ip address
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer i0r = ipv4.Assign (d0r);
ipv4.NewAddress();
Ipv4InterfaceContainer i1r = ipv4.Assign (d1r);