Make Python examples use new modular bindings without importing everything
This commit is contained in:
@@ -13,47 +13,47 @@
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
# */
|
||||
|
||||
from ns.applications import *
|
||||
from ns.core import *
|
||||
from ns.internet import *
|
||||
from ns.network import *
|
||||
from ns.point_to_point import *
|
||||
import ns.applications
|
||||
import ns.core
|
||||
import ns.internet
|
||||
import ns.network
|
||||
import ns.point_to_point
|
||||
|
||||
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO)
|
||||
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO)
|
||||
ns.core.LogComponentEnable("UdpEchoClientApplication", ns.core.LOG_LEVEL_INFO)
|
||||
ns.core.LogComponentEnable("UdpEchoServerApplication", ns.core.LOG_LEVEL_INFO)
|
||||
|
||||
nodes = NodeContainer()
|
||||
nodes = ns.network.NodeContainer()
|
||||
nodes.Create(2)
|
||||
|
||||
pointToPoint = PointToPointHelper()
|
||||
pointToPoint.SetDeviceAttribute("DataRate", StringValue("5Mbps"))
|
||||
pointToPoint.SetChannelAttribute("Delay", StringValue("2ms"))
|
||||
pointToPoint = ns.point_to_point.PointToPointHelper()
|
||||
pointToPoint.SetDeviceAttribute("DataRate", ns.core.StringValue("5Mbps"))
|
||||
pointToPoint.SetChannelAttribute("Delay", ns.core.StringValue("2ms"))
|
||||
|
||||
devices = pointToPoint.Install(nodes)
|
||||
|
||||
stack = InternetStackHelper()
|
||||
stack = ns.internet.InternetStackHelper()
|
||||
stack.Install(nodes)
|
||||
|
||||
address = Ipv4AddressHelper()
|
||||
address.SetBase(Ipv4Address("10.1.1.0"), Ipv4Mask("255.255.255.0"))
|
||||
address = ns.internet.Ipv4AddressHelper()
|
||||
address.SetBase(ns.network.Ipv4Address("10.1.1.0"), ns.network.Ipv4Mask("255.255.255.0"))
|
||||
|
||||
interfaces = address.Assign (devices);
|
||||
|
||||
echoServer = UdpEchoServerHelper(9)
|
||||
echoServer = ns.applications.UdpEchoServerHelper(9)
|
||||
|
||||
serverApps = echoServer.Install(nodes.Get(1))
|
||||
serverApps.Start(Seconds(1.0))
|
||||
serverApps.Stop(Seconds(10.0))
|
||||
serverApps.Start(ns.core.Seconds(1.0))
|
||||
serverApps.Stop(ns.core.Seconds(10.0))
|
||||
|
||||
echoClient = UdpEchoClientHelper(interfaces.GetAddress(1), 9)
|
||||
echoClient.SetAttribute("MaxPackets", UintegerValue(1))
|
||||
echoClient.SetAttribute("Interval", TimeValue(Seconds (1.0)))
|
||||
echoClient.SetAttribute("PacketSize", UintegerValue(1024))
|
||||
echoClient = ns.applications.UdpEchoClientHelper(interfaces.GetAddress(1), 9)
|
||||
echoClient.SetAttribute("MaxPackets", ns.core.UintegerValue(1))
|
||||
echoClient.SetAttribute("Interval", ns.core.TimeValue(ns.core.Seconds (1.0)))
|
||||
echoClient.SetAttribute("PacketSize", ns.core.UintegerValue(1024))
|
||||
|
||||
clientApps = echoClient.Install(nodes.Get(0))
|
||||
clientApps.Start(Seconds(2.0))
|
||||
clientApps.Stop(Seconds(10.0))
|
||||
clientApps.Start(ns.core.Seconds(2.0))
|
||||
clientApps.Stop(ns.core.Seconds(10.0))
|
||||
|
||||
Simulator.Run()
|
||||
Simulator.Destroy()
|
||||
ns.core.Simulator.Run()
|
||||
ns.core.Simulator.Destroy()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user