Merge pull request #20 from OPENNETWORKINGLAB/driver-update

Driver update for point-to-point intent with bandwidth and labmda alloca...
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 2404a0d..8d31cac 100644
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -950,7 +950,7 @@
 
     def add_point_intent(self, ingress_device, port_ingress,
             egress_device, port_egress, ethType="", ethSrc="",
-            ethDst=""):
+            ethDst="", bandwidth="", lambda_alloc=""):
         '''
         Required:
             * ingress_device: device id of ingress device
@@ -959,6 +959,8 @@
             * ethType: specify ethType
             * ethSrc: specify ethSrc (i.e. src mac addr)
             * ethDst: specify ethDst (i.e. dst mac addr)
+            * bandwidth: specify bandwidth capacity of link
+            * lambda_alloc: spcify lambda allocation
         Description:
             Adds a point-to-point intent (uni-directional) by
             specifying device id's and optional fields
@@ -971,7 +973,8 @@
             cmd = ""
 
             #If there are no optional arguments
-            if not ethType and not ethSrc and not ethDst:
+            if not ethType and not ethSrc and not ethDst\
+                    and not bandwidth and not lambda:
                 cmd = "add-point-intent "+\
                         str(ingress_device) + "/" + str(port_ingress) + " " +\
                         str(egress_device) + "/" + str(port_egress)
@@ -985,13 +988,14 @@
                     cmd += " --ethSrc " + str(ethSrc) 
                 if ethDst:    
                     cmd += " --ethDst " + str(ethDst) 
-                        
-                cmd += " "+str(ingress_device) + "/" + str(port_ingress) + " " +\
-                str(egress_device) + "/" + str(port_egress) 
+                if bandwidth:
+                    cmd += " --bandwidth " + str(bandwidth)
+                if lambda_alloc:
+                    cmd += " --lambda " + str(lambda_alloc)
 
-            #print "cmd = ", cmd
-            #self.handle.sendline("")
-            #self.handle.expect("onos>")
+                cmd += " "+str(ingress_device) +\
+                    "/" + str(port_ingress) + " " +\
+                    str(egress_device) + "/" + str(port_egress) 
 
             self.handle.sendline(cmd)
             i = self.handle.expect([
@@ -1001,12 +1005,6 @@
             self.handle.sendline("intents")
             self.handle.expect("onos>")
             Intenthandle = self.handle.before
-            #print "Intenthandle = ", Intenthandle
-
-            #self.handle.sendline("flows")
-            #self.handle.expect("onos>")
-            #Flowhandle = self.handle.before
-            #print "Flowhandle = ", Flowhandle
 
             if i == 0:
                 main.log.error("Error in adding point-to-point intent")
@@ -1072,7 +1070,9 @@
                 self.handle.expect("intents -j")
                 self.handle.expect("onos>")
                 handle = self.handle.before
-
+                
+                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+                handle = ansi_escape.sub('', handle)
             else:
                 self.handle.sendline("")
                 self.handle.expect("onos>")
@@ -1130,7 +1130,44 @@
             main.cleanup()
             main.exit()
 
+    def intents_events_metrics(self, json_format=True):
+        '''
+        Description:Returns topology metrics 
+        Optional:
+            * json_format: enable json formatting of output
+        '''
+        try:
+            if json_format:
+                self.handle.sendline("intents-events-metrics -j")
+                self.handle.expect("intents-events-metrics -j")
+                self.handle.expect("onos>")
+                
+                handle = self.handle.before
+              
+                #Some color thing that we want to escape
+                ansi_escape = re.compile(r'\r\r\n\x1b[^m]*m')
+                handle = ansi_escape.sub('', handle)
+            
+            else:
+                self.handle.sendline("intents-events-metrics")
+                self.handle.expect("intents-events-metrics")
+                self.handle.expect("onos>")
+                
+                handle = self.handle.before
 
+            return handle
+        
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":    " + self.handle.before)
+            main.cleanup()
+            main.exit()
+        except:
+            main.log.info(self.name+" ::::::")
+            main.log.error( traceback.print_exc())
+            main.log.info(self.name+" ::::::")
+            main.cleanup()
+            main.exit()
 
     def topology_events_metrics(self, json_format=True):
         '''
