diff --git a/src/test/igmp/igmpTest.py b/src/test/igmp/igmpTest.py
index a683ee9..88dae5f 100644
--- a/src/test/igmp/igmpTest.py
+++ b/src/test/igmp/igmpTest.py
@@ -62,13 +62,13 @@
     MINVALIDGROUP2 = '239.255.255.255'
     MMACGROUP1 = "01:00:5e:01:02:03"
     MMACGROUP2 = "01:00:5e:02:02:03"
-    IGMP_DST_MAC = "01:00:5e:00:01:01"
+    IGMP_DST_MAC = "01:00:5e:00:00:16"
     IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
     IP_SRC = '1.2.3.4'
-    IP_DST = '224.0.1.1'
+    IP_DST = '224.0.0.22'
     NEGATIVE_TRAFFIC_STATUS = 1
-    igmp_eth = Ether(dst = IGMP_DST_MAC, src = IGMP_SRC_MAC, type = ETH_P_IP)
-    igmp_ip = IP(dst = IP_DST, src = IP_SRC)
+    igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
+    igmp_ip = IP(dst = IP_DST)
     IGMP_TEST_TIMEOUT = 5
     IGMP_QUERY_TIMEOUT = 60
     MCAST_TRAFFIC_TIMEOUT = 10
@@ -87,24 +87,33 @@
     def tearDownClass(cls): pass
 
     def setUp(self):
-        ''' Activate the dhcp app'''
+        ''' Activate the igmp app'''
         self.onos_ctrl = OnosCtrl(self.app)
+	self.onos_ctrl.activate()
         self.igmp_channel = IgmpChannel()
 
     def tearDown(self): pass
 
     def onos_load_config(self, config):
+	log.info('onos load config is %s'%config)
         status, code = OnosCtrl.config(config)
         if status is False:
             log.info('JSON request returned status %d' %code)
             assert_equal(status, True)
         time.sleep(2)
 
-    def onos_ssm_table_load(self, groups, src_list):
+    def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
           ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
           ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
-          for g in groups:
-                for s in src_list:
+	  if flag: #to maintain seperate group-source pair.
+	      for i in range(len(groups)):
+		  d = {}
+		  d['source'] = src_list[i] or '0.0.0.0'
+		  d['group'] = groups[i]
+		  ssm_xlate_list.append(d)
+	  else:
+              for g in groups:
+                  for s in src_list:
                       d = {}
                       d['source'] = s or '0.0.0.0'
                       d['group'] = g
@@ -116,6 +125,66 @@
           self.igmp_channel.cord_port_table_load(cord_port_map)
           time.sleep(2)
 
+    def mcast_ip_range(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
+        start = list(map(int, start_ip.split(".")))
+        end = list(map(int, end_ip.split(".")))
+        temp = start
+        ip_range = []
+        ip_range.append(start_ip)
+        while temp != end:
+            start[3] += 1
+            for i in (3, 2, 1):
+                if temp[i] == 255:
+                    temp[i] = 0
+                    temp[i-1] += 1
+            ip_range.append(".".join(map(str, temp)))
+        return ip_range
+
+    def random_mcast_ip(self,start_ip = '224.0.1.0', end_ip = '224.0.1.100'):
+        start = list(map(int, start_ip.split(".")))
+        end = list(map(int, end_ip.split(".")))
+        temp = start
+        ip_range = []
+        ip_range.append(start_ip)
+        while temp != end:
+            start[3] += 1
+            for i in (3, 2, 1):
+                if temp[i] == 255:
+                    temp[i] = 0
+                    temp[i-1] += 1
+            ip_range.append(".".join(map(str, temp)))
+        return random.choice(ip_range)
+
+    def source_ip_range(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
+        start = list(map(int, start_ip.split(".")))
+        end = list(map(int, end_ip.split(".")))
+        temp = start
+        ip_range = []
+        ip_range.append(start_ip)
+        while temp != end:
+            start[3] += 1
+            for i in (3, 2, 1):
+                if temp[i] == 255:
+                    temp[i] = 0
+                    temp[i-1] += 1
+            ip_range.append(".".join(map(str, temp)))
+        return ip_range
+
+    def randomsourceip(self,start_ip = '10.10.0.1', end_ip = '10.10.0.100'):
+        start = list(map(int, start_ip.split(".")))
+        end = list(map(int, end_ip.split(".")))
+        temp = start
+        ip_range = []
+        ip_range.append(start_ip)
+        while temp != end:
+            start[3] += 1
+            for i in (3, 2, 1):
+                if temp[i] == 255:
+                    temp[i] = 0
+                    temp[i-1] += 1
+            ip_range.append(".".join(map(str, temp)))
+        return random.choice(ip_range)
+
     def igmp_verify_join(self, igmpStateList):
         sendState, recvState = igmpStateList
         ## check if the send is received for the groups
@@ -168,12 +237,12 @@
         igmpState.update(p.dst, rx = 1, t = recv_time - send_time)
         return 0
 
-    def send_igmp_join(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
-        self.onos_ssm_table_load(groups, src_list)
+    def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,ip_pkt = None, iface = 'veth0', delay = 1):
+        #self.onos_ssm_table_load(groups, src_list)
         igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
                       gaddr=self.IP_DST)
         for g in groups:
-              gr = IGMPv3gr(rtype=IGMP_V3_GR_TYPE_INCLUDE, mcaddr=g)
+              gr = IGMPv3gr(rtype= record_type, mcaddr=g)
               gr.sources = src_list
               igmp.grps.append(gr)
         if ip_pkt is None:
@@ -202,7 +271,7 @@
             resp = srp1(pkt, iface=iface)
         else:
             log.info('Sending IGMP join for group %s and waiting for periodic query packets and printing one packet' %groups)
-            resp = srp3(pkt, iface=iface)
+            resp = srp1(pkt, iface=iface)
 #       resp = srp1(pkt, iface=iface) if rec_queryCount else srp3(pkt, iface=iface)
         resp[0].summary()
         log.info('Sent IGMP join for group %s and received a query packet and  printing packet' %groups)
@@ -210,6 +279,7 @@
             time.sleep(delay)
 
     def send_igmp_leave(self, groups, src_list = ['1.2.3.4'], ip_pkt = None, iface = 'veth0', delay = 2):
+	log.info('entering into igmp leave function')
         igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
                       gaddr=self.IP_DST)
         for g in groups:
@@ -245,6 +315,7 @@
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
     def test_igmp_join_verify_traffic(self):
         groups = ['224.0.1.1', '225.0.0.1']
+	self.onos_ssm_table_load(groups)
         df = defer.Deferred()
         igmpState = IGMPTestState(groups = groups, df = df)
         igmpStateRecv = IGMPTestState(groups = groups, df = df)
@@ -271,10 +342,11 @@
         reactor.callLater(0, igmp_srp_task, igmpStateList)
         return df
 
-    @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
+    @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
     def test_igmp_leave_verify_traffic(self):
         groups = ['224.0.1.10', '225.0.0.10']
         leave_groups = ['224.0.1.10']
+	self.onos_ssm_table_load(groups)
         df = defer.Deferred()
         igmpState = IGMPTestState(groups = groups, df = df)
         igmpStateRecv = IGMPTestState(groups = groups, df = df)
@@ -285,28 +357,21 @@
         self.mcastTraffic = mcastTraffic
         self.recv_socket = L3PacketSocket(iface = 'veth0', type = ETH_P_IP)
 
-        def igmp_srp_task(stateList):
-            igmpSendState, igmpRecvState = stateList
-            if not mcastTraffic.isRecvStopped():
-                result = self.igmp_recv(igmpRecvState)
-                reactor.callLater(0, igmp_srp_task, stateList)
-            else:
-                self.mcastTraffic.stop()
-                self.recv_socket.close()
-                self.igmp_verify_leave(stateList, leave_groups)
-                self.df.callback(0)
-
-        self.send_igmp_join(groups)
-        self.send_igmp_leave(leave_groups, delay = 3)
-        mcastTraffic.start()
-        self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
-        reactor.callLater(0, igmp_srp_task, igmpStateList)
+	mcastTraffic.start()
+	self.send_igmp_join(groups)
+	self.send_igmp_leave(leave_groups, delay = 3)
+	join_state = IGMPTestState(groups = leave_groups)
+	status = self.igmp_not_recv_task(self.V_INF1,leave_groups, join_state)
+	log.info('verified status for igmp recv task %s'%status)
+	assert status == 1 , 'EXPECTED RESULT'
+	self.df.callback(0)
         return df
 
     @deferred(timeout=100)
     def test_igmp_leave_join_loop(self):
         self.groups = ['226.0.1.1', '227.0.0.1', '228.0.0.1', '229.0.0.1', '230.0.0.1' ]
         self.src_list = ['3.4.5.6', '7.8.9.10']
