25ns.core.LogComponentEnable(
"UdpEchoClientApplication", ns.core.LOG_LEVEL_INFO)
26ns.core.LogComponentEnable(
"UdpEchoServerApplication", ns.core.LOG_LEVEL_INFO)
28nodes = ns.network.NodeContainer()
31pointToPoint = ns.point_to_point.PointToPointHelper()
32pointToPoint.SetDeviceAttribute(
"DataRate", ns.core.StringValue(
"5Mbps"))
33pointToPoint.SetChannelAttribute(
"Delay", ns.core.StringValue(
"2ms"))
35devices = pointToPoint.Install(nodes)
37stack = ns.internet.InternetStackHelper()
40address = ns.internet.Ipv4AddressHelper()
41address.SetBase(ns.network.Ipv4Address(
"10.1.1.0"),
42 ns.network.Ipv4Mask(
"255.255.255.0"))
44interfaces = address.Assign(devices)
46echoServer = ns.applications.UdpEchoServerHelper(9)
48serverApps = echoServer.Install(nodes.Get(1))
49serverApps.Start(ns.core.Seconds(1.0))
50serverApps.Stop(ns.core.Seconds(10.0))
52address = interfaces.GetAddress(1).ConvertTo()
53echoClient = ns.applications.UdpEchoClientHelper(address, 9)
54echoClient.SetAttribute(
"MaxPackets", ns.core.UintegerValue(1))
55echoClient.SetAttribute(
"Interval", ns.core.TimeValue(ns.core.Seconds(1.0)))
56echoClient.SetAttribute(
"PacketSize", ns.core.UintegerValue(1024))
58clientApps = echoClient.Install(nodes.Get(0))
59clientApps.Start(ns.core.Seconds(2.0))
60clientApps.Stop(ns.core.Seconds(10.0))
62ns.core.Simulator.Run()
63ns.core.Simulator.Destroy()