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