Merge "Imporve SCPFportLat test     - Improve calculate latency method     - Add a dependence file to grep latency     - Improve database method"
diff --git a/TestON/drivers/common/cli/onosclidriver.py b/TestON/drivers/common/cli/onosclidriver.py
index 5ed20ef..306680e 100755
--- a/TestON/drivers/common/cli/onosclidriver.py
+++ b/TestON/drivers/common/cli/onosclidriver.py
@@ -1156,7 +1156,7 @@
             main.cleanup()
             main.exit()
 
-    def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="", setVlan="" ):
+    def addHostIntent( self, hostIdOne, hostIdTwo, vlanId="", setVlan="", encap="" ):
         """
         Required:
             * hostIdOne: ONOS host id for host1
@@ -1164,6 +1164,7 @@
         Optional:
             * vlanId: specify a VLAN id for the intent
             * setVlan: specify a VLAN id treatment
+            * encap: specify an encapsulation type
         Description:
             Adds a host-to-host intent ( bidirectional ) by
             specifying the two hosts.
@@ -1176,6 +1177,8 @@
                 cmdStr += "-v " + str( vlanId ) + " "
             if setVlan:
                 cmdStr += "--setVlan " + str( vlanId ) + " "
+            if encap:
+                cmdStr += "--encapsulation " + str( encap ) + " "
             cmdStr += str( hostIdOne ) + " " + str( hostIdTwo )
             handle = self.sendline( cmdStr )
             assert "Command not found:" not in handle, handle
@@ -1274,7 +1277,8 @@
             tcpSrc="",
             tcpDst="",
             vlanId="",
-            setVlan="" ):
+            setVlan="",
+            encap="" ):
         """
         Required:
             * ingressDevice: device id of ingress device
@@ -1293,6 +1297,7 @@
             * tcpDst: specify tcp destination port
             * vlanId: specify vlan ID
             * setVlan: specify a VLAN id treatment
+            * encap: specify an Encapsulation type to use
         Description:
             Adds a point-to-point intent ( uni-directional ) by
             specifying device id's and optional fields
@@ -1330,6 +1335,8 @@
                 cmd += " -v " + str( vlanId )
             if setVlan:
                 cmd += " --setVlan " + str( setVlan )
+            if encap:
+                cmd += " --encapsulation " + str( encap )
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -1411,7 +1418,8 @@
             setEthDst="",
             vlanId="",
             setVlan="",
-            partial=False ):
+            partial=False,
+            encap="" ):
         """
         Note:
             This function assumes the format of all ingress devices
@@ -1438,6 +1446,7 @@
             * setEthDst: action to Rewrite Destination MAC Address
             * vlanId: specify vlan Id
             * setVlan: specify VLAN Id treatment
+            * encap: specify a type of encapsulation
         Description:
             Adds a multipoint-to-singlepoint intent ( uni-directional ) by
             specifying device id's and optional fields
@@ -1481,6 +1490,8 @@
                 cmd += " --setVlan " + str( setVlan )
             if partial:
                 cmd += " --partial"
+            if encap:
+                cmd += " --encapsulation " + str( encap )
 
             # Check whether the user appended the port
             # or provided it as an input
@@ -1566,7 +1577,8 @@
             setEthDst="",
             vlanId="",
             setVlan="",
-            partial=False ):
+            partial=False,
+            encap="" ):
         """
         Note:
             This function assumes the format of all egress devices
@@ -1593,6 +1605,7 @@
             * setEthDst: action to Rewrite Destination MAC Address
             * vlanId: specify vlan Id
             * setVlan: specify VLAN ID treatment
+            * encap: specify an encapsulation type
         Description:
             Adds a singlepoint-to-multipoint intent ( uni-directional ) by
             specifying device id's and optional fields
@@ -1636,6 +1649,8 @@
                 cmd += " --setVlan " + str( setVlan )
             if partial:
                 cmd += " --partial"
+            if encap:
+                cmd += " --encapsulation " + str( encap )
 
             # Check whether the user appended the port
             # or provided it as an input
diff --git a/TestON/tests/FUNC/FUNCintent/FUNCintent.py b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
index 5bcfe62..5ee3f70 100644
--- a/TestON/tests/FUNC/FUNCintent/FUNCintent.py
+++ b/TestON/tests/FUNC/FUNCintent/FUNCintent.py
@@ -929,6 +929,36 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString)
 
