示例#1
0
文件: obj.py 项目: 22beer1bif/core
 def runthread():
     ns.core.Simulator.Stop(ns.core.Seconds(self.duration))
     print "running ns-3 simulation for %d seconds" % self.duration
     if vis:
         try:
             import visualizer
         except ImportError:
             print "visualizer is not available"
             ns.core.Simulator.Run()
         else:
             visualizer.start()
     else:
         ns.core.Simulator.Run()
示例#2
0
 def runthread():
     ns.core.Simulator.Stop(ns.core.Seconds(self.duration))
     logger.info("running ns-3 simulation for %d seconds", self.duration)
     if vis:
         try:
             import visualizer
         except ImportError:
             logger.exception("visualizer is not available")
             ns.core.Simulator.Run()
         else:
             visualizer.start()
     else:
         ns.core.Simulator.Run()
示例#3
0
文件: obj.py 项目: gsomlo/core
 def runthread():
     ns.core.Simulator.Stop(ns.core.Seconds(self.duration))
     logger.info("running ns-3 simulation for %d seconds", self.duration)
     if vis:
         try:
             import visualizer
         except ImportError:
             logger.exception("visualizer is not available")
             ns.core.Simulator.Run()
         else:
             visualizer.start()
     else:
         ns.core.Simulator.Run()
 def runthread():
     ns.core.Simulator.Stop(ns.core.Seconds(self.duration))
     print "running ns-3 simulation for %d seconds" % self.duration
     if vis:
         try:
             import visualizer
         except ImportError:
             print "visualizer is not available"
             ns.core.Simulator.Run()
         else:
             visualizer.start()
     else:
         ns.core.Simulator.Run()
示例#5
0
# cs = forwarder.getCs()
# print "Contents of CS (%d):" % cs.size()
# for i in cs:
#     print " - %s" % i.getName()
# ----------------------------------------

Simulator.Stop(Seconds(args.simulationSpan))
#print dir(L2RateTracer)

# ----------------结果记录----------------
filename = "-" + args.routingName.lower() + "-" + str(
    args.InterestsPerSec) + ".txt"
#filename=".txt"
TraceSpan = args.simulationSpan / args.recordsNumber
if (TraceSpan < 1):
    TraceSpan = 1
#ndn.CsTracer.InstallAll("Results/cs-trace"+filename, Seconds(TraceSpan))
ndn.L3RateTracer.InstallAll("Results/rate-trace" + filename,
                            Seconds(TraceSpan))
#ndn.AppDelayTracer.InstallAll("Results/app-delays-trace"+filename)
#L2RateTracer.InstallAll("Results/drop-trace"+filename,Seconds(TraceSpan))
if args.vis:
    visualizer.start()
Simulator.Run()

Simulator.Destroy()

# ----------------结果处理----------------
import subprocess
示例#6
0
        print(theta_options)
        theta_index = int(input())
        printf("choose theta_dot_index:")
        print(theta_dot_options)
        theta_dot_index = int(input())
        do_run = True
        model.reset()
        model.lean_angle = theta_options[theta_index]
        model.lean_angle_dot = theta_dot_options[theta_dot_index]
        run_time = 0

    if(run_time > 50):
        do_run = False

    if(abs(model.lean_angle) > 3*consts.theta_max):
        do_run = False
        return

    action = interpolateAction([model.lean_angle, model.lean_angle_dot], theta_options, theta_dot_options, Q)
    print( "\n", "angle : ", model.lean_angle, "\t", "angle_dot : ", model.lean_angle_dot, "\t", "action : ", action)
    #simulate the bicycle for the next dT time, and visualize it.
    model = simulator(model, action, consts.dT, visualizer.SimWorld)

    run_time += consts.dT


train()

do_run = False
visualizer.start(run)
示例#7
0
producer = grid.GetNode(2, 2)
consumerNodes = NodeContainer()
consumerNodes.Add (grid.GetNode(0,0))


cHelper = ndn.AppHelper("ns3::ndn::ConsumerCbr")
cHelper .SetPrefix("/prefix")
cHelper .SetAttribute("Frequency", StringValue ("10"))
cHelper .Install(consumerNodes)

pHelper = ndn.AppHelper("ns3::ndn::Producer")
pHelper.SetPrefix("/prefix")
pHelper.SetAttribute("PayloadSize", StringValue("1024"));
pHelper.Install(producer)

ndnGlobalRoutingHelper = ndn.GlobalRoutingHelper()
ndnGlobalRoutingHelper.InstallAll()

# Add /prefix origins to ndn::GlobalRouter
ndnGlobalRoutingHelper.AddOrigin("/prefix", producer)

# Calculate and install FIBs
ndnGlobalRoutingHelper.CalculateRoutes()

# Simulator.Stop (Seconds (20.0))
# Simulator.Run ()
# Simulator.Destroy ()

import visualizer
visualizer.start()