+	self.onos_ssm_table_load(self.groups,src_list=self.src_list)
         df = defer.Deferred()
         self.df = df
         self.iterations = 0
@@ -336,7 +401,7 @@
         return df
 
     def igmp_join_task(self, intf, groups, state, src_list = ['1.2.3.4']):
-          self.onos_ssm_table_load(groups, src_list)
+          #self.onos_ssm_table_load(groups, src_list)
           igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
                         gaddr=self.IP_DST)
           for g in groups:
@@ -380,6 +445,7 @@
           log.debug('Returning from recv task')
 
     def igmp_not_recv_task(self, intf, groups, join_state):
+	  log.info('entering igmp not recv task loop')
           recv_socket = L2Socket(iface = intf, type = ETH_P_IP)
           group_map = {}
           for g in groups:
@@ -414,17 +480,35 @@
           self.send_igmp_leave(groups = groups)
           return
 
+    @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
     def test_igmp_1group_join_latency(self):
-          groups = ['239.0.1.1']
-          self.group_latency_check(groups)
+        groups = ['239.0.1.1']
+        df = defer.Deferred()
+        def igmp_1group_join_latency():
+              self.group_latency_check(groups)
+              df.callback(0)
+        reactor.callLater(0, igmp_1group_join_latency)
+        return df
 
+    @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
     def test_igmp_2group_join_latency(self):
-          groups = ['239.0.1.1', '240.0.1.1']
-          self.group_latency_check(groups)
+        groups = ['239.0.1.1', '240.0.1.1']
+        df = defer.Deferred()
+        def igmp_2group_join_latency():
+            self.group_latency_check(groups)
+            df.callback(0)
+        reactor.callLater(0, igmp_2group_join_latency)
+        return df
 
+    @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
     def test_igmp_Ngroup_join_latency(self):
-          groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
-          self.group_latency_check(groups)
+        groups = ['239.0.1.1', '240.0.1.1', '241.0.1.1', '242.0.1.1']
+        df = defer.Deferred()
+        def igmp_Ngroup_join_latency():
+            self.group_latency_check(groups)
+            df.callback(0)
+        reactor.callLater(0, igmp_Ngroup_join_latency)
+        return df
 
     def test_igmp_join_rover(self):
           s = (224 << 24) | 1
@@ -438,21 +522,22 @@
     @deferred(timeout=IGMP_QUERY_TIMEOUT + 10)
     def test_igmp_query(self):
         groups = ['224.0.0.1'] ##igmp query group
+	self.onos_ssm_table_load(groups)
         df = defer.Deferred()
         self.df = df
         self.recv_socket = L2Socket(iface = 'veth0', type = ETH_P_IP)
 
         def igmp_query_timeout():
               def igmp_query_cb(pkt):
+		    log.info('received igmp query packet is %s'%pkt.show())
                     log.info('Got IGMP query packet from %s for %s' %(pkt[IP].src, pkt[IP].dst))
                     assert_equal(pkt[IP].dst, '224.0.0.1')
-
               sniff(prn = igmp_query_cb, count=1, lfilter = lambda p: IP in p and p[IP].dst in groups,
                     opened_socket = self.recv_socket)
               self.recv_socket.close()
               self.df.callback(0)
 
-        self.send_igmp_join(groups)
+        #self.send_igmp_join(groups)
         self.test_timer = reactor.callLater(self.IGMP_QUERY_TIMEOUT, igmp_query_timeout)
         return df
 
@@ -461,13 +546,12 @@
         g2 = groups[1]
         sourcelist1 = sources[0]
         sourcelist2 = sources[1]
-        eth = Ether(dst = self.MMACGROUP1, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
-        src_ip = ip_src or self.IP_SRC
-        ip = IP(dst = g1, src = src_ip)
+        eth = Ether(dst = self.IGMP_DST_MAC,type = ETH_P_IP)
+        ip = IP(dst = self.IP_DST)
         log.info('Sending join message for the group %s' %g1)
         self.send_igmp_join((g1,), src_list = sourcelist1, ip_pkt = eth/ip, iface = intf, delay = 2)
         eth = Ether(dst = self.MMACGROUP2, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
-        ip = IP(dst = g2, src = src_ip)
+        ip = IP(dst = g2)
         log.info('Sending join message for group %s' %g2)
         self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
         log.info('Done with igmp_send_joins_different_groups_srclist')
@@ -495,13 +579,15 @@
             log.info('Sending join message for group %s' %g2)
             self.send_igmp_join((g2,), src_list = sourcelist2, ip_pkt = eth/ip, iface = intf, delay = 2)
 
-    def igmp_joins_leave_functionality(self, again_join = False, df = None):
-        groups1 = (self.MGROUP1,)
-        groups2 = (self.MGROUP2,)
+    def igmp_joins_leave(self,groups,src_list,again_join = False, df = None):
+        groups1 = [groups[0]]
+        groups2 = [groups[1]]
+	src1 = [src_list[0]]
+	src2 = [src_list[1]]
         self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
-                                                      (['2.2.2.2'], ['2.2.2.2']), intf = self.V_INF1, delay = 2)
-        dst_mac = '01:00:5e:01:02:03'
-        src_ip = '2.2.2.2'
+                                                      (src1, src2), intf = self.V_INF1, delay = 2)
+
+        src_ip = src1[0]
         if df is None:
               df = defer.Deferred()
         igmpState1 = IGMPTestState(groups = groups1, df = df)
@@ -511,11 +597,12 @@
         igmpState2 = IGMPTestState(groups = groups2, df = df)
         igmpStateRecv2 = IGMPTestState(groups = groups2, df = df)
         igmpStateList2 = (igmpState2, igmpStateRecv2)
+	dst_mac = self.iptomac(groups1[0])
         mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
                                      src_ip = src_ip, cb = self.send_mcast_cb,
                                      arg = igmpState1)
-        dst_mac = '01:00:5e:02:02:03'
-        src_ip = '2.2.2.2'
+        src_ip = src2[0]
+	dst_mac = self.iptomac(groups1[0])
         mcastTraffic2 = McastTraffic(groups2, iface= 'veth2', dst_mac = dst_mac,
                                      src_ip = src_ip, cb = self.send_mcast_cb,
                                      arg = igmpState2)
@@ -528,15 +615,15 @@
         target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
         log.info('Interface is receiving multicast groups %s' %groups2)
         log.info('Interface is sending leave message for groups %s now' %groups2)
-        self.send_igmp_leave(groups = groups2, src_list = ['2.2.2.2'], iface = self.V_INF1, delay = 2)
+        self.send_igmp_leave(groups = groups2, src_list = src2, iface = self.V_INF1, delay = 2)
         target3 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
         target4 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state2)
         assert target4 == 1, 'EXPECTED FAILURE'
         if again_join:
             dst_mac = '01:00:5e:02:02:03'
             ip_dst = '239.2.2.3'
-            eth = Ether(dst = dst_mac, src = self.IGMP_SRC_MAC, type = ETH_P_IP)
-            ip = IP(dst = ip_dst, src = self.IP_SRC)
+            eth = Ether(dst = dst_mac,  type = ETH_P_IP)
+            ip = IP(dst = ip_dst)
             log.info('Interface sending join message again for the groups %s' %groups2)
             self.send_igmp_join(groups2, src_list = [src_ip], ip_pkt = eth/ip, iface = self.V_INF1, delay = 2)
             target5 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
@@ -550,31 +637,38 @@
 
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_2joins_1leave_functionality(self):
+    def test_igmp_2joins_1leave(self):
         df = defer.Deferred()
