Merge branch 'ONOS-Next' of https://github.com/OPENNETWORKINGLAB/ONLabTest into ONOS-Next
diff --git a/TestON/drivers/common/cli/emulator/mininetclidriver.py b/TestON/drivers/common/cli/emulator/mininetclidriver.py
index 9875064..ad07d95 100644
--- a/TestON/drivers/common/cli/emulator/mininetclidriver.py
+++ b/TestON/drivers/common/cli/emulator/mininetclidriver.py
@@ -115,18 +115,18 @@
             if fanout is None:     #In tree topology, if fanout arg is not given, by default it is 2
                 fanout = 2
             k = 0
-            sum = 0
+            count = 0
             while(k <= depth-1): 
-                sum = sum + pow(fanout,k)
+                count = count + pow(fanout,k)
                 k = k+1
-                num_switches = sum
+                num_switches = count
             while(k <= depth-2): 
                 '''depth-2 gives you only core links and not considering edge links as seen by ONOS
                     If all the links including edge links are required, do depth-1
                 '''
-                sum = sum + pow(fanout,k)
+                count = count + pow(fanout,k)
                 k = k+1
-            num_links = sum * fanout
+            num_links = count * fanout
             #print "num_switches for %s(%d,%d) = %d and links=%d" %(topoType,depth,fanout,num_switches,num_links)
         
         elif topoType =='linear':