diff --git a/TestON/drivers/common/cli/onosdriver.py b/TestON/drivers/common/cli/onosdriver.py
index 4bf6978..f4e1714 100644
--- a/TestON/drivers/common/cli/onosdriver.py
+++ b/TestON/drivers/common/cli/onosdriver.py
@@ -120,6 +120,36 @@
             main.cleanup()
             main.exit()
 
+    def onos_build(self):
+        '''
+        Use the pre defined script to build onos via mvn
+        '''
+        
+        try:
+            self.handle.sendline("onos-build")
+            self.handle.expect("onos-build")
+            i = self.handle.expect([
+                "BUILD SUCCESS",
+                "ERROR",
+                "BUILD FAILED"], timeout=120)
+            handle = str(self.handle.before)
+
+            main.log.info("onos-build command returned: "+
+                    handle)
+
+            if i == 0:
+                return main.TRUE
+            else:
+                return handle
+
+        except pexpect.EOF:
+            main.log.error(self.name + ": EOF exception found")
+            main.log.error(self.name + ":    " + self.handle.before)
+        except:
+            main.log.error("Failed to build ONOS")
+            main.cleanup()
+            main.exit()
+
     def clean_install(self):
         '''
         Runs mvn clean install in the root of the ONOS directory. 
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.params b/TestON/tests/IntentPerfNext/IntentPerfNext.params
index 15945e1..7e1de77 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.params
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1,3</testcases>
+    <testcases>1,2</testcases>
 
     <ENV>
         <cellName>intent_perf_test</cellName>
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.py b/TestON/tests/IntentPerfNext/IntentPerfNext.py
index a2d8674..2fb22dc 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.py
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.py
@@ -1,6 +1,8 @@
 #Intent Performance Test for ONOS-next
 #
 #andrew@onlab.us
+#
+#November 5, 2014
 
 class IntentPerfNext:
     def __init__(self):
@@ -111,25 +113,106 @@
         wdRequest_time = main.params['JSON']['wdRequestTime']
         withdrawn_time = main.params['JSON']['withdrawnTime']
 
-        devices_json_str = main.ONOScli.devices()
+        devices_json_str = main.ONOS1cli.devices()
         devices_json_obj = json.loads(devices_json_str)
 
         device_id_list = []
 
+        #Obtain device id list in ONOS format.
+        #They should already be in order (1,2,3,10,11,12,13, etc)
         for device in devices_json_obj:
             device_id_list.append(device['id'])
 
-        #TODO: Add point intent 
-        #add_point_intent(ingr_device, ingr_port, 
-        #                 egr_device, egr_port)
+        intent_add_lat_list = []
 
-        #TODO: Obtain metrics 
+        for i in range(0, int(num_iter)):
+            #add_point_intent(ingr_device, ingr_port, 
+            #                 egr_device, egr_port)
+            main.ONOS1cli.add_point_intent(
+                device_id_list[0], 2,
+                device_id_list[2], 1)
+        
+            #Allow some time for intents to propagate
+            time.sleep(5)
 
-        #TODO: Calculate average, append to latency list
-        #TODO: Iterate through iterations specified
-        #TODO: Report min, max average of latency list
+            #Obtain metrics from ONOS 1, 2, 3
+            intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
+            intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
+            intents_json_str_3 = main.ONOS3cli.intents_events_metrics()
+
+            intents_json_obj_1 = json.loads(intents_json_str_1)
+            intents_json_obj_2 = json.loads(intents_json_str_2)
+            intents_json_obj_3 = json.loads(intents_json_str_3)
+
+            #Parse values from the json object
+            intent_submit_1 = \
+                    intents_json_obj_1[submit_time]['value']
+            intent_submit_2 = \
+                    intents_json_obj_2[submit_time]['value']
+            intent_submit_3 = \
+                    intents_json_obj_3[submit_time]['value']
+
+            intent_install_1 = \
+                    intents_json_obj_1[install_time]['value']
+            intent_install_2 = \
+                    intents_json_obj_2[install_time]['value']
+            intent_install_3 = \
+                    intents_json_obj_3[install_time]['value']
+
+            intent_install_lat_1 = \
+                    int(intent_install_1) - int(intent_submit_1)
+            intent_install_lat_2 = \
+                    int(intent_install_2) - int(intent_submit_2)
+            intent_install_lat_3 = \
+                    int(intent_install_3) - int(intent_submit_3)
+            
+            intent_install_lat_avg = \
+                    (intent_install_lat_1 + 
+                     intent_install_lat_2 +
+                     intent_install_lat_3 ) / 3
+
+            main.log.info("Intent add latency avg for iteration "+str(i)+
+                    ": "+str(intent_install_lat_avg))
+
+            if intent_install_lat_avg > 0.0 and \
+               intent_install_lat_avg < 1000:
+                intent_add_lat_list.append(intent_install_lat_avg)
+            else:
+                main.log.info("Intent add latency exceeded "+
+                        "threshold. Skipping iteration "+str(i))
+
+            time.sleep(3)
+            
+            #TODO: Possibly put this in the driver function
+            main.log.info("Removing intents for next iteration")
+            json_temp = \
+                    main.ONOS1cli.intents(json_format=True)
+            json_obj_intents = json.loads(json_temp)
+            if json_obj_intents:
+                for intents in json_obj_intents:
+                    temp_id = intents['id']
+                    main.ONOS1cli.remove_intent(temp_id)
+                    main.log.info("Removing intent id: "+
+                        str(temp_id))
+                    main.ONOS1cli.remove_intent(temp_id)
+            else:
+                main.log.info("Intents were not installed correctly")
+
+            time.sleep(5)
+
+        intent_add_lat_min = min(intent_add_lat_list)
+        intent_add_lat_max = max(intent_add_lat_list)
+        intent_add_lat_avg = sum(intent_add_lat_list) /\
+                             len(intent_add_lat_list)
+        #END ITERATION FOR LOOP
+        main.log.report("Single intent add latency - \n"+
+                "Min: "+str(intent_add_lat_min)+" ms\n"+
+                "Max: "+str(intent_add_lat_max)+" ms\n"+
+                "Avg: "+str(intent_add_lat_avg)+" ms\n")
 
 
-
-
+    def CASE3(self, main):
+        '''
+        CASE3 coming soon
+        '''
 
diff --git a/TestON/tests/IntentPerfNext/IntentPerfNext.topo b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
index 37ca2f9..fbde0e1 100644
--- a/TestON/tests/IntentPerfNext/IntentPerfNext.topo
+++ b/TestON/tests/IntentPerfNext/IntentPerfNext.topo
@@ -53,10 +53,10 @@
             <type>MininetCliDriver</type>
             <connect_order>4</connect_order>
             <COMPONENTS>
-                <arg1> --custom topo-perf-2sw.py </arg1>
+                <arg1> --custom topo-intentFlower.py </arg1>
                 <arg2> --arp --mac --topo mytopo</arg2>
                 <arg3> </arg3>
-                <controller> remote </controller>
+                <controller> remote,ip=10.128.174.1 </controller>
             </COMPONENTS>
         </Mininet1>
 
diff --git a/TestON/tests/MininetSlicing/MininetSlicing.py b/TestON/tests/MininetSlicing/MininetSlicing.py
index ac723fb..86b3ddc 100644
--- a/TestON/tests/MininetSlicing/MininetSlicing.py
+++ b/TestON/tests/MininetSlicing/MininetSlicing.py
@@ -1,17 +1,4 @@
-'''
-	
- *   TestON is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 2 of the License, or
- *   (at your option) any later version.
 