+        main.step( "Encapsulation: Add host intents between h1 and h9" )
+        main.assertReturnString = "Assertion Result for VLAN Encapsulated host intent\n"
+        host1 = { "name":"h1","id":"00:00:00:00:00:01/-1" }
+        host2 = { "name":"h9","id":"00:00:00:00:00:09/-1" }
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installHostIntent( main,
+                                              name='ENCAPSULATION',
+                                              onosNode='0',
+                                              host1=host1,
+                                              host2=host2,
+                                              encap="VLAN" )
+        if installResult:
+            testResult = main.intentFunction.testHostIntent( main,
+                                              name='ENCAPSULATION',
+                                              intentId = installResult,
+                                              onosNode='0',
+                                              host1=host1,
+                                              host2=host2,
+                                              sw1='s5',
+                                              sw2='s2',
+                                              expectedLink = 18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString)
+
         main.step( "Confirm that ONOS leadership is unchanged")
         intentLeadersNew = main.CLIs[ 0 ].leaderCandidates()
         main.intentFunction.checkLeaderChange( intentLeadersOld,
@@ -1317,6 +1347,41 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        main.step( "Add point to point intents using VLAN Encapsulation" )
+        main.assertReturnString = "Assertion Result for VLAN Encapsulation Point Intent"
+        senders = [
+            { "name":"h1","device":"of:0000000000000005/1" }
+        ]
+        recipients = [
+            { "name":"h9","device":"of:0000000000000006/1" }
+        ]
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installPointIntent(
+                                       main,
+                                       name="ENCAPSULATION",
+                                       senders=senders,
+                                       recipients=recipients,
+                                       encap="VLAN" )
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="ENCAPSULATION",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.intentFunction.report( main )
 
     def CASE3000( self, main ):
@@ -1582,6 +1647,48 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        main.step( "ENCAPSULATION: Install and test single point to multi point intents" )
+        main.assertReturnString = "Assertion results for VLAN Encapsulation single to multi point intent\n"
+        senders = [
+            { "name":"h8", "device":"of:0000000000000005/8" }
+        ]
+        recipients = [
+            { "name":"h16", "device":"of:0000000000000006/8" },
+            { "name":"h24", "device":"of:0000000000000007/8" }
+        ]
+        badSenders=[ { "name":"h9" } ]  # Senders that are not in the intent
+        badRecipients=[ { "name":"h17" } ]  # Recipients that are not in the intent
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installSingleToMultiIntent(
+                                         main,
+                                         name="ENCAPSULATION",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         encap="VLAN" )
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="ENCAPSULATION",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         badSenders=badSenders,
+                                         badRecipients=badRecipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         expectedLink=18)
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.intentFunction.report( main )
 
     def CASE4000( self, main ):
@@ -1848,6 +1955,48 @@
                                  onpass=main.assertReturnString,
                                  onfail=main.assertReturnString )
 
+        main.step( "ENCAPSULATION: Add multi point to single point intents" )
+        main.assertReturnString = "Assertion results for VLAN Encapsulation multi to single point intent\n"
+        senders = [
+            { "name":"h16", "device":"of:0000000000000006/8" },
+            { "name":"h24", "device":"of:0000000000000007/8" }
+        ]
+        recipients = [
+            { "name":"h8", "device":"of:0000000000000005/8" }
+        ]
+        badSenders=[ { "name":"h17" } ]  # Senders that are not in the intent
+        badRecipients=[ { "name":"h9" } ]  # Recipients that are not in the intent
+        testResult = main.FALSE
+        installResult = main.FALSE
+        installResult = main.intentFunction.installMultiToSingleIntent(
+                                         main,
+                                         name="ENCAPSULATION",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         encap="VLAN" )
+
+        if installResult:
+            testResult = main.intentFunction.testPointIntent(
+                                         main,
+                                         intentId=installResult,
+                                         name="ENCAPSULATION",
+                                         senders=senders,
+                                         recipients=recipients,
+                                         badSenders=badSenders,
+                                         badRecipients=badRecipients,
+                                         sw1="s5",
+                                         sw2="s2",
+                                         expectedLink=18 )
+        else:
+            main.CLIs[ 0 ].removeAllIntents( purge=True )
+
+        utilities.assert_equals( expect=main.TRUE,
+                                 actual=testResult,
+                                 onpass=main.assertReturnString,
+                                 onfail=main.assertReturnString )
+
         main.intentFunction.report( main )
 
     def CASE5000( self, main ):
