Exemplo n.º 1
0
    def runTest(self):
        s1_vlan_id = 10
        s2_vlan_id = 20
        s1_ip = '192.168.10.254'
        s2_ip = '192.168.20.254'
        ports = sorted(config["port_map"].keys())

        t1 = (Tenant('t1').segment(
            's1', 'vlan', [s1_ip], s1_vlan_id).segment_member(
                SegmentMember('s1',
                              cfg.leaf0['id']).ports([cfg.leaf0['portC'].name
                                                      ])).build())

        t2 = (Tenant('t2').segment(
            's2', 'vlan', [s2_ip], s2_vlan_id).segment_member(
                SegmentMember('s2',
                              cfg.leaf1['id']).ports([cfg.leaf1['portC'].name
                                                      ])).build())

        system_tenant = (Tenant('system', 'System').build())

        lrouter_r1 = (LogicalRouter('r1', 't1').interfaces(['s1']).build())

        lrouter_r2 = (LogicalRouter('r2', 't2').interfaces(['s2']).build())

        lrouter_system = (LogicalRouter('system').tenant_routers(
            ['t1/r1', 't2/r2']).build())

        host[0]['ip'] = '192.168.10.118'
        host[2]['ip'] = '192.168.20.103'

        h0 = Host(host[0]).set_ip()
        h2 = Host(host[2]).set_ip()

        assert ('success' == h0.ping(host[2]['ip']))
Exemplo n.º 2
0
    def runTest(self):
        ports = sorted(config["port_map"].keys())

        s1_ip = '192.168.10.1'
        s2_ip = '192.168.20.1'
        ports = sorted(config["port_map"].keys())

        t1 = (Tenant('t1').segment('s1', 'vlan', [s1_ip], 100).segment_member(
            SegmentMember('s1', cfg.leaf0['id']).ports([
                cfg.leaf0['portC'].name
            ])).segment('s2', 'vlan', [s2_ip], 200).segment_member(
                SegmentMember('s2',
                              cfg.leaf1['id']).ports([cfg.leaf1['portC'].name
                                                      ])).build())

        t2 = (Tenant('t2').segment('s1', 'vlan', [s1_ip], 101).segment_member(
            SegmentMember('s1', cfg.leaf0['id']).ports([
                cfg.leaf0['portD'].name
            ])).segment('s2', 'vlan', [s2_ip], 201).segment_member(
                SegmentMember('s2',
                              cfg.leaf1['id']).ports([cfg.leaf1['portD'].name
                                                      ])).build())

        wait_for_system_stable()

        lrouter_r1 = (LogicalRouter('r1', 't1').interfaces(['s1',
                                                            's2']).build())

        wait_for_system_stable()

        lrouter_r2 = (LogicalRouter('r2', 't2').interfaces(['s1',
                                                            's2']).build())

        wait_for_system_stable()

        cfg.host0['ip'] = '192.168.10.10'
        cfg.host1['ip'] = '192.168.20.10'
        cfg.host2['ip'] = '192.168.10.20'
        cfg.host3['ip'] = '192.168.20.20'

        testhost_configuration()

        route_add(cfg.host0, '192.168.20.0', s1_ip)
        route_add(cfg.host1, '192.168.10.0', s2_ip)
        route_add(cfg.host2, '192.168.20.0', s1_ip)
        route_add(cfg.host3, '192.168.10.0', s2_ip)

        ping_result = ping_test(cfg.host0, cfg.host1['ip'])

        assert (ping_verify('64 bytes from ' + cfg.host1['ip'], ping_result))

        ping_result1 = ping_test(cfg.host2, cfg.host3['ip'])

        assert (ping_verify('64 bytes from ' + cfg.host3['ip'], ping_result1))

        lrouter_r1.destroy()
        lrouter_r2.destroy()
        t1.destroy()
        t2.destroy()