-        def test_igmp_2joins_1leave():
-              self.igmp_joins_leave_functionality(again_join = False, df = df)
+        def igmp_2joins_1leave():
+	      groups = ['234.2.3.4','236.8.7.9']
+	      src_list = ['2.3.4.5','5.4.3.2']
+	      self.onos_ssm_table_load(groups,src_list = src_list)
+              self.igmp_joins_leave(groups,src_list,again_join = False, df = df)
               df.callback(0)
-        reactor.callLater(0, test_igmp_2joins_1leave)
+        reactor.callLater(0, igmp_2joins_1leave)
         return df
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+25)
-    def test_igmp_2joins_1leave_again_joins_functionality(self):
+    def test_igmp_2joins_1leave_and_join_again(self):
         df = defer.Deferred()
-        def test_igmp_2joins_1leave_join_again():
-              self.igmp_joins_leave_functionality(again_join = True, df = df)
+        def igmp_2joins_1leave_join_again():
+	      groups = ['234.2.3.4','236.8.7.9']
+	      src_list = ['2.3.4.5','5.4.3.2']
+	      self.onos_ssm_table_load(groups,src_list = src_list)
+              self.igmp_joins_leave(groups,src_list,again_join = True, df = df)
               df.callback(0)
-        reactor.callLater(0, test_igmp_2joins_1leave_join_again)
+        reactor.callLater(0, igmp_2joins_1leave_join_again)
         return df
 
-    def igmp_not_in_src_list_functionality(self, df = None):
+    def igmp_not_in_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
+	self.onos_ssm_table_load(groups1 + groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','2.2.2.2', '5.5.5.5'])
         self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
                                                      (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
                                                       intf = self.V_INF1, delay = 2)
-        dst_mac = '01:00:5e:01:02:03'
         src_ip = '6.6.6.6'
+	dst_mac = self.iptomac(groups1[0])
         if df is None:
               df = defer.Deferred()
         igmpState1 = IGMPTestState(groups = groups1, df = df)
@@ -586,26 +680,27 @@
         log.info('Interface should not receive from multicast groups %s from an interface, which is expected' %groups1)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 2, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s, working as expected' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s, working as expected' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_not_in_src_list_functionality(self):
+    def test_igmp_not_in_src_list(self):
         df = defer.Deferred()
-        def igmp_not_in_src_list_functionality():
-              self.igmp_not_in_src_list_functionality(df = df)
+        def igmp_not_in_src_list():
+              self.igmp_not_in_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_not_in_src_list_functionality)
+        reactor.callLater(0, igmp_not_in_src_list)
         return df
 
-    def igmp_change_to_exclude_src_list_functionality(self, df = None):
-        groups1 = (self.MGROUP1,)
-        groups2 = (self.MGROUP2,)
+    def igmp_change_to_exclude_src_list(self, df = None):
+        groups1 = [self.random_mcast_ip()]
+        groups2 = [self.random_mcast_ip()]
+	self.onos_ssm_table_load(groups1 + groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','2.2.2.2', '5.5.5.5'])
         self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
                                                       (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
                                                       intf = self.V_INF1, delay = 2)
-        dst_mac = '01:00:5e:01:02:03'
         src_ip = '2.2.2.2'
+	dst_mac=self.iptomac(groups1[0])
         if df is None:
               df = defer.Deferred()
         igmpState1 = IGMPTestState(groups = groups1, df = df)
@@ -618,121 +713,126 @@
         self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2'], iface = self.V_INF1, delay =2)
         target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target2 == 2, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
-    def test_igmp_change_to_exclude_src_list_functionality(self):
+    def test_igmp_change_to_exclude_src_list(self):
         df = defer.Deferred()
-        def igmp_change_to_exclude_src_list_functionality():
-              self.igmp_change_to_exclude_src_list_functionality(df = df)
+        def igmp_change_to_exclude_src_list():
+              self.igmp_change_to_exclude_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_change_to_exclude_src_list_functionality)
+        reactor.callLater(0, igmp_change_to_exclude_src_list)
         return df
 
-    def igmp_include_to_allow_src_list_functionality(self, df = None):
-        groups1 = (self.MGROUP1,)
-        groups2 = (self.MGROUP2,)
-        self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
-                                                      (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
-                                                      intf = self.V_INF1, delay = 2)
-        dst_mac = '01:00:5e:01:02:03'
-        src_ip = '2.2.2.2'
+    def igmp_include_to_allow_src_list(self, df = None):
+        groups1 = [self.random_mcast_ip()] #(self.MGROUP1,)
+	self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
+	self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+        src_ip = '4.4.4.4'
         if df is None:
               df = defer.Deferred()
         igmpState1 = IGMPTestState(groups = groups1, df = df)
         igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
-        mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
-                                     src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
+        mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_ip,
+					cb = self.send_mcast_cb, arg = igmpState1)
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups1)
         target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
-                                                      (['2.2.2.2', '3.3.3.3', '4.4.4.4', '6.6.6.6'], ['2.2.2.2', '5.5.5.5']),
-                                                      intf = self.V_INF1, delay = 2)
+	mcastTraffic1.stop()
+	mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
+                                        cb = self.send_mcast_cb, arg = igmpState1)
+	self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
+                                         iface = self.V_INF1)
+	mcastTraffic2.start()
         target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        mcastTraffic1.stop()
+        mcastTraffic2.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
-    def test_igmp_include_to_allow_src_list_functionality(self):
+    def test_igmp_include_to_allow_src_list(self):
         df = defer.Deferred()
-        def igmp_include_to_allow_src_list_functionality():
-              self.igmp_include_to_allow_src_list_functionality(df = df)
+        def igmp_include_to_allow_src_list():
+              self.igmp_include_to_allow_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_include_to_allow_src_list_functionality)
+        reactor.callLater(0, igmp_include_to_allow_src_list)
         return df
 
-    def igmp_include_to_block_src_list_functionality(self, df = None):
-        groups1 = (self.MGROUP1,)
-        groups2 = (self.MGROUP2,)
-        self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
-                                                      (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
-                                                      intf = self.V_INF1, delay = 2)
-        dst_mac = '01:00:5e:01:02:03'
-        src_ip = '2.2.2.2'
+    def igmp_include_to_block_src_list(self, df = None):
+        groups1 = [self.random_mcast_ip()]   #groups1 = (self.MGROUP1,)
+	self.onos_ssm_table_load(groups1,src_list = ['4.4.4.4','6.6.6.6'])
+	self.send_igmp_join(groups = groups1, src_list = ['4.4.4.4','6.6.6.6'],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
         if df is None:
               df = defer.Deferred()
         igmpState1 = IGMPTestState(groups = groups1, df = df)
         igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
-        mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
-                                     src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
+        mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
+					cb = self.send_mcast_cb, arg = igmpState1)
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups1)
         target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        self.send_igmp_leave(groups = groups1, src_list = ['6.6.6.6','7.7.7.7'],
-                             iface = self.V_INF1, delay = 2)
-        target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
+	mcastTraffic1.stop()
+	self.send_igmp_join(groups = groups1, src_list = ['6.6.6.6'],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
+                                         iface = self.V_INF1)
+	mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = '6.6.6.6',
+                                        cb = self.send_mcast_cb, arg = igmpState1)
+	mcastTraffic2.start()
+        target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
+	assert target1 == 1, 'EXPECTED FAILURE'
         log.info('Interface is still receiving from old multicast group data %s even after we send block list' %groups1)
-        mcastTraffic1.stop()
+        mcastTraffic2.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+30)
-    def test_igmp_include_to_block_src_list_functionality(self):
+    def test_igmp_include_to_block_src_list(self):
         df = defer.Deferred()
-        def igmp_include_to_block_src_list_functionality():
-              self.igmp_include_to_block_src_list_functionality(df = df)
+        def igmp_include_to_block_src_list():
+              self.igmp_include_to_block_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_include_to_block_src_list_functionality)
+        reactor.callLater(0, igmp_include_to_block_src_list)
         return df
 
 
-    def igmp_change_to_include_src_list_functionality(self, df = None):
-        groups1 = (self.MGROUP1,)
-        groups2 = (self.MGROUP2,)
-        self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
+    def igmp_change_to_include_src_list(self, df = None):
+        groups1 = [self.random_mcast_ip()]
+	src_list = ['4.4.4.4','6.6.6.6']
+	self.onos_ssm_table_load(groups1,src_list = src_list)
+        self.send_igmp_leave(groups = groups1, src_list = src_list,
                              iface = self.V_INF1, delay = 2)