diff --git a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
index 0164c68..89695a2 100755
--- a/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
+++ b/TestON/tests/FUNC/FUNCintent/dependencies/FuncIntentFunction.py
@@ -23,7 +23,8 @@
                        tcp="",
                        sw1="",
                        sw2="",
-                       setVlan="" ):
+                       setVlan="",
+                       encap="" ):
     """
     Installs a Host Intent
 
@@ -80,7 +81,8 @@
         intentId = main.CLIs[ onosNode ].addHostIntent( hostIdOne=host1.get( "id" ),
                                                         hostIdTwo=host2.get( "id" ),
                                                         vlanId=vlanId,
-                                                        setVlan=setVlan )
+                                                        setVlan=setVlan,
+                                                        encap=encap )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -306,7 +308,8 @@
                         ipDst="",
                         tcpSrc="",
                         tcpDst="",
-                        setVlan=""):
+                        setVlan="",
+                        encap="" ):
     """
     Installs a Single to Single Point Intent
 
@@ -395,7 +398,8 @@
                                             tcpSrc=tcpSrc,
                                             tcpDst=tcpDst,
                                             vlanId=vlanId,
-                                            setVlan=setVlan )
+                                            setVlan=setVlan,
+                                            encap=encap )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -714,7 +718,8 @@
                                 sw1="",
                                 sw2="",
                                 setVlan="",
-                                partial=False ):
+                                partial=False,
+                                encap="" ):
     """
     Installs a Single to Multi Point Intent
 
@@ -803,7 +808,8 @@
                                             tcpDst="",
                                             vlanId=vlanId,
                                             setVlan=setVlan,
-                                            partial=partial )
+                                            partial=partial,
+                                            encap=encap )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -839,7 +845,8 @@
                                 sw1="",
                                 sw2="",
                                 setVlan="",
-                                partial=False ):
+                                partial=False,
+                                encap="" ):
     """
     Installs a Multi to Single Point Intent
 
@@ -927,7 +934,8 @@
                                             tcpDst="",
                                             vlanId=vlanId,
                                             setVlan=setVlan,
-                                            partial=partial )
+                                            partial=partial,
+                                            encap=encap )
     except (KeyError, TypeError):
         errorMsg = "There was a problem loading the hosts data."
         if intentId:
@@ -1107,7 +1115,7 @@
             testResult = main.FALSE
 
         # Check flows count in each node
-        if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=3 ):
+        if utilities.retry( f=checkFlowsCount, retValue=main.FALSE, args=[ main ], sleep=20, attempts=5 ) and utilities.retry( f=checkFlowsState, retValue=main.FALSE, args=[ main ], sleep=20, attempts=5 ):
             main.assertReturnString += 'Link Down Flow State Passed\n'
         else:
             main.assertReturnString += 'Link Down Flow State Failed\n'
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.params b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.params
index 79e8620..0abc6b7 100755
--- a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.params
+++ b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.params
@@ -7,8 +7,8 @@
     # 100 - balance master and bring onos node down
     # 200 - bring onos node up and balance masters
     # 1000 - report logs
-
-    <testcases>1,[2,10,300,11,100,300,11,200,300,11,1000]*3</testcases>
+    # 1,[2,10,300,11,100,300,11,200,300,11,1000]*3
+    <testcases>1,[2,10,300,11,1000]*10</testcases>
 
     <DEPENDENCY>
         <path>/tests/SCPF/SCPFscaleTopo/dependencies/</path>
@@ -19,7 +19,7 @@
     </DEPENDENCY>
 
     <ENV>
-        <cellApps>drivers,openflow,fwd</cellApps>
+        <cellApps>drivers,openflow</cellApps>
     </ENV>
 
     <GIT>
@@ -38,6 +38,7 @@
         <nodeSleep>10</nodeSleep>
         <pingall>15</pingall>
         <MNsleep>60</MNsleep>
+        <host>0</host>
     </SLEEP>
 
     <TIMEOUT>
@@ -52,7 +53,8 @@
 
     <TOPOLOGY>
         <topology>torus</topology>
-        <scale>10,15,20</scale>
+        <scale>20,25,30,35,40,45,50,55,60</scale>
+        <host>True</host>
     </TOPOLOGY>
 
 </PARAMS>
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
index 71c7d3a..e8e5b94 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/SCPFscaleTopo.py
@@ -8,10 +8,8 @@
         self.default = ''
 
     def CASE1( self, main ):
-        import time
         import os
         import imp