Exemplo n.º 3
0
def clear_logical_router():
    response = requests.get(URL+"tenantlogicalrouter/v1",
                            cookies=COOKIES, headers=GET_HEADER)
    assert(response.status_code == 200)

    if response.json()['routers']:
        for lrouter in response.json()['routers']:
            tmp_lrouter = LogicalRouter(lrouter['name'], lrouter['tenant'])
            tmp_lrouter.destroy()
            clear_policy_route(lrouter['tenant'], lrouter['name'])
            clear_nexthop_group(lrouter['tenant'], lrouter['name'])
            clear_static_route(lrouter['tenant'], lrouter['name'])
Exemplo n.º 4
0
    def runTest(self):
        s1_vlan_id = 50
        s2_vlan_id = 60
        s1_ip = '192.168.50.254'
        s2_ip = '192.168.60.254'
        ports = sorted(config["port_map"].keys())
        match_ip = '10.10.10.10'

        t1 = (Tenant('t1').segment(
            's1', 'vlan', [s1_ip], s1_vlan_id).segment_member(
                SegmentMember('s1', cfg.leaf0['id']).ports([
                    cfg.leaf0['portC'].name, cfg.leaf0['portD'].name
                ])).segment('s2', 'vlan', [s2_ip], s2_vlan_id).build())

        pr1 = (PolicyRoute('pr1').ingress_segments(['s1']).ingress_ports([
            '{}/{}'.format(cfg.leaf0['id'], cfg.leaf0['portC'].number)
        ]).action('permit').sequence_no('1').protocols(
            ['icmp']).match_ip(match_ip + '/32').nexthop('192.168.50.120'))

        lrouter = (LogicalRouter('r1', 't1').interfaces(
            ['s1', 's2']).policy_route(pr1).build())

        host[0]['ip'] = '192.168.50.118'
        host[1]['ip'] = '192.168.50.120'

        h0 = Host(host[0]).set_ip()
        h1 = Host(host[1]).set_ip()

        sr = SenderReceiver(h0, h1)

        assert ('success' == sr.sender_ping(
            match_ip,
            expected_str='{} \xe2\x86\x92 {}  ICMP 98 Echo \(ping\) request'.
            format(host[0]['ip'], match_ip)))
Exemplo n.º 5
0
    def runTest(self):
        s1_vlan_id = 50
        s2_vlan_id = 60
        s1_ip = '192.168.50.254'
        s2_ip = '192.168.60.254'
        ports = sorted(config["port_map"].keys())

        t1 = (Tenant('t1').segment(
            's1', 'vlan', [s1_ip], s1_vlan_id).segment_member(
                SegmentMember('s1', cfg.leaf0['id']).ports([
                    cfg.leaf0['portC'].name, cfg.leaf0['portD'].name
                ])).segment('s2', 'vlan', [s2_ip], s2_vlan_id).build())

        cfg.external_router0['ip'] = '192.168.50.100'
        nexthop_ip = '10.10.10.1'

        lrouter = (LogicalRouter('r1', 't1').interfaces([
            's1', 's2'
        ]).nexthop_group('n1', [cfg.external_router0['ip']]).static_route(
            'static-r1', nexthop_ip, 24, 'n1').build())

        host[0]['ip'] = '192.168.50.118'
        host[1]['ip'] = cfg.external_router0['ip']

        h0 = Host(host[0]).set_ip()
        h1 = Host(host[1]).set_ip()

        sr = SenderReceiver(h0, h1)

        assert ('success' == sr.sender_ping(
            nexthop_ip,
            expected_str='{} \xe2\x86\x92 {}   ICMP 98 Echo \(ping\) request'.
            format(host[0]['ip'], nexthop_ip)))
