예제 #1
0
    def test_flow_eviction_on_tcp_rst(self):
        '''
        Check TCP flow eviction TCP session gets closed due to a TCP RST
        '''
        sport = 10000
        self.vn1_vm1_fixture.wait_till_vm_is_up()
        self.vn1_vm2_fixture.wait_till_vm_is_up()
        # Unassigned dest port. TCP session to this port should end with RST
        dport = 26
        traffic_obj = BaseTraffic.factory(proto='tcp')
        traffic_obj.start(self.vn1_vm1_fixture, self.vn1_vm2_fixture, 'tcp',
                          sport, dport)

        traffic_obj.stop()
        time.sleep(15)
        flow_table = self.vn1_vm1_vrouter_fixture.get_flow_table(
            show_evicted=True)
        (flow_entry, junk) = self.vn1_vm1_vrouter_fixture.get_flow_entry(
            flow_table=flow_table,
            source_ip=self.vn1_vm1_fixture.vm_ip,
            dest_ip=self.vn1_vm2_fixture.vm_ip,
            proto='tcp',
            source_port=sport,
            dest_port=dport,
            vrf_id=self.vn1_vm1_vrouter_fixture.get_vrf_id(
                self.vn1_fixture.vn_fq_name))

        assert flow_entry is None, ('Flow not evicted ater tcp close. Flow: ',
                                    '%s' % (flow_entry.dump))
        self.logger.info('TCP flow is evicted after a TCP RST')
예제 #2
0
    def test_flow_eviction_on_tcp_rst(self):
        '''
        Check TCP flow eviction TCP session gets closed due to a TCP RST
        '''
        sport = 10000
        self.vn1_vm1_fixture.wait_till_vm_is_up()
        self.vn1_vm2_fixture.wait_till_vm_is_up()
        # Unassigned dest port. TCP session to this port should end with RST
        dport = 26
        traffic_obj = BaseTraffic.factory(proto='tcp')
        traffic_obj.start(self.vn1_vm1_fixture, self.vn1_vm2_fixture, 'tcp',
                          sport, dport)

        traffic_obj.stop()
        time.sleep(15)
        flow_table = self.vn1_vm1_vrouter_fixture.get_flow_table(show_evicted=True)
        (flow_entry, junk) = self.vn1_vm1_vrouter_fixture.get_flow_entry(
            flow_table=flow_table,
            source_ip=self.vn1_vm1_fixture.vm_ip,
            dest_ip=self.vn1_vm2_fixture.vm_ip,
            proto='tcp',
            source_port=sport,
            dest_port=dport,
            vrf_id=self.vn1_vm1_vrouter_fixture.get_vrf_id(
                self.vn1_fixture.vn_fq_name))

        assert flow_entry is None, ('Flow not evicted ater tcp close. Flow: ',
                                    '%s' % (flow_entry.dump))
        self.logger.info('TCP flow is evicted after a TCP RST')
예제 #3
0
 def start_traffic(self,
                   src_vm_fixture,
                   dst_vm_fixture,
                   proto,
                   sport=None,
                   dport=None,
                   src_vn_fqname=None,
                   dst_vn_fqname=None,
                   fip_ip=None,
                   **kwargs):
     if proto == 'icmp':
         return self.start_ping(src_vm_fixture,
                                dst_vm=dst_vm_fixture,
                                dst_ip=fip_ip)
     traffic_obj = BaseTraffic.factory(tool=SOCKET, proto=proto)
     assert traffic_obj.start(src_vm_fixture,
                              dst_vm_fixture,
                              proto,
                              sport,
                              dport,
                              sender_vn_fqname=src_vn_fqname,
                              receiver_vn_fqname=dst_vn_fqname,
                              fip=fip_ip,
                              **kwargs)
     return traffic_obj
예제 #4
0
    def test_flow_on_normal_tcp_close(self):
        '''
        Check TCP flow eviction on a regular four-way teardown
        Start a TCP session between vn1_vm1 and vn1_vm2
        Check if the flow is active
        After the TCP session is closed,
        Check that no matching flow exists after it is done
        Validate that the flow is marked inactive

        Repeat this 3 times
        '''
        sport = 10000
        dport = 11000
        self.vn1_vm1_fixture.wait_till_vm_is_up()
        self.vn1_vm2_fixture.wait_till_vm_is_up()

        f_flow_index = None
        r_flow_index = None

        for i in range(0, 3):
            traffic_obj = BaseTraffic.factory(proto='tcp')
            traffic_obj.start(self.vn1_vm1_fixture, self.vn1_vm2_fixture,
                              'tcp', sport, dport)
            time.sleep(3)
            flow_table = self.vn1_vm1_vrouter_fixture.get_flow_table(
                show_evicted=False)
            (flow_entry, junk) = self.vn1_vm1_vrouter_fixture.get_flow_entry(
                flow_table=flow_table,
                show_evicted=False,
                source_ip=self.vn1_vm1_fixture.vm_ip,
                dest_ip=self.vn1_vm2_fixture.vm_ip,
                proto='tcp',
                source_port=sport,
                dest_port=dport,
                vrf_id=self.vn1_vm1_vrouter_fixture.get_vrf_id(
                    self.vn1_fixture.vn_fq_name))
            if not f_flow_index:
                f_flow_index = flow_entry.index
                r_flow_index = flow_entry.r_flow_index

            assert not flow_entry.is_flow_evicted(), (
                "TCP flow shown as evicted",
                " on an existing TCP session: %s" % (flow_entry.items))
            assert f_flow_index == flow_entry.index, (
                "Flow table not same on",
                " a new TCP session with same 5-tuple. Expected: %s, Got %s" %
                (flow_entry.index, f_flow_index))
            assert r_flow_index == flow_entry.r_flow_index, (
                "Rev flow not same",
                " on new TCP session with same 5-tuple. Expected: %s, Got %s" %
                (flow_entry.index, f_flow_index))
            (sent, recv) = traffic_obj.stop()
            # Wait for atleast 15 secs for agent to evict the flow
            time.sleep(15)
            self.check_flow_is_evicted(self.vn1_vm1_vrouter_fixture,
                                       flow_entry)
            assert flow_entry.packets > recv, ("Unexpected Flow pkt count",
                                               "Expected: >%s, Seen: %s" %
                                               (recv, flow_entry.packets))