-        import re
 
         """
         - Construct tests variables
@@ -48,6 +46,12 @@
         main.pingallSleep = int( main.params[ 'SLEEP' ][ 'pingall' ] )
         main.MNSleep = int( main.params[ 'SLEEP' ][ 'MNsleep' ] )
         main.pingTimeout = float( main.params[ 'TIMEOUT' ][ 'pingall' ] )
+        main.hostDiscover = main.params[ 'TOPOLOGY' ][ 'host' ]
+        main.hostDiscoverSleep = float( main.params['SLEEP']['host'] )
+        if main.hostDiscover == 'True':
+            main.hostDiscover = True
+        else:
+            main.hostDiscover = False
         gitPull = main.params[ 'GIT' ][ 'pull' ]
         main.homeDir = os.path.expanduser('~')
         main.cellData = {} # for creating cell file
@@ -118,6 +122,7 @@
         - Install ONOS cluster
         - Connect to cli
         """
+        import time
         main.log.info( "Checking if mininet is already running" )
         if len( main.topoScale ) < main.topoScaleSize:
             main.log.info( "Mininet is already running. Stopping mininet." )
@@ -234,7 +239,6 @@
         """
             Starting up torus topology
         """
-        import json
 
         main.case( "Starting up Mininet and verifying topology" )
         main.caseExplanation = "Starting Mininet with a scalling topology and " +\
@@ -245,9 +249,8 @@
         main.step( "Starting up TORUS %sx%s topology" % (main.currScale, main.currScale) )
 
         main.log.info( "Constructing Mininet command" )
-        mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs +\
-                " --switch ovsm --topo " + main.topoName + ","+ main.currScale + "," + main.currScale
-
+        mnCmd = " mn --custom " + main.Mininet1.home + main.multiovs + \
+                " --switch ovsm --topo " + main.topoName + "," + main.currScale + "," + main.currScale
         for i in range( main.numCtrls ):
                 mnCmd += " --controller remote,ip=" + main.ONOSip[ i ]
 
@@ -263,11 +266,11 @@
 
     def CASE11( self, main ):
         """
-            Pingall, and compare topo
-            We don't care the pingall result,
+            Compare topo, and sending Arping package
             if the topology is same, then Pass.
         """
         import json
+        import time
 
         main.case( "Verifying topology: TORUS %sx%s" % (main.currScale, main.currScale) )
         main.caseExplanation = "Pinging all hosts and comparing topology " +\
@@ -275,10 +278,6 @@
 
         main.log.info( "Gathering topology information" )
         time.sleep( main.MNSleep )
-
-        devicesResults = main.TRUE
-        linksResults = main.TRUE
-        hostsResults = main.TRUE
         stepResult = main.TRUE
         main.step( "Comparing MN topology to ONOS topology" )
 
@@ -288,17 +287,14 @@
             devices = main.topo.getAllDevices( main )
             ports = main.topo.getAllPorts( main )
             links = main.topo.getAllLinks( main)
-            clusters = main.topo.getAllClusters( main )
             mnSwitches = main.Mininet1.getSwitches()
             mnLinks = main.Mininet1.getLinks(timeout=180)
-            mnHosts = main.Mininet1.getHosts()
 
             for controller in range(len(main.activeNodes)):