Exemplo n.º 6
0
    def runTest(self):
        s1_vlan_id = 10
        s2_vlan_id = 30
        ports = sorted(config["port_map"].keys())
        segment_ip_list = [(['192.168.10.254'], ['192.168.30.254'])]

        for (s1_ip, s2_ip) in segment_ip_list:
            t1 = (Tenant('t1').segment(
                's1', 'vlan', s1_ip, s1_vlan_id).segment_member(
                    SegmentMember('s1', cfg.leaf0['id']).ports([
                        cfg.leaf0['portC'].name
                    ])).segment('s2', 'vlan', s2_ip,
                                s2_vlan_id).segment_member(
                                    SegmentMember('s2', cfg.leaf1['id']).ports(
                                        [cfg.leaf1['portC'].name])).build())

            lrouter = (LogicalRouter('r1', 't1').interfaces(['s1',
                                                             's2']).build())

            host[0]['ip'] = '192.168.10.118'
            host[2]['ip'] = '192.168.30.63'

            h0 = Host(host[0]).set_ip()
            h2 = Host(host[2]).set_ip()

            assert ('success' == h0.ping(host[2]['ip']))
Exemplo n.º 7
0
    def runTest(self):
        s1_vlan_id = 50
        s2_vlan_id = 100
        s1_vlan_ip = '192.168.50.1'
        s2_vlan_ip = '192.168.100.1'
        dhcp_server_ip = '192.168.100.10'
        ports = sorted(config["port_map"].keys())

        t1 = (
            Tenant('t1')
            .segment('s1', 'vlan', [s1_vlan_ip], s1_vlan_id)
            .segment_member(SegmentMember('s1', cfg.leaf0['id']).ports([cfg.leaf0['portA'].name]))
            .segment('s2', 'vlan', [s2_vlan_ip], s2_vlan_id)
            .segment_member(SegmentMember('s2', cfg.leaf1['id']).ports([cfg.leaf1['portA'].name, cfg.leaf1['portB'].name]))
            .build()
        )

        lrouter = (
            LogicalRouter('r1', 't1')
            .interfaces(['s1', 's2'])
            .build()
        )

        dhcp_relay = (
            DHCPRelay('t1', 's1')
            .servers([dhcp_server_ip])
            .build()
        )

        cfg.dhcp_server['ip'] = dhcp_server_ip
Exemplo n.º 8
0
    def runTest(self):
        s1_vlan_id = 130
        s2_vlan_id = 140
        s1_ip = '192.168.130.1'
        s2_ip = '192.168.140.1'
        ports = sorted(config["port_map"].keys())

        t1 = (
            Tenant('t1')
            .segment('s1', 'vlan', [s1_ip], s1_vlan_id)
            .segment_member(
                SegmentMember('s1', cfg.leaf0['id'])
                .mac_based_vlan(['{}/48'.format(cfg.host0['mac'])])
            )
            .segment('s2', 'vlan', [s2_ip], s2_vlan_id)
            .segment_member(
                SegmentMember('s2', cfg.leaf1['id'])
                .ports([cfg.leaf1['portB'].name])
            )
            .build()
        )

        lrouter = (
            LogicalRouter('r1', 't1')
            .interfaces(['s1', 's2'])
            .build()
        )

        cfg.host0['ip'] = '192.168.130.30'
        cfg.host3['ip'] = '192.168.140.30'

        master_spine = get_master_spine(
            self.dataplane, cfg.host3, s2_ip, ports[3])
        send_icmp_echo_request(self.dataplane, cfg.host3,
                               master_spine, s2_ip, ports[3])

        pkt_from_p0_to_p3 = simple_tcp_packet(
            pktlen=68,
            dl_vlan_enable=True,
            vlan_vid=s1_vlan_id,
            eth_dst=master_spine['mac'],
            eth_src=cfg.host0['mac'],
            ip_dst=cfg.host3['ip'],
            ip_src=cfg.host0['ip']
        )

        # check connection between 2 segments
        self.dataplane.send(ports[0], str(pkt_from_p0_to_p3))

        pkt_expected = simple_tcp_packet(
            pktlen=64,
            eth_dst=cfg.host3['mac'],
            eth_src=master_spine['mac'],
            ip_dst=cfg.host3['ip'],
            ip_src=cfg.host0['ip'],
            ip_ttl=63
        )

        verify_packet(self, str(pkt_expected), ports[3])