@@ -387,7 +387,7 @@
             return information dict about interfaces connected to the node
         '''
         if self.handle :
-            cmd = 'py "\\n".join(["name=%s,mac=%s,ip=%s,isUp=%s" % (i.name, i.MAC(), i.IP(), i.isUp())'
+            cmd = 'py "\\n".join(["name=%s,mac=%s,ip=%s,enabled=%s" % (i.name, i.MAC(), i.IP(), i.isUp())'
             cmd += ' for i in %s.intfs.values()])' % node
             try:
                 response = self.execute(cmd=cmd,prompt="mininet>",timeout=10)
@@ -490,11 +490,11 @@
         '''
         Bring link(s) between two nodes up or down
         '''
-        main.log.info('Bring link(s) between two nodes up or down')
         args = utilities.parse_args(["END1","END2","OPTION"],**linkargs)
         end1 = args["END1"] if args["END1"] != None else ""
         end2 = args["END2"] if args["END2"] != None else ""
         option = args["OPTION"] if args["OPTION"] != None else ""
+        main.log.info("Bring link between '"+ end1 +"' and '" + end2 + "' '" + option + "'")
         command = "link "+str(end1) + " " + str(end2)+ " " + str(option)
         try:
             #response = self.execute(cmd=command,prompt="mininet>",timeout=10)
@@ -716,7 +716,6 @@
             pattern = "flow_count=(\d+)"
             result = re.search(pattern, response, re.MULTILINE)
             if result is None:
-                print "no flow on switch print test"
                 main.log.info("Couldn't find flows on switch '', found: %s" % (switch, response))
                 return main.FALSE
             return result.group(1)
@@ -811,13 +810,10 @@
         #main.log.debug("Switches_json string: ", switches_json)
         output = {"switches":[]}
         for switch in topo.graph.switches: #iterate through the MN topology and pull out switches and and port info
-            #print vars(switch)
             ports = []
             for port in switch.ports.values():
-                #print port.hw_addr.toStr(separator = '')
                 ports.append({'of_port': port.port_no, 'mac': str(port.hw_addr).replace('\'',''), 'name': port.name})
             output['switches'].append({"name": switch.name, "dpid": str(switch.dpid).zfill(16), "ports": ports })
-        #print output
 
         #print "mn"
         #print json.dumps(output, sort_keys=True,indent=4,separators=(',', ': '))
@@ -830,6 +826,7 @@
         for switch in output['switches']:
             mnDPIDs.append(switch['dpid'])
         mnDPIDs.sort()
+        #print "List of Mininet switch DPID's"
         #print mnDPIDs
         if switches_json == "":#if rest call fails
             main.log.error(self.name + ".compare_switches(): Empty JSON object given from ONOS")
@@ -837,9 +834,13 @@
         onos=switches_json
         onosDPIDs=[]
         for switch in onos:
-            onosDPIDs.append(switch['id'].replace(":",'').replace("of",''))
-            #print switch
+            if switch['available'] == True:
+                onosDPIDs.append(switch['id'].replace(":",'').replace("of",''))
+            #else:
+                #print "Switch is unavailable:"
+                #print switch
         onosDPIDs.sort()
+        #print "List of ONOS switch DPID's"
         #print onosDPIDs
 
         if mnDPIDs!=onosDPIDs:
@@ -872,51 +873,68 @@
         port_results = main.TRUE
         output = {"switches":[]}
         for switch in topo.graph.switches: #iterate through the MN topology and pull out switches and and port info
-            #print vars(switch)
             ports = []
             for port in switch.ports.values():
                 #print port.hw_addr.toStr(separator = '')
-                ports.append({'of_port': port.port_no, 'mac': str(port.hw_addr).replace('\'',''), 'name': port.name})
-            output['switches'].append({"name": switch.name, "dpid": str(switch.dpid).zfill(16), "ports": ports })
-        #print "compare_ports 'output' variable:"
-        #print output
+                tmp_port = {}
+                tmp_port['of_port'] = port.port_no
+                tmp_port['mac'] = str(port.hw_addr).replace('\'','')
+                tmp_port['name'] = port.name
+                tmp_port['enabled'] = port.enabled
+
+                ports.append(tmp_port)
+            tmp_switch = {}
+            tmp_switch['name'] = switch.name
+            tmp_switch['dpid'] = str(switch.dpid).zfill(16)
+            tmp_switch['ports'] = ports
+
+            output['switches'].append(tmp_switch)
 
 
         ################ports#############
-        for switch in output['switches']:
+        for mn_switch in output['switches']:
             mn_ports = []
             onos_ports = []
-            for port in switch['ports']:
-                mn_ports.append(port['of_port'])
+            for port in mn_switch['ports']:
+                if port['enabled'] == True:
+                    mn_ports.append(port['of_port'])
             for onos_switch in ports_json:
-                if onos_switch['device'].replace(':','').replace("of", '') == switch['dpid']:
-                    for port in onos_switch['ports']:
-                        onos_ports.append(int(port['port'])) 
+                #print "Iterating through a new switch as seen by ONOS"
+                #print onos_switch
+                if onos_switch['device']['available'] == True:
+                    if onos_switch['device']['id'].replace(':','').replace("of", '') == mn_switch['dpid']:
+                        for port in onos_switch['ports']:
+                            if port['isEnabled']:
+                                #print "Iterating through available ports on the switch"
+                                #print port
+                                onos_ports.append(int(port['port'])) 
             mn_ports.sort(key=float)
             onos_ports.sort(key=float)
             #print "\nPorts for Switch %s:" % (switch['name'])
             #print "\tmn_ports[] = ", mn_ports
             #print "\tonos_ports[] = ", onos_ports
             
-            #if mn_ports == onos_ports:
-                #pass #don't set results to true here as this is just one of many checks and it might override a failure
-
-            #For OF1.3, the OFP_local port number is 0xfffffffe or 4294967294 instead of 0xfffe or 65534 in OF1.0, ONOS topology
-            #sees the correct port number, however MN topology as read from line 151 of https://github.com/ucb-sts/sts/blob/
-            #topology_refactoring2/sts/entities/teston_entities.py is 0xfffe which doesn't work correctly with OF1.3 switches.
-            #So a short term fix is to ignore the case when mn_port == 65534 and onos_port ==4294967294.
+            #NOTE:For OF1.3, the OFP_local port number is 0xfffffffe or 4294967294 instead of 0xfffe or 65534 in OF1.0,
+            #   ONOS topology sees the correct port number, however MN topology as read from line 151 of
+            #   https://github.com/ucb-sts/sts/blob/topology_refactoring2/sts/entities/teston_entities.py 
+            #   is 0xfffe which doesn't work correctly with OF1.3 switches.
             
-            #ONOS-Next is abstracting port numbers to 64bit unsigned number. So we will be converting the OF reserved ports to these numbers
+            #NOTE: ONOS is abstracting port numbers to 64bit unsigned number(long). So we will be converting the 
+            #   OF reserved ports to these numbers
+
+
             #TODO: handle other reserved port numbers besides LOCAL
             for mn_port,onos_port in zip(mn_ports,onos_ports):
-                if mn_port == onos_port or (mn_port == 65534 and onos_port ==int(uint64(-2))):
+                #print "mn == onos port?"
+                #print mn_port, onos_port
+                if mn_port == onos_port or (mn_port == 65534 and onos_port == long(uint64(-2))):
                     continue
                     #don't set results to true here as this is just one of many checks and it might override a failure
                 else:  #the ports of this switch don't match
                     port_results = main.FALSE
                     break
             if port_results == main.FALSE:
-                main.log.report("The list of ports for switch %s(%s) does not match:" % (switch['name'], switch['dpid']) )
+                main.log.report("The list of ports for switch %s(%s) does not match:" % (mn_switch['name'], mn_switch['dpid']) )
                 main.log.report("mn_ports[] = " +  str(mn_ports))
                 main.log.report("onos_ports[] = " + str(onos_ports))
         return port_results
@@ -939,7 +957,8 @@
         output = {"switches":[]}
         onos = links_json
         for switch in topo.graph.switches: #iterate through the MN topology and pull out switches and and port info
-            #print vars(switch)
+            # print "Iterating though switches as seen by Mininet"
+            # print switch
             ports = []
             for port in switch.ports.values():
                 #print port.hw_addr.toStr(separator = '')
@@ -947,19 +966,21 @@
             output['switches'].append({"name": switch.name, "dpid": str(switch.dpid).zfill(16), "ports": ports })
         #######Links########
 
-        if 2*len(topo.patch_panel.network_links) == len(onos):
+        mn_links = [link for link in topo.patch_panel.network_links if (link.port1.enabled and link.port2.enabled)]
+        #print "mn_links:"
+        #print mn_links
+        if 2*len(mn_links) == len(onos):
             link_results = main.TRUE
         else:
             link_results = main.FALSE
-            main.log.report("Mininet has %i bidirectional links and ONOS has %i unidirectional links" % (len(topo.patch_panel.network_links), len(onos) ))
+            main.log.report("Mininet has %i bidirectional links and ONOS has %i unidirectional links" % (len(mn_links), len(onos) ))
 
 
         # iterate through MN links and check if an ONOS link exists in both directions
         # NOTE: Will currently only show mn links as down if they are cut through STS. 
         #       We can either do everything through STS or wait for up_network_links 
         #       and down_network_links to be fully implemented.
-        for link in topo.patch_panel.network_links: 
-            #print "\n"
+        for link in mn_links: 
             #print "Link: %s" % link
             #TODO: Find a more efficient search method
             node1 = None
@@ -1050,6 +1071,26 @@
 
         return host_list 
 
+
+    def update(self):
+        '''
+        updates the port address and status information for each port in mn
+        '''
+        #TODO: Add error checking. currently the mininet command has no output
+        main.log.info("Updateing MN port information")
+        self.handle.sendline("")
+        self.handle.expect("mininet>")
+        
+        self.handle.sendline("update")
+        self.handle.expect("mininet>")
+
+        self.handle.sendline("")
+        self.handle.expect("mininet>")
+
+        return main.TRUE 
+
+        
+
 if __name__ != "__main__":
     import sys
     sys.modules[__name__] = MininetCliDriver()
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 3d2d6c9..159d251 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -1021,6 +1021,25 @@
             main.cleanup()
             main.exit()
 
+    def tshark_pcap(self, interface, dir_file):
+        '''
+        Capture all packet activity and store in specified
+        directory/file
+
+        Required:
+            * interface: interface to capture
+            * dir: directory/filename to store pcap
+        '''
+        self.handle.sendline("")
+        self.handle.expect("\$")
+
+        self.handle.sendline("tshark -i "+str(interface)+
+                " -t e -w "+str(dir_file))
+        self.handle.expect("Capturing on")
+
+        main.log.info("Tshark started capturing files on "+
+                str(interface)+ " and saving to directory: "+
+                str(dir_File))
 
 
     def run_onos_topo_cfg(self):
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index e5ac6c0..01334c9 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -31,10 +31,15 @@
     </BENCH>
 
     <TEST>
+        #'on' or 'off' debug mode.
+        #If on, logging will be more verbose and
+        #tshark pcap will be enabled
+        #pcap file located at /tmp/'capture_name'
+        <debugMode>on</debugMode>
+
         #Number of times to iterate each case
         <numIter>5</numIter>
         <numSwitch>100</numSwitch>         
-        <printPacketInfo>False</printPacketInfo>
     
         <singleSwThreshold>0,1000</singleSwThreshold>
         <portUpThreshold>0,1000</portUpThreshold>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index b46fb76..9dd828e 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -131,6 +131,8 @@
         deviceTimestamp = main.params['JSON']['deviceTimestamp']
         graphTimestamp = main.params['JSON']['graphTimestamp']
 
+        debug_mode = main.params['TEST']['debugMode']
+
         #Threshold for the test
         threshold_str = main.params['TEST']['singleSwThreshold']
         threshold_obj = threshold_str.split(",")
@@ -154,7 +156,12 @@
      
         #Initialize assertion to TRUE
         assertion = main.TRUE
-        
+      
+        local_time = time.strftime('%x %X')
+        if debug_mode == 'on':
+            main.ONOS1.tshark_pcap("eth0",
+                    "/tmp/single_sw_lat_pcap"+local_time) 
+
         main.log.report("Latency of adding one switch")
 
         for i in range(0, int(num_iter)):
@@ -430,17 +437,17 @@
                  len(latency_ofp_to_device_list))
 
         main.log.report("Switch add - End-to-end latency: \n"+\
-                "Min: "+str(latency_end_to_end_min)+"\n"+\
-                "Max: "+str(latency_end_to_end_max)+"\n"+\
-                "Avg: "+str(latency_end_to_end_avg))
+                "Min: "+str(latency_end_to_end_min)+" mx\n"+\
+                "Max: "+str(latency_end_to_end_max)+" ms\n"+\
+                "Avg: "+str(latency_end_to_end_avg)+" ms")
         main.log.report("Switch add - OFP-to-Graph latency: \n"+\
-                "Min: "+str(latency_ofp_to_graph_min)+"\n"+\
-                "Max: "+str(latency_ofp_to_graph_max)+"\n"+\
-                "Avg: "+str(latency_ofp_to_graph_avg))
+                "Min: "+str(latency_ofp_to_graph_min)+" ms \n"+\
+                "Max: "+str(latency_ofp_to_graph_max)+" ms\n"+\
+                "Avg: "+str(latency_ofp_to_graph_avg)+" ms")
         main.log.report("Switch add - t0-to-Device latency: \n"+\
-                "Min: "+str(latency_t0_to_device_min)+"\n"+\
-                "Max: "+str(latency_t0_to_device_max)+"\n"+\
-                "Avg: "+str(latency_t0_to_device_avg))
+                "Min: "+str(latency_t0_to_device_min)+" ms\n"+\
+                "Max: "+str(latency_t0_to_device_max)+" ms\n"+\
+                "Avg: "+str(latency_t0_to_device_avg)+" ms")
 
         utilities.assert_equals(expect=main.TRUE, actual=assertion,
                 onpass="Switch latency test successful",
@@ -476,6 +483,13 @@
         #These are subject to change, hence moved into params
         deviceTimestamp = main.params['JSON']['deviceTimestamp']
         graphTimestamp = main.params['JSON']['graphTimestamp']
+        
+        debug_mode = main.params['TEST']['debugMode']
+
+        local_time = time.strftime('%x %X')
+        if debug_mode == 'on':
+            main.ONOS1.tshark_pcap("eth0",
+                    "/tmp/port_lat_pcap"+local_time) 
 
         #Threshold for this test case
         up_threshold_str = main.params['TEST']['portUpThreshold']
@@ -762,10 +776,10 @@
                 (sum(port_down_graph_to_ofp_list) / 
                  len(port_down_graph_to_ofp_list))
         
-        main.log.report("Port down graph-to-ofp Min: "+
-                str(port_down_graph_to_ofp_min)+" ms  Max: "+
-                str(port_down_graph_to_ofp_max)+" ms  Avg: "+
-                str(port_down_graph_to_ofp_avg))
+        main.log.report("Port down graph-to-ofp \nMin: "+
+                str(port_down_graph_to_ofp_min)+" ms  \nMax: "+
+                str(port_down_graph_to_ofp_max)+" ms  \nAvg: "+
+                str(port_down_graph_to_ofp_avg)+" ms")
         
         port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
         port_down_device_to_ofp_max = max(port_down_device_to_ofp_list)
@@ -773,10 +787,10 @@
                 (sum(port_down_device_to_ofp_list) /\
                  len(port_down_device_to_ofp_list))
         
-        main.log.report("Port down device-to-ofp Min: "+
-                str(port_down_device_to_ofp_min)+" ms  Max: "+
-                str(port_down_device_to_ofp_max)+" ms  Avg: "+
-                str(port_down_device_to_ofp_avg))
+        main.log.report("Port down device-to-ofp \nMin: "+
+                str(port_down_device_to_ofp_min)+" ms  \nMax: "+
+                str(port_down_device_to_ofp_max)+" ms  \nAvg: "+
+                str(port_down_device_to_ofp_avg)+" ms")
         
         port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
         port_up_graph_to_ofp_max = max(port_up_graph_to_ofp_list)
@@ -784,10 +798,10 @@
                 (sum(port_up_graph_to_ofp_list) /\
                  len(port_up_graph_to_ofp_list))
         
-        main.log.report("Port up graph-to-ofp Min: "+
-                str(port_up_graph_to_ofp_min)+" ms  Max: "+
-                str(port_up_graph_to_ofp_max)+" ms  Avg: "+
-                str(port_up_graph_to_ofp_avg))
+        main.log.report("Port up graph-to-ofp \nMin: "+
+                str(port_up_graph_to_ofp_min)+" ms  \nMax: "+
+                str(port_up_graph_to_ofp_max)+" ms  \nAvg: "+
+                str(port_up_graph_to_ofp_avg)+" ms")
           
         port_up_device_to_ofp_min = min(port_up_device_to_ofp_list)
         port_up_device_to_ofp_max = max(port_up_device_to_ofp_list)
@@ -795,10 +809,10 @@
                 (sum(port_up_device_to_ofp_list) /\
                  len(port_up_device_to_ofp_list))
         
-        main.log.report("Port up device-to-ofp Min: "+
-                str(port_up_device_to_ofp_min)+" ms  Max: "+
-                str(port_up_device_to_ofp_max)+" ms  Avg: "+
-                str(port_up_device_to_ofp_avg))
+        main.log.report("Port up device-to-ofp \nMin: "+
+                str(port_up_device_to_ofp_min)+" ms  \nMax: "+
+                str(port_up_device_to_ofp_max)+" ms  \nAvg: "+
+                str(port_up_device_to_ofp_avg)+" ms")
 
         utilities.assert_equals(expect=main.TRUE, actual=assertion,
                 onpass="Port discovery latency calculation successful",
@@ -834,6 +848,13 @@
         deviceTimestamp = main.params['JSON']['deviceTimestamp']
         linkTimestamp = main.params['JSON']['linkTimestamp'] 
         graphTimestamp = main.params['JSON']['graphTimestamp']
+        
+        debug_mode = main.params['TEST']['debugMode']
+
+        local_time = time.strftime('%x %X')
+        if debug_mode == 'on':
+            main.ONOS1.tshark_pcap("eth0",
+                    "/tmp/link_lat_pcap"+local_time) 
 
         #Threshold for this test case
         up_threshold_str = main.params['TEST']['linkUpThreshold']
@@ -1150,24 +1171,25 @@
                     link_up_lat_device1 = 0
                     link_up_lat_device2 = 0
                     link_up_lat_device3 = 0
-        
-            main.log.info("Link up latency ONOS1 iteration "+
+       
+            if debug_mode == 'on':
+                main.log.info("Link up latency ONOS1 iteration "+
                     str(i)+" (end-to-end): "+
                     str(link_up_lat_graph1)+" ms")
-            main.log.info("Link up latency ONOS2 iteration "+
+                main.log.info("Link up latency ONOS2 iteration "+
                     str(i)+" (end-to-end): "+
                     str(link_up_lat_graph2)+" ms")
-            main.log.info("Link up latency ONOS3 iteration "+
+                main.log.info("Link up latency ONOS3 iteration "+
                     str(i)+" (end-to-end): "+
                     str(link_up_lat_graph3)+" ms")
             
-            main.log.info("Link up latency ONOS1 iteration "+
+                main.log.info("Link up latency ONOS1 iteration "+
                     str(i)+" (link-event-to-system-timestamp): "+
                     str(link_up_lat_link1)+" ms")
-            main.log.info("Link up latency ONOS2 iteration "+
+                main.log.info("Link up latency ONOS2 iteration "+
                     str(i)+" (link-event-to-system-timestamp): "+
                     str(link_up_lat_link2)+" ms")
-            main.log.info("Link up latency ONOS3 iteration "+
+                main.log.info("Link up latency ONOS3 iteration "+
                     str(i)+" (link-event-to-system-timestamp): "+
                     str(link_up_lat_link3))
       
@@ -1209,14 +1231,14 @@
         link_up_avg = sum(link_up_graph_to_system_list) / \
                         len(link_up_graph_to_system_list)
 
-        main.log.report("Link down latency - Min: "+
-                str(link_down_min)+"ms  Max: "+
-                str(link_down_max)+"ms  Avg: "+
-                str(link_down_avg)+"ms")
-        main.log.report("Link up latency - Min: "+
-                str(link_up_min)+"ms  Max: "+
-                str(link_up_max)+"ms  Avg: "+
-                str(link_up_avg)+"ms")
+        main.log.report("Link down latency - \nMin: "+
+                str(link_down_min)+" ms  \nMax: "+
+                str(link_down_max)+" ms  \nAvg: "+
+                str(link_down_avg)+" ms")
+        main.log.report("Link up latency - \nMin: "+
+                str(link_up_min)+" ms  \nMax: "+
+                str(link_up_max)+" ms  \nAvg: "+
+                str(link_up_avg)+" ms")
 
         utilities.assert_equals(expect=main.TRUE, actual=assertion,
                 onpass="Link discovery latency calculation successful",
@@ -1259,6 +1281,13 @@
         #These are subject to change, hence moved into params
         deviceTimestamp = main.params['JSON']['deviceTimestamp']
         graphTimestamp = main.params['JSON']['graphTimestamp']
+        
+        debug_mode = main.params['TEST']['debugMode']
+
+        local_time = time.strftime('%x %X')
+        if debug_mode == 'on':
+            main.ONOS1.tshark_pcap("eth0",
+                    "/tmp/100_sw_lat_pcap"+local_time) 
  
         #Threshold for this test case
         sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold']
@@ -1266,8 +1295,6 @@
         sw_disc_threshold_min = int(sw_disc_threshold_obj[0])
         sw_disc_threshold_max = int(sw_disc_threshold_obj[1])
 
-        print_packet_info = main.params['TEST']['printPacketInfo']
-
         tshark_ofp_output = "/tmp/tshark_ofp_"+num_sw+"sw.txt"
         tshark_tcp_output = "/tmp/tshark_tcp_"+num_sw+"sw.txt"
 
@@ -1409,26 +1436,23 @@
                     tshark_ofp_output+" /tmp/") 
             os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
                     tshark_tcp_output+" /tmp/")
-            ofp_file = open(tshark_ofp_output, 'r')
 
-            #The following is for information purpose only.
             #TODO: Automate OFP output analysis
-            main.log.info("Tshark OFP Vendor output: ")
-            for line in ofp_file:
-                tshark_ofp_result_list.append(line)
-                if print_packet_info=='True':
+            #Debug mode - print out packets captured at runtime     
+            if debug_mode == 'on': 
+                ofp_file = open(tshark_ofp_output, 'r')
+                main.log.info("Tshark OFP Vendor output: ")
+                for line in ofp_file:
+                    tshark_ofp_result_list.append(line)
                     main.log.info(line)
+                ofp_file.close()
 
-            ofp_file.close()
-
-            tcp_file = open(tshark_tcp_output, 'r')
-            main.log.info("Tshark TCP 74 output: ")
-            for line in tcp_file:
-                tshark_tcp_result_list.append(line)
-                if print_packet_info=='True': 
+                tcp_file = open(tshark_tcp_output, 'r')
+                main.log.info("Tshark TCP 74 output: ")
+                for line in tcp_file:
+                    tshark_tcp_result_list.append(line)
                     main.log.info(line)
-
-            tcp_file.close()
+                tcp_file.close()
 
             json_obj_1 = json.loads(json_str_topology_metrics_1)
             json_obj_2 = json.loads(json_str_topology_metrics_2)