- *   TestON is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
-
-
-'''
 class MininetSlicing :
 
     def __init__(self) :
@@ -81,5 +68,4 @@
     
     
     
-    
-    
+    
\ No newline at end of file
diff --git a/TestON/tests/ONOSNextTest/ONOSNextTest.params b/TestON/tests/ONOSNextTest/ONOSNextTest.params
index 019b746..d600eae 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.params
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.params
@@ -8,7 +8,7 @@
     </ENV>
 
     <CTRL>
-        <ip1>10.128.20.11</ip1>
+        <ip1>10.128.174.1</ip1>
         <port1>6633</port1>
     </CTRL>
 
diff --git a/TestON/tests/ONOSNextTest/ONOSNextTest.py b/TestON/tests/ONOSNextTest/ONOSNextTest.py
index de441ba..3496771 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.py
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.py
@@ -30,7 +30,7 @@
         ONOS1_port = main.params['CTRL']['port1']
         
         git_pull_trigger = main.params['GIT']['autoPull']
-        git_checkout_branch = main.params['GIT']['branch']
+        git_checkout_branch = main.params['GIT']['checkout']
 
         main.case("Setting up test environment")
         
@@ -39,7 +39,7 @@
         cell_file_result = main.ONOSbench.create_cell_file(
                 "10.128.20.10", "temp_cell_2", "10.128.10.90",
                 "onos-core-trivial,onos-app-fwd",
-                "10.128.20.11")
+                "10.128.174.1")
 
         main.step("Applying cell variable to environment")
         #cell_result = main.ONOSbench.set_cell(cell_name)
@@ -180,7 +180,8 @@
         main.case("Testing the ONOS-cli")
         
         main.step("Set cell for ONOS-cli environment")
-        main.ONOScli.set_cell(cell_name)
+        #main.ONOScli.set_cell(cell_name)
+        main.ONOScli.set_cell("temp_cell_2")
 
         main.step("Start ONOS-cli")
         main.ONOScli.start_onos_cli(ONOS1_ip)
@@ -198,12 +199,12 @@
             main.log.info("Node successfully added")
 
         main.step("Add a correct node")
-        node_result = main.ONOScli.add_node("111", "10.128.20.12")
+        node_result = main.ONOScli.add_node("111", "10.128.174.2")
 
         main.step("Assign switches and list devices")
         for i in range(1,8):
             main.Mininet2.handle.sendline("sh ovs-vsctl set-controller s"+str(i)+
-                    " tcp:10.128.20.11")
+                    " tcp:10.128.174.1")
             main.Mininet2.handle.expect("mininet>")
         #Need to sleep to allow switch add processing
         time.sleep(5)
@@ -315,6 +316,19 @@
             main.log.info(get_intent_result)
         #*******************************************
 
+        main.step("Print intents in json format")
+        intents = main.ONOScli.intents(json_format = True)
+        main.log.info(intents)
+
+        main.step("Add eth options in point-to-point intent")
+        ptp_eth = main.ONOScli.add_point_intent(
+                devices_id_list[2], 1, devices_id_list[3], 2,
+                ethSrc = "00:02", ethDst = "00:03")
+        main.log.info(ptp_eth)
+
+        main.step("Print intents with eth options")
+        intents = main.ONOScli.intents()
+        main.log.info(intents)
 ######
 #jhall@onlab.us
 #andrew@onlab.us
diff --git a/TestON/tests/ONOSNextTest/ONOSNextTest.topo b/TestON/tests/ONOSNextTest/ONOSNextTest.topo
index 118e57c..0c84cc7 100755
--- a/TestON/tests/ONOSNextTest/ONOSNextTest.topo
+++ b/TestON/tests/ONOSNextTest/ONOSNextTest.topo
@@ -20,7 +20,7 @@
         </ONOScli>
 
         <ONOS1>
-            <host>10.128.20.11</host>
+            <host>10.128.174.1</host>
             <user>sdn</user>
             <password>rocks</password>
             <type>OnosDriver</type>
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.params b/TestON/tests/TopoPerfNext/TopoPerfNext.params
index 39ddc7b..82d492c 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.params
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.params
@@ -1,5 +1,5 @@
 <PARAMS>
-    <testcases>1,4</testcases>
+    <testcases>1,2,3,4</testcases>
 
     <ENV>
         <cellName>topo_perf_test</cellName>
@@ -32,7 +32,7 @@
 
     <TEST>
         #Number of times to iterate each case
-        <numIter>2</numIter>
+        <numIter>10</numIter>
         <numSwitch>100</numSwitch>         
     </TEST>
 
diff --git a/TestON/tests/TopoPerfNext/TopoPerfNext.py b/TestON/tests/TopoPerfNext/TopoPerfNext.py
index adc3b96..1e4b4c0 100644
--- a/TestON/tests/TopoPerfNext/TopoPerfNext.py
+++ b/TestON/tests/TopoPerfNext/TopoPerfNext.py
@@ -326,14 +326,11 @@
             
             #NOTE: ofp - delta measurements are occasionally negative
             #      due to system time misalignment.
-            #TODO: Implement ptp across all clusters
-            #Just add the calculation to list for now
             latency_ofp_to_device_list.append(avg_delta_ofp_device)
 
             #TODO:
             #Fetch logs upon threshold excess
 
-            
             main.log.info("ONOS1 delta end-to-end: "+
                     str(delta_graph_1) + " ms")
             main.log.info("ONOS2 delta end-to-end: "+
@@ -355,12 +352,12 @@
             main.log.info("ONOS3 delta device - t0: "+
                     str(delta_device_3) + " ms")
           
-            main.log.info("ONOS1 delta OFP - device: "+
-                    str(delta_ofp_device_1) + " ms")
-            main.log.info("ONOS2 delta OFP - device: "+
-                    str(delta_ofp_device_2) + " ms")
-            main.log.info("ONOS3 delta OFP - device: "+
-                    str(delta_ofp_device_3) + " ms")
+            #main.log.info("ONOS1 delta OFP - device: "+
+            #        str(delta_ofp_device_1) + " ms")
+            #main.log.info("ONOS2 delta OFP - device: "+
+            #        str(delta_ofp_device_2) + " ms")
+            #main.log.info("ONOS3 delta OFP - device: "+
+            #        str(delta_ofp_device_3) + " ms")
 
             main.step("Remove switch from controller")
             main.Mininet1.delete_sw_controller("s1")
@@ -433,10 +430,6 @@
                 "Min: "+str(latency_ofp_to_graph_min)+"\n"+\
                 "Max: "+str(latency_ofp_to_graph_max)+"\n"+\
                 "Avg: "+str(latency_ofp_to_graph_avg))
-        main.log.report("Switch add - OFP-to-Device latency: \n"+\
-                "Min: "+str(latency_ofp_to_device_min)+"\n"+\
-                "Max: "+str(latency_ofp_to_device_max)+"\n"+\
-                "Avg: "+str(latency_ofp_to_device_avg))
         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"+\
@@ -467,7 +460,8 @@
         ONOS_user = main.params['CTRL']['user']
 
         default_sw_port = main.params['CTRL']['port1']
-       
+      
+        assertion = main.TRUE
         #Number of iterations of case
         num_iter = main.params['TEST']['numIter']
        
@@ -493,6 +487,11 @@
         main.Mininet1.assign_sw_controller(sw="2",ip1=ONOS1_ip,
                 port1=default_sw_port)
 
+        #Give enough time for metrics to propagate the 
+        #assign controller event. Otherwise, these events may
+        #carry over to our measurements
+        time.sleep(10)
+
         main.step("Verify switch is assigned correctly")
         result_s1 = main.Mininet1.get_sw_controller(sw="s1")
         result_s2 = main.Mininet1.get_sw_controller(sw="s2")
@@ -519,7 +518,7 @@
             main.Mininet2.handle.sendline("sudo ifconfig "+
                     interface_config+" down")
             main.Mininet2.handle.expect("\$")
-            time.sleep(20)
+            time.sleep(10)
 
             main.ONOS1.tshark_stop()
             time.sleep(5)
@@ -597,11 +596,11 @@
             pt_down_graph_to_ofp_avg =\
                     (int(pt_down_graph_to_ofp_1) +
                      int(pt_down_graph_to_ofp_2) + 
-                     int(pt_down_graph_to_ofp_3)) / 3
+                     int(pt_down_graph_to_ofp_3)) / 3.0
             pt_down_device_to_ofp_avg = \
                     (int(pt_down_device_to_ofp_1) + 
                      int(pt_down_device_to_ofp_2) +
-                     int(pt_down_device_to_ofp_3)) / 3
+                     int(pt_down_device_to_ofp_3)) / 3.0
 
             if pt_down_graph_to_ofp_avg > 0.0 and \
                     pt_down_graph_to_ofp_avg < 1000:
@@ -629,12 +628,14 @@
             main.step("Enable port and obtain timestamp")
             main.step("Starting wireshark capture for port status up")
             main.ONOS1.tshark_grep("OFP 130 Port Status", tshark_port_up)
-            time.sleep(10)
+            time.sleep(5)
 
             main.Mininet2.handle.sendline("sudo ifconfig "+
                     interface_config+" up")
             main.Mininet2.handle.expect("\$")
-            time.sleep(20)
+            time.sleep(10)
+            
+            main.ONOS1.tshark_stop()
 
             os.system("scp "+ONOS_user+"@"+ONOS1_ip+":"+
                     tshark_port_up+" /tmp/")
@@ -729,7 +730,12 @@
                         str(pt_up_device_to_ofp_avg))
             
             #END ITERATION FOR LOOP
-       
+        
+        #Check all list for latency existence and set assertion
+        if (port_down_graph_to_ofp_list and port_down_device_to_ofp_list\
+           and port_up_graph_to_ofp_list and port_up_device_to_ofp_list):
+            assertion = main.TRUE
+
         #Calculate and report latency measurements
         port_down_graph_to_ofp_min = min(port_down_graph_to_ofp_list)
         port_down_graph_to_ofp_max = max(port_down_graph_to_ofp_list)
@@ -738,10 +744,8 @@
                  len(port_down_graph_to_ofp_list))
         
         main.log.report("Port down graph-to-ofp Min: "+
-                str(port_down_graph_to_ofp_min))
-        main.log.report("Port down graph-to-ofp Max: "+
-                str(port_down_graph_to_ofp_max))
-        main.log.report("Port down graph-to-ofp Avg: "+
+                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))
         
         port_down_device_to_ofp_min = min(port_down_device_to_ofp_list)
@@ -751,10 +755,8 @@
                  len(port_down_device_to_ofp_list))
         
         main.log.report("Port down device-to-ofp Min: "+
-                str(port_down_device_to_ofp_min))
-        main.log.report("Port down device-to-ofp Max: "+
-                str(port_down_device_to_ofp_max))
-        main.log.report("Port down device-to-ofp Avg: "+
+                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))
         
         port_up_graph_to_ofp_min = min(port_up_graph_to_ofp_list)
@@ -762,7 +764,26 @@
         port_up_graph_to_ofp_avg = \
                 (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))
+          
+        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)
+        port_up_device_to_ofp_avg = \
+                (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))
+
+        utilities.assert_equals(expect=main.TRUE, actual=assertion,
+                onpass="Port discovery latency calculation successful",
+                onfail="Port discovery test failed")
 
     def CASE4(self, main):
         '''
