Make the visualizer a command-line option
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Thu Apr 30 14:13:07 2009 +0100 (9 months ago)
changeset 3938b51d8ebd4724
parent 3937 b200bb6b89e6
child 3939 a71522dddea9
Make the visualizer a command-line option
examples/flowmon.py
     1.1 --- a/examples/flowmon.py	Wed Nov 26 12:11:11 2008 +0000
     1.2 +++ b/examples/flowmon.py	Thu Apr 30 14:13:07 2009 +0100
     1.3 @@ -18,13 +18,19 @@
     1.4  
     1.5  import sys
     1.6  import ns3
     1.7 -import visualizer
     1.8  
     1.9  DISTANCE = 150 # (m)
    1.10  NUM_NODES_SIDE = 3
    1.11  
    1.12  def main(argv):
    1.13  
    1.14 +    cmd = ns3.CommandLine()
    1.15 +
    1.16 +    cmd.Viz = None
    1.17 +    cmd.AddValue("Viz", "Enable visualizer")
    1.18 +
    1.19 +    cmd.Parse(argv)
    1.20 +
    1.21      ns3.RandomVariable.UseGlobalSeed(1, 1, 2, 3, 5, 8)
    1.22  
    1.23      #ns3.Config.SetDefault("ns3::Ipv4L3Protocol::CalcChecksum", ns3.BooleanValue(True))
    1.24 @@ -83,10 +89,10 @@
    1.25      #internet.EnablePcapAll("wifi-olsr")
    1.26      flowmon_helper = ns3.FlowMonitorHelper()
    1.27      monitor = flowmon_helper.InstallAll()
    1.28 -    classifier = flowmon_helper.GetClassifier()
    1.29  
    1.30      ns3.Simulator.Stop(ns3.Seconds(44.0))
    1.31 -    if 0:
    1.32 +    if cmd.Viz is not None:
    1.33 +        import visualizer
    1.34          visualizer.start()
    1.35      else:
    1.36          ns3.Simulator.Run()
    1.37 @@ -102,6 +108,7 @@
    1.38              print >> os, "  Mean{Hop Count}: ", float(st.timesForwarded) / st.rxPackets + 1
    1.39  
    1.40      monitor.CheckForLostPackets()
    1.41 +    classifier = flowmon_helper.GetClassifier()
    1.42      for flow_id, flow_stats in monitor.GetFlowStats():
    1.43          t = classifier.FindFlow(flow_id)
    1.44          proto = {6: 'TCP', 17: 'UDP'} [t.protocol]