Commits

Joshua Bonsink committed 734650e

Minor fixes

  • Participants
  • Parent commits 8e4c360

Comments (0)

Files changed (2)

File core/ns3/experiment/imalse_pure_sim_experiment.py

 from core.ns3.experiment import ImalseExperiment
 from core.ns3.util.netanim import AnimationInterface
 
+import settings
+
 class ImalsePureSimExperiment(ImalseExperiment):
     
     """
         parser.add_option("", "--SimulatorImpl", dest = "SimulatorImplementationType",
                 help="the simulator implementation Type, available options are['Realtime', 'Default', 'Visual']")
 
-        parser.set_defaults(ExportXML='false')
+        parser.set_defaults(ExportXML=None)
         parser.add_option("", "--ExportXML", dest = "ExportXML", 
-                help ="Export XMLS used to animate network in NetAanim.")        
+                help ="Define filename of XML used to animate network in NetAanim.")        
         
         parser.set_defaults(numnodes = 2, simtime = 30)
         parser.add_option("-n", "--numnodes", dest = "numnodes", type = int,
         print "running simulator for %s sec" % self.options.simtime
         
         ns.core.Simulator.Stop(ns.core.Seconds(self.options.simtime)) 
-        anim = AnimationInterface("test.xml")
-        
-        #pointToPoint = ns3.PointToPointHelper()
-        #pointToPoint.EnablePcapAll("test.pcap");
+        if self.options.ExportXML != None:
+            anim = AnimationInterface(settings.ROOT + '/' + self.options.ExportXML)                    
         
         ns.core.Simulator.Run()
-        anim.pcapToXML()
+        
+        if self.options.ExportXML != None:
+            anim.pcapToXML()
         self.cleanup()
         ns.core.Simulator.Destroy()
         

File core/ns3/util/netanim.py

 This file contains a utility class to convert the generated pcap files 
 during a simulation into a usable XML file for NetAnim.
 
+Clear the res folder before starting a simulation when using this option!
+
 """
 
 from operator import itemgetter
            
         for dirEntry in os.listdir(path):
             dirEntryPath = os.path.join(path, dirEntry)
-            if os.path.isfile(dirEntryPath):                
-                fix_pcap(dirEntryPath)
-                time.sleep(5)
+            if os.path.isfile(dirEntryPath):  
+                if 'pcap' in dirEntryPath:
+                    fix_pcap(dirEntryPath)
+                    time.sleep(5)
                 
         for dirEntry in os.listdir(path):
             dirEntryPath = os.path.join(path, dirEntry)
     
     def writeLine(self, line):        
         """Write line at the end of the xml file."""
-        with open(self.fileName, 'r+U') as f:
+        with open(self.fileName, 'w+') as f:
             try:
                 f.seek(-1, 2)
                 while f.read(1) == "\n":