@@ -976,10 +997,18 @@
                link_down_lat_graph_avg < 30000:
                 link_down_graph_to_system_list.append(
                         link_down_lat_graph_avg)
+            else:
+                main.log.info("Link down latency exceeded threshold")
+                main.log.info("Results for iteration "+str(i)+
+                        "have been omitted")
             if link_down_lat_link_avg > 0.0 and\
                link_down_lat_link_avg < 30000:
                 link_down_link_to_system_list.append(
                         link_down_lat_link_avg)
+            else:
+                main.log.info("Link down latency exceeded threshold")
+                main.log.info("Results for iteration "+str(i)+
+                        "have been omitted")
 
             #NOTE: To remove loss rate and measure latency:
             #       'sh tc qdisc del dev s1-eth1 root'
@@ -1125,10 +1154,18 @@
                link_up_lat_graph_avg < 30000:
                 link_up_graph_to_system_list.append(
                         link_up_lat_graph_avg)
+            else:
+                main.log.info("Link up latency exceeded threshold")
+                main.log.info("Results for iteration "+str(i)+
+                        "have been omitted")
             if link_up_lat_link_avg > 0.0 and\
                link_up_lat_link_avg < 30000:
                 link_up_link_to_system_list.append(
                         link_up_lat_link_avg)
