30 import ns.internet_apps
38 cmd = ns.core.CommandLine();
43 print (
"Create nodes")
44 n0 = ns.network.Node();
45 r = ns.network.Node();
46 n1 = ns.network.Node();
48 net1 = ns.network.NodeContainer();
51 net2 = ns.network.NodeContainer();
54 all = ns.network.NodeContainer();
60 internetv6 = ns.internet.InternetStackHelper();
61 internetv6.Install(all);
64 csma = ns.csma.CsmaHelper();
65 csma.SetChannelAttribute(
"DataRate", ns.network.DataRateValue(ns.network.DataRate(5000000)));
66 csma.SetChannelAttribute(
"Delay", ns.core.TimeValue(ns.core.MilliSeconds(2)));
67 d1 = csma.Install(net1);
68 d2 = csma.Install(net2);
72 ipv6 = ns.internet.Ipv6AddressHelper();
73 ipv6.SetBase(ns.network.Ipv6Address(
"2001:1::"), ns.network.Ipv6Prefix(64));
75 i1.SetForwarding(1,
True);
76 i1.SetDefaultRouteInAllNodes(1);
77 ipv6.SetBase(ns.network.Ipv6Address(
"2001:2::"), ns.network.Ipv6Prefix(64));
79 i2.SetForwarding(0,
True);
80 i2.SetDefaultRouteInAllNodes(0);
86 interPacketInterval = ns.core.Seconds(1.);
87 ping6 = ns.internet_apps.Ping6Helper();
89 ping6.SetLocal(i1.GetAddress(0, 1));
90 ping6.SetRemote(i2.GetAddress(1, 1));
92 ping6.SetAttribute(
"MaxPackets", ns.core.UintegerValue(maxPacketCount));
93 ping6.SetAttribute(
"Interval", ns.core.TimeValue(interPacketInterval));
94 ping6.SetAttribute(
"PacketSize", ns.core.UintegerValue(packetSize));
96 apps = ping6.Install(ns.network.NodeContainer(net1.Get(0)));
97 apps.Start(ns.core.Seconds(2.0));
98 apps.Stop(ns.core.Seconds(20.0));
101 ascii = ns.network.AsciiTraceHelper()
102 csma.EnableAsciiAll(ascii.CreateFileStream(
"simple-routing-ping6.tr"))
103 csma.EnablePcapAll(
"simple-routing-ping6",
True)
106 ns.core.Simulator.Run()
107 ns.core.Simulator.Destroy()
109 if __name__ ==
'__main__':