-                controllerStr = str( main.activeNodes[controller] + 1 )
-                if devices[ controller ] and ports[ controller ] and\
-                    "Error" not in devices[ controller ] and\
-                    "Error" not in ports[ controller ]:
-
+                # controllerStr = str( main.activeNodes[controller] + 1 )
+                if devices[ controller ] and ports[ controller ] and \
+                                "Error" not in devices[ controller ] and \
+                                "Error" not in ports[ controller ]:
                     currentDevicesResult = main.Mininet1.compareSwitches(
                             mnSwitches,
                             json.loads( devices[ controller ] ),
@@ -313,40 +309,52 @@
                 else:
                     currentLinksResult = main.FALSE
 
-                stepResult = currentDevicesResult and currentLinksResult
+                stepResult = stepResult and currentDevicesResult and currentLinksResult
             if stepResult:
                 break
             compareRetry += 1
+        utilities.assert_equals(expect=main.TRUE,
+                                actual=stepResult,
+                                onpass=" Topology match Mininet",
+                                onfail="ONOS Topology doesn't match Mininet")
 
-        # host discover
-        hostList=[]
-        for i in range( 1, int(main.currScale)+1 ):
-            for j in range( 1, int(main.currScale)+1 ):
-                hoststr = "h" + str(i)+ "x" + str(j)
-                hostList.append(hoststr)
-        totalNum = main.topo.sendArpPackage(main, hostList)
-        # check host number
-        main.log.info("{} hosts has been discovered".format( totalNum ))
-        if int(totalNum) == ( int(main.currScale) * int(main.currScale) ):
-            main.log.info("All hosts has been discovered")
-            stepResult = stepResult and main.TRUE
+        if stepResult:
+            if main.hostDiscover:
+                hostList = []
+                for i in range( 1, int( main.currScale ) + 1 ):
+                    for j in range( 1, int( main.currScale ) + 1) :
+                        # Generate host list
+                        hoststr = "h" + str(i) + "x" + str(j)
+                        hostList.append(hoststr)
+                for i in range( len(hostList) ):
+                    totalHost = main.topo.sendArpPackage( main, hostList[i] )
+                    time.sleep( main.hostDiscoverSleep )
+                    if totalHost < 0:
+                        # if totalHost less than 0 which means dependence function has exception.
+                        main.log.info( "Error when discover host!" )
+                        break
+                if totalHost == int( main.currScale ) *  int( main.currScale ):
+                    main.log.info( "Discovered all hosts" )
+                    stepResult = stepResult and main.TRUE
+                else:
+                    main.log.warn( "Some hosts ware not discovered by ONOS... Topology doesn't match!" )
+                    stepResult = main.FALSE
+                utilities.assert_equals(expect=main.TRUE,
+                                        actual=stepResult,
+                                        onpass=" Topology match Mininet",
+                                        onfail="ONOS Topology doesn't match Mininet")
+            main.log.info( "Finished this iteration, continue to scale next topology." )
         else:
-            main.log.warn("Hosts number is not correct!")
-            stepResult = stepResult and main.FALSE
-
-        utilities.assert_equals( expect=main.TRUE,
-                                 actual=stepResult,
-                                 onpass=" Topology match Mininet",
-                                 onfail="ONOS" + controllerStr +
-                                 " Topology doesn't match Mininet" )
-
+            main.log.info( "Clean up and exit TestON. Finished this test." )
+            main.cleanup()
+            main.exit()
 
     def CASE100( self, main ):
         '''
            Bring Down node 3
         '''
 
-        main.case("Balancing Masters and bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
+        main.case("Bring ONOS node 3 down: TORUS %sx%s" % (main.currScale, main.currScale))
         main.caseExplanation = "Balance masters to make sure " +\
                         "each controller has some devices and " +\
                         "stop ONOS node 3 service. "
@@ -369,10 +377,10 @@
 
     def CASE200( self, main ):
         '''
-            Bring up onos node and balance masters
+            Bring up onos node
         '''
 
-        main.case("Bring ONOS node 3 up and balance masters: TORUS %sx%s" % (main.currScale, main.currScale))
+        main.case("Bring ONOS node 3 up: TORUS %sx%s" % (main.currScale, main.currScale))
         main.caseExplanation = "Bring node 3 back up and balance the masters"
 
         node = main.deadNode + 1
diff --git a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
index 4f7bfb7..22505ff 100644
--- a/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
+++ b/TestON/tests/SCPF/SCPFscaleTopo/dependencies/topo.py
@@ -104,14 +104,23 @@
         send arping package from host
         return the total hosts number from Onos
     """
-    main.log.info("Sending Arping package...")
+    main.log.info( "Sending Arping package..." )
     if isinstance(hostList, list):
-        threads = []
         for h in hostList:
             main.Mininet1.arping( srcHost=h, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
             time.sleep(0.5)
     else:
-        main.Mininet1.arping(srcHost=hostList)
-    summaryStr = json.loads( main.CLIs[0].summary().encode() )
-    hostNum = summaryStr.get('hosts')
+        main.Mininet1.arping( srcHost=hostList, dstHost="10.0.0.1", output=main.FALSE, noResult=True )
+    try:
+        summaryStr = ""
+        summaryStr = json.loads( main.CLIs[0].summary().encode() )
+        hostNum = summaryStr.get( 'hosts' )
+
+    except (TypeError, ValueError):
+        main.log.exception( " Object not as expected: {!r}".format( summaryStr) )
+        return -1
+    except Exception:
+        main.log.exception( self.name + ": Uncaught exception!" )
+        return -1
+
     return hostNum