Exemplo n.º 1
0
    def test_custom_node_routers(self):
        RoutingHelper("rip", [self.n0, self.n1],
                      [self.r0, self.r1]).populate_routing_tables()

        status = self.n0.ping("10.0.3.4", verbose=False)
        self.assertTrue(status)

        status = self.n1.ping("10.0.1.1", verbose=False)
        self.assertTrue(status)

        with self.assertRaises(TypeError):
            RoutingHelper("rip", self.n1, self.r1).populate_routing_tables()

        with self.assertRaises(ValueError):
            RoutingHelper("rip", ["n1"], ["r1"]).populate_routing_tables()
Exemplo n.º 2
0
    def test_isis(self):
        RoutingHelper("isis").populate_routing_tables()

        status = self.n0.ping("10.0.3.4", verbose=False)
        self.assertTrue(status)

        status = self.n1.ping("10.0.1.1", verbose=False)
        self.assertTrue(status)
Exemplo n.º 3
0
    def test_ospf(self):
        RoutingHelper("ospf").populate_routing_tables()

        status = self.n0.ping("10::3:4", verbose=False)
        self.assertTrue(status)

        status = self.n1.ping("10::1:1", verbose=False)
        self.assertTrue(status)
Exemplo n.º 4
0
    def test_logs(self):
        config.set_value("routing_logs", True)

        RoutingHelper("rip").populate_routing_tables()

        self.assertTrue(
            len(glob(f"{config.get_value('routing_suite')}-logs_*")) > 0)

        config.set_value("routing_logs", False)
Exemplo n.º 5
0
    def test_logs(self):
        config.set_value("routing_logs", True)

        RoutingHelper("rip").populate_routing_tables()

        self.assertTrue(
            os.path.isdir(
                f"{config.get_value('routing_suite')}-logs_{IdGen.topology_id}"
            ))

        config.set_value("routing_logs", False)
Exemplo n.º 6
0
    def test_prrp(self):
        # pylint: disable=invalid-name
        r1 = Node("r")
        r2 = Node("r")
        r1.enable_ip_forwarding()
        r2.enable_ip_forwarding()

        with self.net1:
            (n0_r1, r1_n0) = connect(self.n0, r1)

        (r1_r2, r2_r1) = connect(r1, r2, network=self.net2)
        (r2_n1, n1_r2) = connect(r2, self.n1)

        AddressHelper.assign_addresses()
        r2_n1.set_address("10.1.3.2/24")
        n1_r2.set_address("10.1.3.1/24")

        RoutingHelper(protocol="rip").populate_routing_tables()

        status = self.n0.ping(n1_r2.get_address(), verbose=False)

        self.assertTrue(status)
Exemplo n.º 7
0
# Set the IPv4 address for the networks, and not the interfaces.
# We will use the `AddressHelper` later to assign addresses to the interfaces.
# Note: this example has two networks, one each on either side of `r1`.
n1 = Network("192.168.1.0/24")  # network on the left side of `r1`
n2 = Network("192.168.2.0/24")  # network on the right side of `r1`

# Connect `h1` to `r1` (left side), and then `r1` (right side) to `h2`.
# `eth1` and `eth2` are the interfaces at `h1` and `h2`, respectively.
# `etr1a` is the first interface at `r1` which connects it with `h1`
# `etr1b` is the second interface at `r1` which connects it with `h2`
(eth1, etr1a) = connect(h1, r1, network=n1)
(etr1b, eth2) = connect(r1, h2, network=n2)

# Assign IPv4 addresses to all the interfaces in the network.
AddressHelper.assign_addresses()

# Set the link attributes: `h1` --> `r1` --> `h2`
eth1.set_attributes("5mbit", "5ms")  # from `h1` to `r1`
etr1b.set_attributes("5mbit", "5ms")  # from `r1` to `h2`

# Set the link attributes: `h2` --> `r1` --> `h1`
eth2.set_attributes("10mbit", "100ms")  # from `h2` to `r1`
etr1a.set_attributes("10mbit", "100ms")  # from `r1` to `h1`

# Use RIP to form routes.
RoutingHelper(protocol="rip").populate_routing_tables()

# `Ping` from `h1` to `h2`.
h1.ping(eth2.address)
Exemplo n.º 8
0
# Assign IPv4 addresses to all the interfaces in the network.
AddressHelper.assign_addresses()

# Enable MPLS on the required interfaces in the network.
etpe1b.enable_mpls()
etpa.enable_mpls()
etpb.enable_mpls()
etpe2a.enable_mpls()

# Use LDP to auto-assign labels on MPLS enabled interfaces. LDP requires an IP
# based dynamic routing protocol to be already in place for it to find out the
# IP addresses. In this program, we use Open Shortest Path First (OSPF).
# Initially, the OSPF routing protocol runs as usual, and then LDP runs on
# the MPLS enabled routers: `pe` and `p`.
RoutingHelper("ospf", ldp_routers=[pe1, p, pe2]).populate_routing_tables()

# Add `sleep` time to allow LDP to install routes. Depending on the size of the
# topology, the amount of time specified for `sleep` may vary. The following
# two lines may be added as topology grows in size and complexity. Note: this
# example does not require `sleep` time as the topology is simple and small.
#
# from time import sleep
# sleep(20)

# Set the link attributes: `ce1` --> `pe1` --> `p` --> `pe2` --> `ce2`
etce1.set_attributes("50mbit", "5ms")  # from `ce1` to `pe1`
etpe1b.set_attributes("10mbit", "10ms")  # from `pe1` to `p`
etpb.set_attributes("10mbit", "10ms")  # from `p` to `pe2`
etpe2b.set_attributes("50mbit", "5ms")  # from `pe2` to `ce2`