summaryrefslogtreecommitdiffstats
path: root/tests/topotests/bgp_ecmp_topo1/peer6/exa-send.py
blob: 1a8e6bfe2ffdc672e6af6aaa30517c1c65ee0a29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3

"""
exa-send.py: Send a few testroutes with ExaBGP
"""

from sys import stdout, argv
from time import sleep

sleep(5)

# 1st arg is peer number
# 2nd arg is number of routes to send
peer = int(argv[1])
numRoutes = int(argv[2])
if peer <= 10:
    asnum = 99
else:
    asnum = peer + 100

# Announce numRoutes equal routes per PE - different neighbor AS
for i in range(0, numRoutes):
    stdout.write(
        "announce route 10.201.%s.0/24 med 100 next-hop 10.0.%i.%i origin igp\n"
        % (i, (((peer - 1) / 5) + 1), peer + 100)
    )
    stdout.flush()

# Announce numRoutes equal routes per PE - different neighbor AS, but same source AS
for i in range(0, numRoutes):
    stdout.write(
        "announce route 10.202.%s.0/24 med 100 next-hop 10.0.%i.%i origin igp as-path [ %i 200 ]\n"
        % (i, (((peer - 1) / 5) + 1), peer + 100, asnum)
    )
    stdout.flush()

# Announce numRoutes equal routes with different med per PE and different neighbor AS
for i in range(0, numRoutes):
    stdout.write(
        "announce route 10.203.%s.0/24 med %i next-hop 10.0.%i.%i origin igp\n"
        % (i, peer, (((peer - 1) / 5) + 1), peer + 100)
    )
    stdout.flush()

# Announce numRoutes equal routes with different med per PE and different neighbor AS, but same source AS
for i in range(0, numRoutes):
    stdout.write(
        "announce route 10.204.%s.0/24 med %i next-hop 10.0.%i.%i origin igp as-path [ %i 200 ]\n"
        % (i, peer, (((peer - 1) / 5) + 1), peer + 100, asnum)
    )
    stdout.flush()

# Announce 2 different route per peer
stdout.write(
    "announce route 10.205.%i.0/24 next-hop 10.0.%i.%i origin igp\n"
    % (peer, (((peer - 1) / 5) + 1), peer + 100)
)
stdout.write(
    "announce route 10.206.%i.0/24 next-hop 10.0.%i.%i origin igp as-path [ %i 200 ]\n"
    % (peer, (((peer - 1) / 5) + 1), peer + 100, asnum)
)
stdout.flush()

# Loop endlessly to allow ExaBGP to continue running
while True:
    sleep(1)