Exemplo n.º 9
0
    def runTest(self):
        s1_vlan_id = 15
        s2_vlan_id = 25
        ports = sorted(config["port_map"].keys())

        s1_ip = ['192.168.15.1']
        s2_ip = ['192.168.25.1']

        t1 = (Tenant('t1').segment(
            's1', 'vlan', s1_ip, s1_vlan_id).segment_member(
                SegmentMember('s1', cfg.leaf0['id']).ports([
                    cfg.leaf0['portA'].name
                ])).segment('s2', 'vlan', s2_ip, s2_vlan_id).segment_member(
                    SegmentMember('s2', cfg.leaf1['id']).ports(
                        [cfg.leaf1['portA'].name])).build())

        lrouter = (LogicalRouter('r1', 't1').interfaces(['s1', 's2']).build())

        cfg.host0['ip'] = '192.168.15.30'
        cfg.host2['ip'] = '192.168.25.30'

        def test_by_packet():
            master_spine = get_master_spine(self.dataplane, cfg.host2, s2_ip,
                                            ports[2])
            send_icmp_echo_request(self.dataplane, cfg.host2, master_spine,
                                   s2_ip, ports[2])

            pkt_from_p0_to_p2 = simple_tcp_packet(pktlen=68,
                                                  dl_vlan_enable=True,
                                                  vlan_vid=s1_vlan_id,
                                                  eth_dst=master_spine['mac'],
                                                  eth_src=cfg.host0['mac'],
                                                  ip_dst=cfg.host2['ip'],
                                                  ip_src=cfg.host0['ip'])

            # check connection between 2 segments
            self.dataplane.send(ports[0], str(pkt_from_p0_to_p2))

            pkt_expected = simple_tcp_packet(pktlen=64,
                                             eth_dst=cfg.host2['mac'],
                                             eth_src=master_spine['mac'],
                                             ip_dst=cfg.host2['ip'],
                                             ip_src=cfg.host0['ip'],
                                             ip_ttl=63)

            verify_packet(self, str(pkt_expected), ports[2])

        test_by_packet()

        self.reboot_switch()

        test_by_packet()

        lrouter.destroy()
        t1.destroy()