+            else:
+                main.log.info("Link up latency exceeded threshold")
+                main.log.info("Results for iteration "+str(i)+
+                        "have been omitted")
 
         #Calculate min, max, avg of list and report
         link_down_min = min(link_down_graph_to_system_list)
@@ -1149,19 +1186,24 @@
                 str(link_up_max)+"ms  Avg: "+
                 str(link_up_avg)+"ms")
 
+        utilities.assert_equals(expect=main.TRUE, actual=assertion,
+                onpass="Link discovery latency calculation successful",
+                onfail="Link discovery latency case failed")
+
     def CASE5(self, main):
         '''
         100 Switch discovery latency
 
         Important:
-            If a simple topology was used in previous cases,
-            you will need to change the topology file in the
-            params for this case to proceed
-        
             This test case can be potentially dangerous if 
             your machine has previously set iptables rules.
             One of the steps of the test case will flush
             all existing iptables rules.
+        Note:
+            You can specify the number of switches in the 
+            params file to adjust the switch discovery size
+            (and specify the corresponding topology in Mininet1 
+            .topo file)
         '''
         import time
         import subprocess
@@ -1230,6 +1272,8 @@
                     " --dport "+default_sw_port+" -j DROP")
             main.ONOS1.handle.expect("\$")
             #Give time to allow rule to take effect
+            #NOTE: Sleep period may need to be configured 
+            #      based on the number of switches in the topology
             main.log.info("Please wait for switch connection to "+
                     "time out")
             time.sleep(60)