-
-        dst_mac = '01:00:5e:01:02:03'
-        src_ip = '2.2.2.2'
         if df is None:
               df = defer.Deferred()
         igmpState1 = IGMPTestState(groups = groups1, df = df)
         igmpStateRecv1 = IGMPTestState(groups = groups1, df = df)
-        mcastTraffic1 = McastTraffic(groups1, iface= 'veth2', dst_mac = dst_mac,
-                                     src_ip = src_ip, cb = self.send_mcast_cb, arg = igmpState1)
+        mcastTraffic1 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[0],
+                                          cb = self.send_mcast_cb, arg = igmpState1)
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups1)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
-        self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
-                                                      (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
-                                                      intf = self.V_INF1, delay = 2)
-        target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1)
-        mcastTraffic1.stop()
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
+	mcastTraffic1.stop()
+        self.send_igmp_join(groups = groups1, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+        mcastTraffic2 = McastTraffic(groups1, iface= 'veth2',src_ip = src_list[1],
+                                        cb = self.send_mcast_cb, arg = igmpState1)
+        mcastTraffic2.start()
+        target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
+        mcastTraffic2.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
-    def test_igmp_change_to_include_src_list_functionality(self):
+    def test_igmp_change_to_include_src_list(self):
         df = defer.Deferred()
-        def igmp_change_to_include_src_list_functionality():
-              self.igmp_change_to_include_src_list_functionality(df = df)
+        def igmp_change_to_include_src_list():
+              self.igmp_change_to_include_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_change_to_include_src_list_functionality)
+        reactor.callLater(0, igmp_change_to_include_src_list)
         return df
 
-    def igmp_exclude_to_allow_src_list_functionality(self, df = None):
+    #this test case failing because group in include receiving multicast traffic from any of the source
+    def igmp_exclude_to_allow_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
+	self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','6.6.6.6', '7.7.7.7', '8.8.8.8','5.5.5.5'])
         self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
                              iface = self.V_INF1, delay = 2)
 
@@ -748,27 +848,28 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
                                                       (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),
                                                       intf = self.V_INF1, delay = 2)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
-    def test_igmp_exclude_to_allow_src_list_functionality(self):
+    def test_igmp_exclude_to_allow_src_list(self):
         df = defer.Deferred()
-        def igmp_exclude_to_allow_src_list_functionality():
-              self.igmp_exclude_to_allow_src_list_functionality(df = df)
+        def igmp_exclude_to_allow_src_list():
+              self.igmp_exclude_to_allow_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_exclude_to_allow_src_list_functionality)
+        reactor.callLater(0, igmp_exclude_to_allow_src_list)
         return df
 
-    def igmp_exclude_to_block_src_list_functionality(self, df = None):
+    def igmp_exclude_to_block_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
+	self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','7.7.7.7','5.5.5.5'])
         self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4'],
                              iface = self.V_INF1, delay = 2)
 
@@ -784,26 +885,28 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.send_igmp_leave(groups = groups1, src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
                              iface = self.V_INF1, delay = 2)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
-    def test_igmp_exclude_to_block_src_list_functionality(self):
+    def test_igmp_exclude_to_block_src_list(self):
         df = defer.Deferred()
-        def igmp_exclude_to_block_src_list_functionality():
-              self.igmp_exclude_to_block_src_list_functionality(df = df)
+        def igmp_exclude_to_block_src_list():
+              self.igmp_exclude_to_block_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_exclude_to_block_src_list_functionality)
+        reactor.callLater(0, igmp_exclude_to_block_src_list)
         return df
 
-    def igmp_new_src_list_functionality(self, df = None):
+    #this test case failing because group in include mode recieves traffic from other sources also.
+    def igmp_new_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
+	self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6'])
         self.igmp_send_joins_different_groups_srclist(groups1+groups2,
                                                       (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
                                                       intf = self.V_INF1, delay = 2)
@@ -819,27 +922,28 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.igmp_send_joins_different_groups_srclist(groups1 + groups2,
                                                       (['2.2.2.2', '6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
                                                       intf = self.V_INF1, delay = 2)
         target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1)
+        log.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+10)
-    def test_igmp_new_src_list_functionality(self):
+    def test_igmp_new_src_list(self):
         df = defer.Deferred()
-        def igmp_new_src_list_functionality():
-              self.igmp_new_src_list_functionality(df = df)
+        def igmp_new_src_list():
+              self.igmp_new_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_new_src_list_functionality)
+        reactor.callLater(0, igmp_new_src_list)
         return df
 
