def test_passthrough_rules(self): """ Add UE MAC flows for two subscribers """ imsi_1 = 'IMSI010000000088888' other_mac = '5e:cc:cc:b1:aa:aa' # Add subscriber with UE MAC address """ self.ue_mac_controller.add_ue_mac_flow(imsi_1, self.UE_MAC_1) # Create a set of packets pkt_sender = ScapyPacketInjector(self.BRIDGE) # Only send downlink as the pkt_sender sends pkts from in_port=LOCAL downlink_packet1 = EtherPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .build() dhcp_packet = UDPPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .set_ip_layer('151.42.41.122', '1.1.1.1') \ .set_udp_layer(67, 68) \ .build() dns_packet = UDPPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .set_ip_layer('151.42.41.122', '1.1.1.1') \ .set_udp_layer(53, 32795) \ .build() # Check if these flows were added (queries should return flows) flow_queries = [ FlowQuery(self._tbl_num, self.testing_controller, match=MagmaMatch(eth_dst=self.UE_MAC_1)) ] # =========================== Verification =========================== # Verify 8 flows installed for ue_mac table (3 pkts matched) # 4 flows installed for inout (3 pkts matched) # 2 fliws installed (2 pkts matches) flow_verifier = FlowVerifier([ FlowTest(FlowQuery(self._tbl_num, self.testing_controller), 3, 8), FlowTest(FlowQuery(self._ingress_tbl_num, self.testing_controller), 3, 4), FlowTest(FlowQuery(self._egress_tbl_num, self.testing_controller), 2, 2), FlowTest(flow_queries[0], 3, 4), ], lambda: wait_after_send(self.testing_controller)) snapshot_verifier = SnapshotVerifier(self, self.BRIDGE, self.service_manager) with flow_verifier, snapshot_verifier: pkt_sender.send(downlink_packet1) pkt_sender.send(dhcp_packet) pkt_sender.send(dns_packet) flow_verifier.verify()
def test_passthrough_rules(self): """ Add UE MAC flows for two subscribers """ imsi_1 = 'IMSI010000000088888' other_mac = '5e:cc:cc:b1:aa:aa' cli_ip = '1.1.1.1' server_ip = '151.42.41.122' fake_mandatory_controller_setup(self.ingress_controller) fake_mandatory_controller_setup(self.middle_controller) fake_mandatory_controller_setup(self.egress_controller) # Add subscriber with UE MAC address """ self.ue_mac_controller.add_ue_mac_flow(imsi_1, self.UE_MAC_1) # Create a set of packets pkt_sender = ScapyPacketInjector(self.BRIDGE) # Only send downlink as the pkt_sender sends pkts from in_port=LOCAL downlink_packet1 = EtherPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .build() dhcp_packet = DHCPPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .set_ip_layer(server_ip, cli_ip) \ .set_udp_layer(67, 68) \ .set_bootp_layer(2, cli_ip, server_ip, other_mac) \ .set_dhcp_layer([("message-type", "ack"), "end"]) \ .build() dns_packet = UDPPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .set_ip_layer('151.42.41.122', '1.1.1.1') \ .set_udp_layer(53, 32795) \ .build() arp_packet = ARPPacketBuilder() \ .set_ether_layer(self.UE_MAC_1, other_mac) \ .set_arp_layer('1.1.1.1') \ .set_arp_hwdst(self.UE_MAC_1) \ .set_arp_src(other_mac, '1.1.1.12') \ .build() # Check if these flows were added (queries should return flows) flow_queries = [ FlowQuery( self._tbl_num, self.testing_controller, match=MagmaMatch(eth_dst=self.UE_MAC_1), ), ] # =========================== Verification =========================== # Verify 3 flows installed for ue_mac table (4 pkts matched) # 2 flows installed for ingress (4 pkts matched) # 2 flows installed for egress(3 pkts matches) flow_verifier = FlowVerifier( [ FlowTest( FlowQuery( self._tbl_num, self.testing_controller, ), 4, 3, ), FlowTest( FlowQuery( self._ingress_tbl_num, self.testing_controller, ), 4, 2, ), FlowTest( FlowQuery( self._egress_tbl_num, self.testing_controller, ), 3, 2, ), FlowTest(flow_queries[0], 4, 1), ], lambda: wait_after_send(self.testing_controller), ) snapshot_verifier = SnapshotVerifier( self, self.BRIDGE, self.service_manager, ) with flow_verifier, snapshot_verifier: pkt_sender.send(dhcp_packet) pkt_sender.send(downlink_packet1) pkt_sender.send(dns_packet) hub.sleep(3) pkt_sender.send(arp_packet) flow_verifier.verify()