Exemplo n.º 10
0
    def runTest(self):
        s1_vlan_id = 10
        s2_vlan_id = 20
        s3_vlan_id = 30
        s1_ip = '192.168.10.254'
        s2_ip = '192.168.20.254'
        s3_ip = '192.168.30.254'

        t1 = (Tenant('t1').segment(
            's1', 'vlan', [s1_ip], s1_vlan_id).segment_member(
                SegmentMember('s1', cfg.leaf0['id']).ports([
                    cfg.leaf0['portC'].name
                ])).segment('s2', 'vlan', [s2_ip], s2_vlan_id).segment_member(
                    SegmentMember('s2', cfg.leaf0['id']).ports([
                        cfg.leaf0['portD'].name
                    ])).segment_member(
                        SegmentMember('s2', cfg.leaf1['id']).ports([
                            cfg.leaf1['portC'].name
                        ])).segment(
                            's3', 'vlan', [s3_ip], s3_vlan_id).segment_member(
                                SegmentMember('s3', cfg.leaf1['id']).ports(
                                    [cfg.leaf1['portD'].name])).build())

        lrouter = (LogicalRouter('r1', 't1').interfaces(['s1', 's2',
                                                         's3']).build())

        host[0]['ip'] = '192.168.10.118'
        host[1]['ip'] = '192.168.20.117'
        host[2]['ip'] = '192.168.20.103'
        host[3]['ip'] = '192.168.30.83'

        h0 = Host(host[0]).set_ip()
        h1 = Host(host[1]).set_ip()
        h2 = Host(host[2]).set_ip()
        h3 = Host(host[3]).set_ip()

        assert ('success' == h0.ping(host[1]['ip']))
        assert ('success' == h0.ping(host[2]['ip']))
        assert ('success' == h0.ping(host[3]['ip']))
    def runTest(self):
        ports = sorted(config["port_map"].keys())

        s1_vlan_id = 58
        s2_vlan_id = 108
        s1_vlan_ip = '192.168.58.1'
        s2_vlan_ip = '192.168.108.1'
        dhcp_server_ip = '192.168.108.20'
        allocated_ip = '192.168.58.51'

        t1 = (Tenant('t1').segment(
            's1', 'vlan', [s1_vlan_ip], s1_vlan_id).segment_member(
                SegmentMember('s1', cfg.leaf0['id']).ports([
                    cfg.leaf0['portA'].name
                ])).segment('s2', 'vlan', [s2_vlan_ip],
                            s2_vlan_id).segment_member(
                                SegmentMember('s2', cfg.leaf1['id']).ports([
                                    cfg.leaf1['portA'].name,
                                    cfg.leaf1['portB'].name
                                ])).build())

        lrouter = (LogicalRouter('r1', 't1').interfaces(['s1', 's2']).build())

        dhcp_relay = (DHCPRelay('t1', 's1').servers([dhcp_server_ip]).build())

        cfg.dhcp_server['ip'] = dhcp_server_ip

        def test_by_packet():
            spine = get_master_spine(self.dataplane, cfg.dhcp_server,
                                     s1_vlan_ip, ports[3])
            send_icmp_echo_request(self.dataplane, cfg.dhcp_server, spine,
                                   s2_vlan_ip, ports[3])

            dhcp_pkt = DHCP_PKT()

            # verify dhcp discover
            dhcp_discover = dhcp_pkt.generate_discover_pkt(cfg.host0)
            expected_dhcp_discover = dhcp_pkt.generate_expected_discover_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, s2_vlan_ip)

            self.dataplane.send(ports[0], str(dhcp_discover))
            verify_packet(self, str(expected_dhcp_discover), ports[3])

            # verify dhcp offer
            dhcp_offer = dhcp_pkt.generate_offer_pkt(spine, cfg.dhcp_server,
                                                     cfg.host0, s1_vlan_ip,
                                                     allocated_ip)
            expected_dhcp_offer = dhcp_pkt.generate_expected_offer_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)

            self.dataplane.send(ports[3], str(dhcp_offer))
            verify_packet(self, str(expected_dhcp_offer), ports[0])

            # verify dhcp request
            dhcp_request = dhcp_pkt.generate_request_pkt(
                cfg.dhcp_server, cfg.host0, allocated_ip)
            expected_dhcp_request = dhcp_pkt.generate_expected_request_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, s2_vlan_ip,
                allocated_ip)

            self.dataplane.send(ports[0], str(dhcp_request))
            verify_packet(self, str(expected_dhcp_request), ports[3])

            # verify dhcp ack
            dhcp_ack = dhcp_pkt.generate_ack_pkt(spine, cfg.dhcp_server,
                                                 cfg.host0, s1_vlan_ip,
                                                 allocated_ip)
            expected_dhcp_ack = dhcp_pkt.generate_expected_ack_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)

            self.dataplane.send(ports[3], str(dhcp_ack))
            verify_packet(self, str(expected_dhcp_ack), ports[0])

        self.spine_link_down_up_verify(test_by_packet)

        dhcp_relay.destroy()
        lrouter.destroy()
        t1.destroy()