예제 #5
0
    def test_flow_on_normal_tcp_close(self):
        '''
        Check TCP flow eviction on a regular four-way teardown
        Start a TCP session between vn1_vm1 and vn1_vm2
        Check if the flow is active
        After the TCP session is closed,
        Check that no matching flow exists after it is done
        Validate that the flow is marked inactive

        Repeat this 3 times
        '''
        sport = 10000
        dport = 11000
        self.vn1_vm1_fixture.wait_till_vm_is_up()
        self.vn1_vm2_fixture.wait_till_vm_is_up()

        f_flow_index = None
        r_flow_index = None

        for i in range(0, 3):
            traffic_obj = BaseTraffic.factory(proto='tcp')
            traffic_obj.start(
                self.vn1_vm1_fixture, self.vn1_vm2_fixture, 'tcp',
                sport, dport)
            time.sleep(3)
            flow_table = self.vn1_vm1_vrouter_fixture.get_flow_table(
                show_evicted=True)
            (flow_entry, junk) = self.vn1_vm1_vrouter_fixture.get_flow_entry(
                flow_table=flow_table,
                source_ip=self.vn1_vm1_fixture.vm_ip,
                dest_ip=self.vn1_vm2_fixture.vm_ip,
                proto='tcp',
                source_port=sport,
                dest_port=dport,
                vrf_id=self.vn1_vm1_vrouter_fixture.get_vrf_id(
                    self.vn1_fixture.vn_fq_name)
            )
            if not f_flow_index:
                f_flow_index = flow_entry.index
                r_flow_index = flow_entry.r_flow_index

            assert not flow_entry.is_flow_evicted(
            ), ("TCP flow shown as evicted",
                " on an existing TCP session: %s" % (flow_entry.items))
            assert f_flow_index == flow_entry.index, ("Flow table not same on",
                                                      " a new TCP session with same 5-tuple. Expected: %s, Got %s" % (
                                                          flow_entry.index, f_flow_index))
            assert r_flow_index == flow_entry.r_flow_index, (
                "Rev flow not same",
                " on new TCP session with same 5-tuple. Expected: %s, Got %s" % (
                    flow_entry.index, f_flow_index))
            (sent, recv) = traffic_obj.stop()
            # Wait for atleast 15 secs for agent to evict the flow
            time.sleep(15)
            self.check_flow_is_evicted(
                self.vn1_vm1_vrouter_fixture, flow_entry)
            assert flow_entry.packets > recv, ("Unexpected Flow pkt count",
                                               "Expected: >%s, Seen: %s" % (recv, flow_entry.packets))
예제 #6
0
 def start_traffic(self, src_vm_fixture, dst_vm_fixture, proto, sport,
                   dport, src_vn_fqname=None, dst_vn_fqname=None,
                   af=None, fip_ip=None):
     traffic_obj = BaseTraffic.factory(tool=SCAPY, proto=proto)
     assert traffic_obj.start(src_vm_fixture, dst_vm_fixture, proto, sport,
                              dport, sender_vn_fqname=src_vn_fqname,
                              receiver_vn_fqname=dst_vn_fqname, af=af,
                              fip=fip_ip)
     return traffic_obj
예제 #7
0
 def start_traffic(self,
                   src_vm_fixture,
                   dst_vm_fixture,
                   proto,
                   sport,
                   dport,
                   src_vn_fqname=None,
                   dst_vn_fqname=None,
                   af=None,
                   fip_ip=None):
     traffic_obj = BaseTraffic.factory(tool=SCAPY, proto=proto)
     assert traffic_obj.start(src_vm_fixture,
                              dst_vm_fixture,
                              proto,
                              sport,
                              dport,
                              sender_vn_fqname=src_vn_fqname,
                              receiver_vn_fqname=dst_vn_fqname,
                              af=af,
                              fip=fip_ip)
     return traffic_obj