-    def igmp_block_old_src_list_functionality(self, df = None):
+    def igmp_block_old_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
+	self.onos_ssm_table_load(groups1+groups2,src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4','5.5.5.5','6.6.6.6','7.7.7.7'])
         self.igmp_send_joins_different_groups_srclist(groups,
                                                       (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
                                                       intf = self.V_INF1, delay = 2)
@@ -854,25 +958,25 @@
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
-        log.info('Interface is receiving from multicast groups %s' %groups2)
+        log.info('Interface is receiving traffic from multicast groups %s' %groups2)
         self.igmp_send_joins_different_groups_srclist(groups,
                                                       (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
                                                       intf = self.V_INF1, delay = 2)
         target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target2 == 2, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s after sending join with block old source list' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_block_old_src_list_functionality(self):
+    def test_igmp_block_old_src_list(self):
         df = defer.Deferred()
-        def igmp_block_old_src_list_functionality():
-              self.igmp_block_old_src_list_functionality(df = df)
+        def igmp_block_old_src_list():
+              self.igmp_block_old_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_block_old_src_list_functionality)
+        reactor.callLater(0, igmp_block_old_src_list)
         return df
 
-    def igmp_include_empty_src_list_functionality(self, df = None):
+    def igmp_include_empty_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -891,20 +995,20 @@
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target1==1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s when we sent join with source list is empty' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s when we sent join with source list is empty' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def ztest_igmp_include_empty_src_list_functionality(self):
+    def test_igmp_include_empty_src_list(self):
         ## '''Disabling this test as scapy IGMP doesn't work with empty source lists'''
         df = defer.Deferred()
-        def igmp_include_empty_src_list_functionality():
-              self.igmp_include_empty_src_list_functionality(df = df)
+        def igmp_include_empty_src_list():
+              self.igmp_include_empty_src_list(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_include_empty_src_list_functionality)
+        reactor.callLater(0, igmp_include_empty_src_list)
         return df
 
-    def igmp_exclude_empty_src_list_functionality(self, df = None):
+    def igmp_exclude_empty_src_list(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -924,15 +1028,15 @@
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def ztest_igmp_exclude_empty_src_list_functionality(self):
+    def test_igmp_exclude_empty_src_list(self):
         df = defer.Deferred()
-        def igmp_exclude_empty_src_list_functionality():
-              self.igmp_exclude_empty_src_list_functionality()
+        def igmp_exclude_empty_src_list():
+              self.igmp_exclude_empty_src_list()
               df.callback(0)
-        reactor.callLater(0, igmp_exclude_empty_src_list_functionality)
+        reactor.callLater(0, igmp_exclude_empty_src_list)
         return df
 
-    def igmp_join_sourceip_0_0_0_0_functionality(self, df = None):
+    def igmp_join_sourceip_0_0_0_0(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -952,19 +1056,19 @@
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
-        log.info('Interface is receiving from multicast groups %s when we sent join with source IP  is 0.0.0.0' %groups2)
+        log.info('Interface is receiving traffic from multicast groups %s when we sent join with source IP  is 0.0.0.0' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_join_sourceip_0_0_0_0_functionality(self):
+    def test_igmp_join_sourceip_0_0_0_0(self):
         df = defer.Deferred()
-        def igmp_join_sourceip_0_0_0_0_functionality():
-              self.igmp_join_sourceip_0_0_0_0_functionality(df = df)
+        def igmp_join_sourceip_0_0_0_0():
+              self.igmp_join_sourceip_0_0_0_0(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_join_sourceip_0_0_0_0_functionality)
+        reactor.callLater(0, igmp_join_sourceip_0_0_0_0)
         return df
 
-    def igmp_invalid_join_packet_functionality(self, df = None):
+    def igmp_invalid_join_packet(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MINVALIDGROUP1,)
         groups = groups1 + groups2
@@ -985,19 +1089,19 @@
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target1==1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_invalid_join_packet_functionality(self):
+    def test_igmp_invalid_join_packet(self):
         df = defer.Deferred()
-        def igmp_invalid_join_packet_functionality():
-              self.igmp_invalid_join_packet_functionality(df = df)
+        def igmp_invalid_join_packet():
+              self.igmp_invalid_join_packet(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_invalid_join_packet_functionality)
+        reactor.callLater(0, igmp_invalid_join_packet)
         return df
 
-    def igmp_join_data_receiving_during_subscriber_link_down_up_functionality(self, df = None):
+    def igmp_join_data_receiving_during_subscriber_link_toggle(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -1017,7 +1121,7 @@
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
-        log.info('Interface is receiving from multicast groups,  before bring down the self.V_INF1=%s  ' %self.V_INF1)
+        log.info('Interface is receiving traffic from multicast groups,  before bring down the self.V_INF1=%s  ' %self.V_INF1)
         os.system('ifconfig '+self.V_INF1+' down')
         log.info(' the self.V_INF1 %s is down now  ' %self.V_INF1)
         os.system('ifconfig '+self.V_INF1)
@@ -1026,19 +1130,19 @@
         os.system('ifconfig '+self.V_INF1)
         log.info(' the self.V_INF1 %s is up now  ' %self.V_INF1)
         target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
-        log.info('Interface is receiving from multicast groups %s when we bringup interface up after down  ' %groups2)
+        log.info('Interface is receiving traffic from multicast groups %s when we nterface up after down  ' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_join_data_receiving_during_subscriber_link_up_down_functionality(self):
+    def test_igmp_join_data_received_during_subscriber_link_toggle(self):
         df = defer.Deferred()
-        def igmp_join_data_receiving_during_subscriber_link_up_down_functionality():
-              self.igmp_join_data_receiving_during_subscriber_link_down_up_functionality(df = df)
+        def igmp_join_data_received_during_subscriber_link_toggle():
+              self.igmp_join_data_received_during_subscriber_link_toggle(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_join_data_receiving_during_subscriber_link_down_up_functionality)
+        reactor.callLater(0, igmp_join_data_received_during_subscriber_link_toggle)
         return df
 
-    def igmp_join_data_receiving_during_channel_distributor_link_up_down_functionality(self, df = None):
+    def igmp_join_data_received_during_channel_distributor_link_toggle(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -1067,42 +1171,34 @@
         join_state2 = IGMPTestState(groups = groups2)
         target1 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
         target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
-        log.info('Interface is receiving from multicast groups,  before bring down the veth2 and subscriber link is self.V_INF1=%s up ' %self.V_INF1)
         mcastTraffic1.stop()
         os.system('ifconfig '+'veth2'+' down')
-        log.info(' the channel distributor interface veth2 is down now  ' )
         os.system('ifconfig '+'veth2')
         time.sleep(10)
-        log.info('Verifying interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2)
         target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
-        log.info('Verified that interface is still receiving a multicast groups2 %s traffic even though other group traffic sending interface goes down' %groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1==1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups1 %s when we shutdown the subscriber interface ' %groups1)
         os.system('ifconfig '+'veth2'+' up')
         os.system('ifconfig '+'veth2')
-        log.info(' the channel distributor interface veth2 is up now  ')
         time.sleep(10)
         mcastTraffic1.start()
-        log.info('Verifying interface is receiving from both multicast groups data %s when we bringup interface up after down  ' %groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
         target2 = self.igmp_recv_task(self.V_INF1, groups2, join_state2)
-        log.info('Interface is receiving from multicast groups %s when we bringup interface up after down  ' %groups2)
         mcastTraffic2.stop()
 
     ##  This test case is failing to receive traffic from multicast data from defferent channel interfaces TO-DO
     ###### TO DO scenario #######
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
-    def test_igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(self):
+    def test_igmp_join_data_received_during_channel_distributors_link_toggle(self):
         df = defer.Deferred()
-        def igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality():
-              self.igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality(df = df)
+        def igmp_join_data_receiving_during_channel_distributor_link_toggle():
+              self.igmp_join_data_receiving_during_channel_distributor_link_toggle(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_down_up_functionality)
+        reactor.callLater(0, igmp_join_data_receiving_during_channel_distributor_link_toggle)
         return df
 
-    def igmp_invalidClassD_IP_join_packet_functionality(self, df = None):
+    def igmp_invalidClassD_IP_join_packet(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MINVALIDGROUP2,)
         groups = groups1 + groups2
@@ -1123,19 +1219,19 @@
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target1==1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_invalidClassD_IP_join_packet_functionality(self):
+    def test_igmp_invalid_class_d_ip_for_join_packet(self):
         df = defer.Deferred()
-        def igmp_invalidClass_D_IP_join_packet_functionality():
-              self.igmp_invalidClass_D_IP_join_packet_functionality(df = df)
+        def igmp_invalidClass_D_IP_join_packet():
+              self.igmp_invalidClass_D_IP_join_packet(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_invalidClassD_IP_join_packet_functionality)
+        reactor.callLater(0, igmp_invalidClassD_IP_join_packet)
         return df
 
-    def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self, df = None):
+    def igmp_invalidClassD_IP_as_srclistIP_join_packet(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -1156,19 +1252,19 @@
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target1==1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s when we sent invalid join packet ' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s when we sent invalid join packet ' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+20)
-    def test_igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(self):
+    def test_igmp_invalid_class_d_ip_as_srclist_ip_for_join_packet(self):
         df = defer.Deferred()
-        def igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality():
-              self.igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality(df = df)
+        def igmp_invalidClassD_IP_as_srclistIP_join_packet():
+              self.igmp_invalidClassD_IP_as_srclistIP_join_packet(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet_functionality)
+        reactor.callLater(0, igmp_invalidClassD_IP_as_srclistIP_join_packet)
         return df
 
-    def igmp_general_query_recv_packet_functionality(self, df = None):
+    def igmp_general_query_recv_packet(self, df = None):
         groups1 = (self.MGROUP1,)
         groups2 = (self.MGROUP2,)
         groups = groups1 + groups2
@@ -1203,23 +1299,23 @@
         target3 = mcastTraffic1.isRecvStopped()
         assert target3==False, 'EXPECTED FAILURE'
         log.info('Verified that multicast data for a group %s is still transmitting from a data interface' %groups2)
-        log.info('Now checking joining interface is receiving a multicast data for group %s after 190 sec' %groups2)
+        log.info('Now checking join interface is receiving a multicast data for group %s after 190 sec' %groups2)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target1==1, 'EXPECTED FAILURE'
         log.info('Interface is not receiving multicast data for group %s' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+250)
-    def test_igmp_general_query_recv_packet_traffic_functionality(self):
+    def test_igmp_general_query_received_traffic(self):
         df = defer.Deferred()
-        def igmp_general_query_recv_packet_functionality():
-              self.igmp_general_query_recv_packet_functionality(df = df)
+        def igmp_general_query_recv_packet():
+              self.igmp_general_query_recv_packet(df = df)
               df.callback(0)
-        reactor.callLater(0, igmp_general_query_recv_packet_functionality)
+        reactor.callLater(0, igmp_general_query_recv_packet)
         return df
 
-    @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
-    def test_igmp_query_packet_received_on_joining_interface(self):
+    @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+100)
+    def test_igmp_query_received_on_joining_interface(self):
         groups = ['224.0.1.10', '225.0.0.10']
         leave_groups = ['224.0.1.10']
         df = defer.Deferred()
@@ -1243,16 +1339,16 @@
                 self.igmp_verify_leave(stateList, leave_groups)
                 self.df.callback(0)
 
-        log.info('Sending join packet and expected to receive on egeneral query packet after 60 sec for multicast %s ' %groups)
+        log.info('Sending join packet and expect to receive on general query packet after 60 sec for multicast %s ' %groups)
         self.send_igmp_join_recvQuery(groups)
-        log.info('Received a egeneral query packet for multicast %s group on joing interface and sending traffic' %groups)
+        log.info('Received a general query packet for multicast %s group on joing interface and sending traffic' %groups)
         mcastTraffic.start()
         self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
         reactor.callLater(0, igmp_srp_task, igmpStateList)
         return df
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
-    def test_igmp_periodic_query_packet_received_on_joining_interface(self):
+    def test_igmp_for_periodic_query_received_on_joining_interface(self):
         groups = ['224.0.1.10', '225.0.0.10']
         leave_groups = ['224.0.1.10']
         df = defer.Deferred()
@@ -1280,7 +1376,7 @@
         return df
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
-    def test_igmp_periodic_query_packet_received_and_checking_entry_deleted(self):
+    def test_igmp_for_periodic_query_received_and_checking_entry_deleted(self):
         groups = ['224.0.1.10', '225.0.0.10']
         leave_groups = ['224.0.1.10']
         df = defer.Deferred()
@@ -1305,14 +1401,14 @@
                 self.df.callback(0)
 
         self.send_igmp_join_recvQuery(groups,3)
-        log.info('Received periodic egeneral query packets for multicast %s, now checking entry is deleted from tabel by sending traffic for that group' %groups)
+        log.info('Received periodic general query packets for multicast %s, now checking entry is deleted from tabel by sending traffic for that group' %groups)
         mcastTraffic.start()
         self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
         reactor.callLater(0, igmp_srp_task, igmpStateList)
         return df
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+190)
-    def test_igmp_member_query_interval_expire_re_joining_interface(self):
+    def test_igmp_member_query_interval_and_expiry_for_rejoining_interface(self):
         groups = ['224.0.1.10', '225.0.0.10']
         leave_groups = ['224.0.1.10']
         df = defer.Deferred()
@@ -1337,7 +1433,7 @@
                 self.df.callback(0)
 
         self.send_igmp_join_recvQuery(groups,3)
-        log.info('Received periodic egeneral query packets for multicast %s, now sending join packet again and verifying traffic for that group is received or not on joining interface' %groups)
+        log.info('Received periodic general query packets for multicast %s, now sending join packet again and verifying traffic for that group is received or not on joining interface' %groups)
         self.send_igmp_join(groups)
         mcastTraffic.start()
         self.test_timer = reactor.callLater(self.MCAST_TRAFFIC_TIMEOUT, self.mcast_traffic_timer)
@@ -1345,7 +1441,7 @@
         return df
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+50)
-    def test_igmp_leave_verify_received_group_source_specific_query(self):
+    def test_igmp_leave_received_group_and_source_specific_query(self):
         groups = ['224.0.1.10', '225.0.0.10']
         leave_groups = ['224.0.1.10']
         df = defer.Deferred()
@@ -1394,11 +1490,11 @@
         time.sleep(10)
         target2 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target2 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s after sending CHANGE_TO_EXCLUDE' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+60)
-    def test_igmp_change_to_exclude_src_list_check_for_group_source_specific_query(self):
+    def test_igmp_change_to_exclude_src_list_and_check_for_group_source_specific_query(self):
         df = defer.Deferred()
         def igmp_change_to_exclude_src_list_check_for_group_source_specific_query():
               self.igmp_change_to_exclude_src_list_check_for_group_source_specific_query(df = df)
@@ -1423,17 +1519,17 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
                                                    (['2.2.2.2', '3.3.3.3', '4.4.4.4'], ['6.6.6.6', '5.5.5.5']),
                                                     intf = self.V_INF1, delay = 2,query_group1 = 'group1', query_group2 = None)
         time.sleep(10)
         target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        log.info('Interface is receiving from multicast groups %s after send Change to include message' %groups1)
+        log.info('Interface is receiving traffic from multicast groups %s after send Change to include message' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
-    def test_igmp_change_to_include_src_list_check_for_general_query(self):
+    def test_igmp_change_to_include_src_list_and_check_for_general_query(self):
         df = defer.Deferred()
         def igmp_change_to_include_src_list_check_for_general_query():
               self.igmp_change_to_include_src_list_check_for_general_query(df = df)
@@ -1459,15 +1555,15 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1 = self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         #assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,                                                                              (['2.2.2.2', '6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '5.5.5.5']),
                                               intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
         target2 = self.igmp_recv_task(self.V_INF1, groups1, join_state1)
-        log.info('Interface is receiving from multicast groups %s after sending join with new source list' %groups1)
+        log.info('Interface is receiving traffic from multicast groups %s after sending join with new source list' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+80)
-    def test_igmp_allow_new_src_list_check_for_general_query(self):
+    def test_igmp_allow_new_src_list_and_check_for_general_query(self):
         df = defer.Deferred()
         def igmp_allow_new_src_list_check_for_general_query():
               self.igmp_allow_new_src_list_check_for_general_query(df = df)
@@ -1493,17 +1589,17 @@
         mcastTraffic1.start()
         join_state1 = IGMPTestState(groups = groups2)
         target1 = self.igmp_recv_task(self.V_INF1, groups2, join_state1)
-        log.info('Interface is receiving from multicast groups %s' %groups2)
+        log.info('Interface is receiving traffic from multicast groups %s' %groups2)
         self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups,
                                                 (['6.6.6.6', '3.3.3.3', '4.4.4.4'], ['2.2.2.2', '7.7.7.7']),
                                                 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
         target2 = self.igmp_not_recv_task(self.V_INF1, groups2, join_state1)
         assert target2 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s after sending join with block old source list' %groups2)
+        log.info('Interface is not receiving traffic from multicast groups %s after sending join with block old source list' %groups2)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
-    def test_igmp_block_old_src_list_check_for_group_source_specific_query(self):
+    def test_igmp_block_old_src_list_and_check_for_group_source_specific_query(self):
         df = defer.Deferred()
         def igmp_block_old_src_list_check_for_group_source_specific_query():
               self.igmp_block_old_src_list_check_for_group_source_specific_query(df = df)
@@ -1533,7 +1629,7 @@
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
-    def test_igmp_include_to_allow_src_list_check_for_general_query(self):
+    def test_igmp_include_to_allow_src_list_and_check_for_general_query(self):
         df = defer.Deferred()
         def igmp_include_to_allow_src_list_check_for_general_query():
               self.igmp_include_to_allow_src_list_check_for_general_query(df = df)
@@ -1564,7 +1660,7 @@
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
-    def test_igmp_include_to_block_src_list_check_for_group_source_specific_query(self):
+    def test_igmp_include_to_block_src_list_and_check_for_group_source_specific_query(self):
         df = defer.Deferred()
         def igmp_include_to_block_src_list_check_for_group_source_specific_query():
               self.igmp_include_to_block_src_list_check_for_group_source_specific_query(df = df)
@@ -1590,16 +1686,16 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.igmp_send_joins_different_groups_srclist_wait_query_packets(groups1 + groups2,
                                              (['6.6.6.6', '7.7.7.7', '8.8.8.8'], ['6.6.6.6', '5.5.5.5']),                                                                 intf = self.V_INF1, delay = 2, query_group1 = 'group1', query_group2 = None)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+90)
-    def test_igmp_exclude_to_allow_src_list_check_for_general_query(self):
+    def test_igmp_exclude_to_allow_src_list_and_check_for_general_query(self):
         df = defer.Deferred()
         def igmp_exclude_to_allow_src_list_check_for_general_query():
               self.igmp_exclude_to_allow_src_list_check_for_general_query(df = df)
@@ -1625,20 +1721,425 @@
         join_state1 = IGMPTestState(groups = groups1)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         self.send_igmp_leave_listening_group_specific_query(groups = groups1,
                                           src_list = ['2.2.2.2', '3.3.3.3', '4.4.4.4', '5.5.5.5', '7.7.7.7'],
                                           iface = self.V_INF1, delay = 2)
         target1= self.igmp_not_recv_task(self.V_INF1, groups1, join_state1)
         assert target1 == 1, 'EXPECTED FAILURE'
-        log.info('Interface is not receiving from multicast groups %s' %groups1)
+        log.info('Interface is not receiving traffic from multicast groups %s' %groups1)
         mcastTraffic1.stop()
 
     @deferred(timeout=MCAST_TRAFFIC_TIMEOUT+40)
-    def test_igmp_exclude_to_block_src_list_check_for_group_source_specific_query(self):
+    def test_igmp_exclude_to_block_src_list_and_check_for_group_source_specific_query(self):
         df = defer.Deferred()
         def igmp_exclude_to_block_src_list_check_for_group_source_specific_query():
               self.igmp_exclude_to_block_src_list_check_for_group_source_specific_query(df = df)
               df.callback(0)
         reactor.callLater(0, igmp_exclude_to_block_src_list_check_for_group_source_specific_query)
         return df
+
+    def iptomac(self, mcast_ip):
+        mcast_mac =  '01:00:5e:'
+        octets = mcast_ip.split('.')
+        second_oct = int(octets[1]) & 127
+        third_oct = int(octets[2])
+        fourth_oct = int(octets[3])
+        mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
+        return mcast_mac
+
+    def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
+        dst_mac = self.iptomac(group)
+        eth = Ether(dst= dst_mac)
+        ip = IP(dst=group,src=source)
+        data = repr(monotonic.monotonic())
+        sendp(eth/ip/data,count=20, iface = intf)
+        pkt = (eth/ip/data)
+        #log.info('multicast traffic packet %s'%pkt.show())
+
+    def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
+        log.info('verifying multicast traffic for group %s from source %s'%(group,source))
+        self.success = False
+        def recv_task():
+            def igmp_recv_cb(pkt):
+                #log.info('received multicast data packet is %s'%pkt.show())
+                log.info('multicast data received for group %s from source %s'%(group,source))
+                self.success = True
+            sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group and p[IP].src == source, count=1,timeout = 2, iface='veth0')
+        t = threading.Thread(target = recv_task)
+        t.start()
+        self.send_multicast_data_traffic(group,source=source)
+        t.join()
+        return self.success
+
+    def test_igmp_include_exclude_modes(self):
+        groups = ['224.2.3.4','230.5.6.7']
+        src_list = ['2.2.2.2','3.3.3.3']
+        dst_mac1 = self.iptomac(groups[0])
+        dst_mac2 =  self.iptomac(groups[1])
+        self.onos_ssm_table_load(groups, src_list=src_list)
+        self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 2)
+        self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
+                             iface = self.V_INF1, delay = 2)
+        status = self.verify_igmp_data_traffic(groups[0],intf=self.V_INF1,source=src_list[0])
+        assert_equal(status,True)
+        status = self.verify_igmp_data_traffic(groups[1],intf = self.V_INF1,source= src_list[1])
+        assert_equal(status,False)
+
+    def test_igmp_allow_new_source_mode(self):
+        group = ['224.8.9.3']
+        src_list = ['2.2.2.2','3.3.3.3']
+        #dst_mac = self.iptomac(group[0])
+        self.onos_ssm_table_load(group, src_list)
+        self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        status = self.verify_igmp_data_traffic(group[0], intf=self.V_INF1,source = src_list[0])
+        assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
+        self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_ALLOW_NEW,
+                            iface = self.V_INF1, delay = 1)
+        for src in src_list:
+            status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
+            assert_equal(status,True) # expecting igmp data traffic from both sources
+
+
+    def test_igmp_include_to_exclude_mode_change(self):
+        group = ['224.2.3.4']
+        src_list = ['2.2.2.2','3.3.3.3']
+        dst_mac = self.iptomac(group[0])
+        self.onos_ssm_table_load(group, src_list)
+        self.send_igmp_join(groups = group, src_list = src_list[0],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src_list[0])
+        assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
+        self.send_igmp_join(groups = group, src_list = src_list[1],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
+                           iface = self.V_INF1, delay = 1)
+        for src in src_list:
+            status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
+            assert_equal(status,False) # expecting igmp data traffic from both sources
+
+    def test_igmp_exclude_to_include_mode_change(self):
+        group = ['224.2.3.4']
+        src = ['2.2.2.2']
+        dst_mac = self.iptomac(group[0])
+        self.onos_ssm_table_load(group, src)
+        self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_EXCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
+        assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
+        self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source = src[0])
+        assert_equal(status,True) # expecting igmp data traffic from both sources
+
+    #this test case wotks properly if the snooping device(ONOS) have multicast router connected.
+    def test_igmp_to_include_mode_with_null_source(self):
+        groups = ['224.2.3.4','230.7.9.8']
+        src = ['192.168.12.34']
+        dst_mac = []
+        dst_mac.append(self.iptomac(groups[0]))
+        dst_mac.append(self.iptomac(groups[1]))
+        self.onos_ssm_table_load(groups, src)
+        self.send_igmp_join(groups = groups, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        for grp in groups:
+            status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
+            assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
+        #sending leave packet for group groups[1]
+        self.send_igmp_join(groups = [groups[1]], src_list = [],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        for grp in groups:
+            status = self.verify_igmp_data_traffic(grp,intf=self.V_INF1,source= src[0])
+            if grp is groups[0]:
+                assert_equal(status,True) # expecting igmp data traffic to group groups[0]
+            else:
+                assert_equal(status,False) # not expecting igmp data traffic to group groups[1]
+
+    def test_igmp_to_include_mode(self):
+        group = ['229.9.3.6']
+        src_list = ['192.168.12.34','192.18.1.34']
+        dst_mac = []
+        dst_mac = self.iptomac(group[0])
+        self.onos_ssm_table_load(group, src_list)
+        self.send_igmp_join(groups = group, src_list = [src_list[0]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src_list[0])
+        assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
+        self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_CHANGE_TO_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        for src in src_list:
+            status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source= src)
+            assert_equal(status,True) # expecting igmp data traffic to group groups[0]
+
+    #this test case passed only if mulitcast router connected to ONOS.
+    def test_igmp_blocking_old_source_mode(self):
+        group = ['224.2.3.4']
+        src_list = ['2.2.2.2','3.3.3.3']
+        dst_mac = self.iptomac(group[0])
+        self.onos_ssm_table_load(group, src_list)
+        self.send_igmp_join(groups = group, src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        for src in src_list:
+            status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
+            assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
+        self.send_igmp_join(groups = group, src_list = [src_list[1]],record_type = IGMP_V3_GR_TYPE_BLOCK_OLD,
+                             iface = self.V_INF1, delay = 1)
+        for src in src_list:
+            status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1, source=src)
+            if src is src_list[0]:
+                assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
+            else:
+                assert_equal(status,False) # not expecting igmp data traffic from source src_list[1]
+
+    def test_igmp_multiple_joins_and_data_verification_with_100_groups(self):
+        groups = []
+	sources = []
+	count = 1
+	mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
+	sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
+        while count<=100:
+            group = random.choice(mcastips)
+            source = random.choice(sourceips)
+	    if group in groups:
+		pass
+	    else:
+		log.info('group and source are %s and %s'%(group,source))
+		groups.append(group)
+                sources.append(source)
+		count += 1
+	self.onos_ssm_table_load(groups,src_list=sources,flag=True)
+	for i in range(100):
+	    self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+            status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+            assert_equal(status, True)
+	    log.info('data received for group %s from source %s'%(groups[i],sources[i]))
+
+    def test_igmp_multiple_joins_with_data_verification_and_leaving_100_groups(self):
+        groups = []
+        sources = []
+        count = 1
+        mcastips = self.mcast_ip_range(start_ip = '226.0.0.1',end_ip = '226.0.5.254')
+        sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.5.254')
+        while count<=100:
+            group = random.choice(mcastips)
+            source = random.choice(sourceips)
+            if group in groups:
+                pass
+            else:
+                log.info('group and source are %s and %s'%(group,source))
+                groups.append(group)
+                sources.append(source)
+                count += 1
+        self.onos_ssm_table_load(groups,src_list=sources,flag=True)
+        for i in range(100):
+            self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+            status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+            assert_equal(status, True)
+            log.info('data received for group %s from source %s'%(groups[i],sources[i]))
+	    self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_CHANGE_TO_EXCLUDE,
+                                         iface = self.V_INF1, delay = 1)
+	    status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+            assert_equal(status, False)
+            log.info("data not received for group %s from source %s after changing group mode to 'TO-EXCLUDE' mode"%(groups[i],sources[i]))
+
+    def test_igmp_group_source_for_only_config_with_1000_entries(self):
+        groups = []
+        sources = []
+        count = 1
+        mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.50.254')
+        sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.50.254')
+        while count<=1000:
+            group = random.choice(mcastips)
+            source = random.choice(sourceips)
+            if group in groups:
+                pass
+            else:
+                log.info('group and source are %s and %s'%(group,source))
+                groups.append(group)
+                sources.append(source)
+                count += 1
+	self.onos_ssm_table_load(groups,src_list=sources,flag=True)
+
+    def test_igmp_from_exclude_to_include_mode_with_100_groups(self):
+        groups = []
+        sources = []
+        count = 1
+        mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.10.254')
+        sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.10.254')
+        while count<=100:
+            group = random.choice(mcastips)
+            source = random.choice(sourceips)
+            if group in groups:
+                pass
+            else:
+                log.info('group and source are %s and %s'%(group,source))
+                groups.append(group)
+                sources.append(source)
+                count += 1
+        self.onos_ssm_table_load(groups,src_list=sources,flag=True)
+        for i in range(100):
+            self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_EXCLUDE,
+                                         iface = self.V_INF1)
+            status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+            assert_equal(status, False)
+	    log.info('data not received for group %s from source %s as expected'%(groups[i],sources[i]))
+	    self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+	    status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+	    assert_equal(status, True)
+            log.info("data received for group %s from source %s after changing group mode to 'TO-INCLUDE' mode"%(groups[i],sources[i]))
+
+    def test_igmp_with_multiple_joins_and_data_verify_with_1000_groups(self):
+        groups = []
+        sources = []
+        count = 1
+        mcastips = self.mcast_ip_range(start_ip = '229.0.0.1',end_ip = '229.0.30.254')
+        sourceips = self.source_ip_range(start_ip = '10.10.0.1',end_ip = '10.10.30.254')
+        while count<=1000:
+            group = random.choice(mcastips)
+            source = random.choice(sourceips)
+            if group in groups:
+                pass
+            else:
+                log.info('group and source are %s and %s'%(group,source))
+                groups.append(group)
+                sources.append(source)
+                count += 1
+        self.onos_ssm_table_load(groups,src_list=sources,flag=True)
+        for i in range(1000):
+            self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+            status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+            assert_equal(status, True)
+            log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
+
+    def test_igmp_with_multiple_joins_and_data_verify_with_5000_groups(self):
+        groups = []
+        sources = []
+        count = 1
+        mcastips = self.mcast_ip_range(start_ip = '231.39.19.121',end_ip = '231.40.30.25')
+        sourceips = self.source_ip_range(start_ip = '192.168.56.43',end_ip = '192.169.110.30')
+        while count<=5000:
+            group = random.choice(mcastips)
+            source = random.choice(sourceips)
+            if group in groups:
+                pass
+            else:
+                log.info('group and source are %s and %s'%(group,source))
+                groups.append(group)
+                sources.append(source)
+                count += 1
+        self.onos_ssm_table_load(groups,src_list=sources,flag=True)
+        for i in range(5000):
+            self.send_igmp_join(groups = [groups[i]], src_list = [sources[i]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                                         iface = self.V_INF1)
+            status = self.verify_igmp_data_traffic(groups[i],intf=self.V_INF1,source=sources[i])
+            assert_equal(status, True)
+            log.info('data received for group %s from source %s - %d'%(groups[i],sources[i],i))
+
+    """def test_igmp_join_from_multiple_infts(self):
+        groups = ['229.9.3.6','234.20.56.2']
+        src_list = ['192.168.12.34','192.18.1.34']
+        self.onos_ssm_table_load(groups, src_list=src_list)
+        self.send_igmp_join(groups = [groups[0]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = 'veth0')
+	self.send_igmp_join(groups = [groups[1]], src_list = src_list,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = 'veth2')
+        status = self.verify_igmp_data_traffic(groups[0],intf='veth0',source=src_list[0])
+	assert_equal(status,True)
+	status = self.verify_igmp_data_traffic(groups[1],intf='veth2',source=src_list[1])
+        assert_equal(status,True) # not expecting igmp data traffic from source src_list[0]
+    """
+
+    def test_igmp_send_data_to_non_registered_group(self):
+        group = ['224.2.3.4']
+        src = ['2.2.2.2']
+        self.onos_ssm_table_load(group,src_list= src)
+        self.send_igmp_join(groups = ['239.0.0.1'], src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1, delay = 1)
+        status = self.verify_igmp_data_traffic('239.0.0.1',intf=self.V_INF1,source=src[0])
+        assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
+
+    def test_igmp_traffic_verification_for_registered_group_with_no_join_sent(self):
+        group = ['227.12.3.40']
+        src = ['190.4.19.67']
+        self.onos_ssm_table_load(group,src_list= src)
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
+        assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
+
+    def test_igmp_toggling_app_activation(self):
+        group = [self.random_mcast_ip()]
+        src = [self.randomsourceip()]
+        self.onos_ssm_table_load(group,src_list= src)
+	self.send_igmp_join(groups = group, src_list = src,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1)
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
+        assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
+	log.info('Multicast traffic received for group %s from source %s before the app is deactivated'%(group[0],src[0]))
+	self.onos_ctrl.deactivate()
+	status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
+        assert_equal(status,False) #not expecting igmp data traffic from source src_list[0]
+	log.info('Multicast traffic not received for group %s from source %s after the app is deactivated'%(group[0],src[0]))
+	self.onos_ctrl.activate()
+        status = self.verify_igmp_data_traffic(group[0],intf=self.V_INF1,source=src[0])
+        assert_equal(status,True) # expecting igmp data traffic from source src_list[0]
+	log.info('Multicast traffic received for group %s from source %s the app is re-activated'%(group[0],src[0]))
+
+    def test_igmp_with_mismatch_for_dst_ip_and_mac_in_data_packets(self):
+        group = ['228.18.19.29']
+        source = [self.randomsourceip()]
+        self.onos_ssm_table_load(group,src_list= source)
+	self.send_igmp_join(groups = group, src_list = source,record_type = IGMP_V3_GR_TYPE_INCLUDE,
+                             iface = self.V_INF1)
+        dst_mac = '01:00:5e:0A:12:09'
+        eth = Ether(dst= dst_mac)
+        ip = IP(dst=group[0],src=source[0])
+        data = repr(monotonic.monotonic())
+        pkt = (eth/ip/data)
+        log.info('Multicast traffic packet %s'%pkt.show())
+	self.success = False
+        def recv_task():
+            def igmp_recv_cb(pkt):
+                #log.info('received multicast data packet is %s'%pkt.show())
+                log.info('multicast data received for group %s from source %s'%(group[0],source[0]))
+                self.success = True
+            sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group[0] and p[IP].src == source[0], count=1,timeout = 2, iface='veth0')
+        t = threading.Thread(target = recv_task)
+        t.start()
+        sendp(eth/ip/data,count=20, iface = 'veth2')
+        t.join()
+        assert_equal(status,False) # not expecting igmp data traffic from source src_list[0]
+
+    #test case failing, ONOS registering unicast ip also as an igmp join
+    def test_igmp_registering_invalid_group(self):
+        groups = ['218.18.19.29','240.10.34.94','224.19.256.10']
+        source = [self.randomsourceip()]
+	ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
+	ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
+	for g in groups:
+            for s in source:
+                d = {}
+                d['source'] = s or '0.0.0.0'
+                d['group'] = g
+                ssm_xlate_list.append(d)
+	    log.info('onos load config is %s'%ssm_dict)
+            status, code = OnosCtrl.config(ssm_dict)
+	    assert_equal(status,False)
+
+    def test_igmp_registering_invalid_source(self):
+        groups = [self.random_mcast_ip()]
+        sources = ['224.10.28.34','193.73.219.257']
+        ssm_dict = {'apps' : { 'org.onosproject.igmp' : { 'ssmTranslate' : [] } } }
+        ssm_xlate_list = ssm_dict['apps']['org.onosproject.igmp']['ssmTranslate']
+        for g in groups:
+            for s in sources:
+                d = {}
+                d['source'] = s or '0.0.0.0'
+                d['group'] = g
+                ssm_xlate_list.append(d)
+            log.info('onos load config is %s'%ssm_dict)
+            status, code = OnosCtrl.config(ssm_dict)
+            assert_equal(status,False)
+