Exemplo n.º 12
0
    def runTest(self):
        ports = sorted(config["port_map"].keys())

        case_item_list = [
            # s1_vlan_id s2_vlan_id  s1_vlan_ip       s2_vlan_ip         dhcp_server_ip      allocated_ip
            (50,        100,        '192.168.50.1', '192.168.100.1',
             '192.168.100.20',   '192.168.50.51'),
            (60,        200,        '192.168.60.1',
             '192.168.200.1',    '192.168.200.20',   '192.168.60.51')
        ]

        for case_item in case_item_list:
            s1_vlan_id = case_item[0]
            s2_vlan_id = case_item[1]
            s1_vlan_ip = case_item[2]
            s2_vlan_ip = case_item[3]
            dhcp_server_ip = case_item[4]
            allocated_ip = case_item[5]

            t1 = (
                Tenant('t1')
                .segment('s1', 'vlan', [s1_vlan_ip], s1_vlan_id)
                .segment_member(SegmentMember('s1', cfg.leaf0['id']).ports([cfg.leaf0['portA'].name]))
                .segment('s2', 'vlan', [s2_vlan_ip], s2_vlan_id)
                .segment_member(SegmentMember('s2', cfg.leaf1['id']).ports([cfg.leaf1['portA'].name, cfg.leaf1['portB'].name]))
                .build()
            )

            lrouter = (
                LogicalRouter('r1', 't1')
                .interfaces(['s1', 's2'])
                .build()
            )

            dhcp_relay = (
                DHCPRelay('t1', 's1')
                .servers([dhcp_server_ip])
                .build()
            )

            cfg.dhcp_server['ip'] = dhcp_server_ip

            spine = get_master_spine(
                self.dataplane, cfg.dhcp_server, s1_vlan_ip, ports[3])
            send_icmp_echo_request(
                self.dataplane, cfg.dhcp_server, spine, s2_vlan_ip, ports[3])

            dhcp_pkt = DHCP_PKT()

            # verify dhcp discover
            dhcp_discover = dhcp_pkt.generate_discover_pkt(cfg.host0)
            expected_dhcp_discover = dhcp_pkt.generate_expected_discover_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, s2_vlan_ip)

            self.dataplane.send(ports[0], str(dhcp_discover))
            verify_packet(self, str(expected_dhcp_discover), ports[3])

            # verify dhcp offer
            dhcp_offer = dhcp_pkt.generate_offer_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)
            expected_dhcp_offer = dhcp_pkt.generate_expected_offer_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)

            self.dataplane.send(ports[3], str(dhcp_offer))
            verify_packet(self, str(expected_dhcp_offer), ports[0])

            # verify dhcp request
            dhcp_request = dhcp_pkt.generate_request_pkt(
                cfg.dhcp_server, cfg.host0, allocated_ip)
            expected_dhcp_request = dhcp_pkt.generate_expected_request_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, s2_vlan_ip, allocated_ip)

            self.dataplane.send(ports[0], str(dhcp_request))
            verify_packet(self, str(expected_dhcp_request), ports[3])

            # verify dhcp ack
            dhcp_ack = dhcp_pkt.generate_ack_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)
            expected_dhcp_ack = dhcp_pkt.generate_expected_ack_pkt(
                spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)

            self.dataplane.send(ports[3], str(dhcp_ack))
            verify_packet(self, str(expected_dhcp_ack), ports[0])

            dhcp_relay.destroy()
            lrouter.destroy()
            t1.destroy()

            # clear queue packet
            self.dataplane.flush()

            wait_for_system_stable()
Exemplo n.º 13
0
    def runTest(self):
        ports = sorted(config["port_map"].keys())

        s1_vlan_id = 50
        s2_vlan_id = 100
        s3_vlan_id = 60
        s4_vlan_id = 200
        s1_vlan_ip = '192.168.50.1'
        s2_vlan_ip = '192.168.100.1'
        s3_vlan_ip = '192.168.60.1'
        s4_vlan_ip = '192.168.200.1'
        dhcp_server_ip = '192.168.200.10'
        allocated_ip = '192.168.50.51'

        t1 = (
            Tenant('t1')
            .segment('s1', 'vlan', [s1_vlan_ip], s1_vlan_id)
            .segment_member(SegmentMember('s1', cfg.leaf0['id']).ports([cfg.leaf0['portA'].name]))
            .segment('s2', 'vlan', [s2_vlan_ip], s2_vlan_id)
            .segment_member(SegmentMember('s2', cfg.leaf0['id']).ports([cfg.leaf0['portB'].name]))
            .build()
        )

        t2 = (
            Tenant('t2')
            .segment('s3', 'vlan', [s3_vlan_ip], s3_vlan_id)
            .segment_member(SegmentMember('s3', cfg.leaf1['id']).ports([cfg.leaf1['portA'].name]))
            .segment('s4', 'vlan', [s4_vlan_ip], s4_vlan_id)
            .segment_member(SegmentMember('s4', cfg.leaf1['id']).ports([cfg.leaf1['portB'].name]))
            .build()
        )

        lrouter_r1 = (
            LogicalRouter('r1', 't1')
            .interfaces(['s1', 's2'])
            .build()
        )

        lrouter_r2 = (
            LogicalRouter('r2', 't2')
            .interfaces(['s3', 's4'])
            .build()
        )

        system_tenant = (
            Tenant('system', 'System')
            .build()
        )

        lrouter_system = (
            LogicalRouter('system')
            .tenant_routers(['t1/r1', 't2/r2'])
            .build()
        )

        dhcp_relay = (
            DHCPRelay('t1', 's1')
            .servers([dhcp_server_ip])
            .build()
        )

        cfg.dhcp_server['ip'] = dhcp_server_ip

        # TODO: this case needs VRF feature
        spine = get_master_spine(
            self.dataplane, cfg.dhcp_server, s1_vlan_ip, ports[3])
        send_icmp_echo_request(
            self.dataplane, cfg.dhcp_server, spine, s2_vlan_ip, ports[3])

        dhcp_pkt = DHCP_PKT()

        # verify dhcp discover
        dhcp_discover = dhcp_pkt.generate_discover_pkt(cfg.host0)
        expected_dhcp_discover = dhcp_pkt.generate_expected_discover_pkt(
            spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, s4_vlan_ip)

        self.dataplane.send(ports[0], str(dhcp_discover))
        verify_packet(self, str(expected_dhcp_discover), ports[3])

        # verify dhcp offer
        dhcp_offer = dhcp_pkt.generate_offer_pkt(
            spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)
        expected_dhcp_offer = dhcp_pkt.generate_expected_offer_pkt(
            spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)

        self.dataplane.send(ports[3], str(dhcp_offer))
        verify_packet(self, str(expected_dhcp_offer), ports[0])

        # verify dhcp request
        dhcp_request = dhcp_pkt.generate_request_pkt(
            cfg.dhcp_server, cfg.host0, allocated_ip)
        expected_dhcp_request = dhcp_pkt.generate_expected_request_pkt(
            spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, s4_vlan_ip, allocated_ip)

        self.dataplane.send(ports[0], str(dhcp_request))
        verify_packet(self, str(expected_dhcp_request), ports[3])

        # verify dhcp ack
        dhcp_ack = dhcp_pkt.generate_ack_pkt(
            spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)
        expected_dhcp_ack = dhcp_pkt.generate_expected_ack_pkt(
            spine, cfg.dhcp_server, cfg.host0, s1_vlan_ip, allocated_ip)

        self.dataplane.send(ports[3], str(dhcp_ack))
        verify_packet(self, str(expected_dhcp_ack), ports[0])

        dhcp_relay.destroy()
        lrouter_r1.destroy()
        lrouter_r2.destroy()
        lrouter_system.destroy()
        system_tenant.destroy()
        t1.destroy()
        t2.destroy()