Stress Config#
stress_definition.py
# STRESS definition file
DUT_NAME = 'ASR9000'
DUT_INTERFACE = 'GigabitEthernet0/0/0/0'
TESTER_NAME = "IXIA"
TESTER_PORT = '1:1'
MP_INTERFACE_DESCRIPTION = f'{TESTER_NAME}_{TESTER_PORT}_Multi-Stress'
MP_INTERFACE_VLAN = 100
MP_INTERFACE_NUM = 100
MP_IPv4_ADDRESS = '100.1.1.1'
MP_IPV4_MASK = '255.255.255.252' # /30 ---> point-point
MP_IPv6_NETWORK = "100:1:1:1::/64"
eBGP_INTERFACE_DESCRIPTION = f'{TESTER_NAME}_{TESTER_PORT}_eBGP-Stress_'
eBGP_INTERFACE_VLAN = 100
eBGP_INTERFACE_NUM = 100
eBGP_IPv4_ADDRESS = '100.100.1.1'
eBGP_IPV4_MASK = '255.255.255.252' # /30 ---> point-point
eBGP_IPv6_NETWORK = "100:100:1:1::/64"
eBGPv4_NUM = 100
eBGPv6_NUM = 100
TESTER_AS_NUM = 65003
DUT_AS_NUM = 65000
USE_LOOPBACK = True
iBGPv4_NUM = 100
iBGPv4_NEIGHBOR_ADDRESS = '100.100.100.100'
iBGPv6_NUM = 100
iBGPv6_NEIGHBOR_ADDRESS = "100:100:100:100::/64"
TUNNEL_INTERFACE_id_start = 60000
TUNNEL_INTERFACE_id_end = 60600
TUNNEL_DESTINATION = '1.1.1.1'
OSPF_PROCESS = 'mpls1'
OSPFv2_NUM = 100
OSPFv3_NUM = 100
LDP_CONNECT_NUM = 100
RSVP_NUM = 100
DUT_TUNNEL_NUM = 100
LDP_TARGETED = 100
create_stressConfig.py
import ipaddress
import itertools as it
import stress_definition as sd # stress definition file
# ファイル名使用不可文字変換
if '/' in sd.TESTER_PORT:
TESTER_PORT = sd.TESTER_PORT.replace('/','-')
elif ':' in sd.TESTER_PORT:
TESTER_PORT = sd.TESTER_PORT.replace(':','-')
FILE_BASENAME = f"{sd.DUT_NAME}-{sd.TESTER_NAME}_{TESTER_PORT}"
class BetterIPv6Network(ipaddress.IPv6Network):
def __add__(self, offset):
# Add numeric offset to the IP.
new_base_addr = int(self.network_address) + offset
return self.__class__((new_base_addr, self.prefixlen))
def size(self):
# Return network size.
return 1 << (self.max_prefixlen - self.prefixlen)
ipv6network = BetterIPv6Network(sd.MP_IPv6_NETWORK)
network_addrs = (ipv6network + i * ipv6network.size() for i in it.count())
ipv4addr = ipaddress.ip_address(sd.MP_IPv4_ADDRESS)
VLAN = sd.MP_INTERFACE_VLAN
# Multi Protocol用 interface 作成セクション
with open(f'./Config/{FILE_BASENAME}_Multi-Stress_interface.txt', 'w', encoding='utf-8') as f:
for num in range(sd.MP_INTERFACE_NUM):
ipv6addr = str(next(network_addrs)).replace('/64','1/64')
f.write(f'interface {sd.DUT_INTERFACE}.{VLAN}\n')
f.write(f' description {sd.MP_INTERFACE_DESCRIPTION}_{num+1}\n')
f.write(f' ipv4 address {ipv4addr}\n')
f.write(f' ipv6 address {ipv6addr}\n')
f.write(f' encapsulation dot1q {VLAN}\n')
f.write(' logging events link-status\n')
f.write('!\n')
ipv4addr += 4
VLAN += 1
# OSPFv2
VLAN = sd.MP_INTERFACE_VLAN
with open(f'./Config/{FILE_BASENAME}_OSPFv2.txt', 'w', encoding='utf-8') as f:
f.write(f'router ospf {sd.OSPF_PROCESS}\n')
f.write(' area 0\n')
for num in range(sd.OSPFv2_NUM):
f.write(f' interface {sd.DUT_INTERFACE}.{VLAN}\n')
f.write(' bfd fast-detect\n')
f.write(' cost 6000\n')
f.write(' network point-to-point\n')
f.write(' !\n')
VLAN +=1
# OSPFv3
VLAN = sd.MP_INTERFACE_VLAN
with open(f'./Config/{FILE_BASENAME}_OSPFv3.txt', 'w', encoding='utf-8') as f:
f.write(f'router ospfv3 {sd.OSPF_PROCESS}\n')
f.write(' area 0\n4')
for num in range(sd.OSPFv2_NUM):
f.write(f' interface {sd.DUT_INTERFACE}.{VLAN}\n')
f.write(' bfd fast-detect\n')
f.write(' cost 6000\n')
f.write(' network point-to-point\n')
f.write(' !\n')
VLAN +=1
# LDP connected
VLAN = sd.MP_INTERFACE_VLAN
with open(f'./Config/{FILE_BASENAME}_LDP_Connected.txt', 'w', encoding='utf-8') as f:
f.write('mpls ldp' + '\n')
for num in range(sd.LDP_CONNECT_NUM):
f.write(f' interface {sd.DUT_INTERFACE}.{VLAN}\n')
f.write(' !\n')
VLAN +=1
# RSVP
if 'GigabitEthernet' in sd.DUT_INTERFACE:
BANDWIDTH = '1000000'
elif 'TenGigE' in sd.DUT_INTERFACE:
BANDWIDTH = '10000000'
elif 'HundredGigE' in sd.DUT_INTERFACE:
BANDWIDTH = '100000000'
elif 'FourHundredGigE' in sd.DUT_INTERFACE:
BANDWIDTH = '400000000'
VLAN = sd.MP_INTERFACE_VLAN
with open(f'./Config/{FILE_BASENAME}_RSVP.txt', 'w', encoding='utf-8') as f:
f.write('rsvp' + '\n')
for num in range(sd.LDP_CONNECT_NUM):
f.write(f' interface {sd.DUT_INTERFACE}.{VLAN}\n')
f.write(f' {BANDWIDTH}\n')
f.write(' !\n')
VLAN +=1
f.write('!\n')
f.write('mpls traffic-eng' + '\n')
VLAN = sd.MP_INTERFACE_VLAN
for num in range(sd.LDP_CONNECT_NUM):
f.write(f' interface {sd.DUT_INTERFACE}.{VLAN}\n')
f.write(' !\n')
VLAN +=1
# iBGP
with open(f'./Config/{FILE_BASENAME}_iBGP.txt', 'w', encoding='utf-8') as f:
f.write(f'router bgp {sd.DUT_AS_NUM}\n')
f.write(' neighbor-group Stresss_iBGP_Neighbor\n')
f.write(f' remote-as {sd.DUT_AS_NUM}\n')
f.write(' descriprion Stresss_iBGP_Neighbor\n')
if sd.USE_LOOPBACK:
f.write(' update-source Loopback0\n')
f.write(' address-family ipv4 unicast\n')
f.write(' route-policy PERMIT in\n')
f.write(' route-policy Filter out\n')
f.write(' next-hop-self\n')
f.write(' !')
f.write(' address-family ipv6 labeled-unicast\n')
f.write(' route-policy PERMIT in\n')
f.write(' route-policy Filter out\n')
f.write(' next-hop-self\n')
f.write(' !\n')
f.write(' !\n')
f.write(' !\n')
ipv4addr = ipaddress.ip_address(sd.iBGPv4_NEIGHBOR_ADDRESS)
for num in range(sd.iBGPv4_NUM):
f.write(f' neighbor {ipv4addr}\n')
f.write(' use neghbor-group Stresss_iBGP_Neighbor\n')
f.write(f' description Stresss_iBGPv4_Neighbor_{num+1}\n')
f.write(' !\n')
if sd.USE_LOOPBACK:
ipv4addr += 1
else:
ipv4addr += 4
ipv6network = BetterIPv6Network(sd.iBGPv6_NEIGHBOR_ADDRESS)
network_addrs = (ipv6network + i * ipv6network.size() for i in it.count())
for num in range(sd.iBGPv4_NUM):
if sd.USE_LOOPBACK:
ipv6addr = str(next(network_addrs)).replace('/64','1/64')
else:
ipv6addr = str(next(network_addrs)).replace('/64','2/64')
f.write(f' neighbor {ipv6addr}\n')
f.write(' use neghbor-group Stresss_iBGP_Neighbor\n')
f.write(f' description Stresss_iBGPv6_Neighbor_{num+1}\n')
f.write(' !\n')
# eBGP
with open(f'./Config/{FILE_BASENAME}_eBGP.txt', 'w', encoding='utf-8') as f:
eBGPv4adr = ipaddress.ip_address(sd.eBGP_IPv4_ADDRESS)
for num in range(sd.iBGPv4_NUM):
f.write(f' neighbor {eBGPv4adr}\n')
f.write(f' remote-as {sd.TESTER_AS_NUM}\n')
f.write(f' description IXIA_eBGPv4_Stress_neighbor_{num+1}\n')
f.write(' address-family ipv4 unicast\n')
f.write(' send-community-ebgp\n')
f.write(' route-policy PERMIT in\n')
f.write(' route-policy Filter out\n')
f.write(' !\n')
f.write(' !\n')
eBGPv4adr += 4
ipv6network = BetterIPv6Network(sd.iBGPv6_NEIGHBOR_ADDRESS)
network_addrs = (ipv6network + i * ipv6network.size() for i in it.count())
for num in range(sd.iBGPv4_NUM):
eBGPv6adr = str(next(network_addrs)).replace('/64','2/64')
f.write(f' neighbor {eBGPv6adr}\n')
f.write(f' remote-as {sd.TESTER_AS_NUM}\n')
f.write(f' description IXIA_eBGPv6_Stress_neighbor_{num+1}\n')
f.write(' address-family ipv4 unicast\n')
f.write(' send-community-ebgp\n')
f.write(' route-policy PERMIT in\n')
f.write(' route-policy Filter out\n')
f.write(' !\n')
f.write(' !\n')
eBGPv4adr += 4
# Tunnel
with open(f'./Config/{FILE_BASENAME}_Tunnel.txt', 'w', encoding='utf-8') as f:
# f.write('explicit-path name Stress-Epath-head\n')
# f.write(' index 1 next-address strict ipv4 unicast 140.12.0.2\n')
# f.write(' index 2 next-address loose ipv4 unicast 145.12.0.1\n')
# f.write('!\n')
# f.write('!\n')
# f.write('!\n')
for num in range(sd.TUNNEL_INTERFACE_id_start, sd.TUNNEL_INTERFACE_id_end):
f.write(f'interface tunnel-te{num}\n')
f.write(f' description {num}_stress_tunnel-head_IXIA\n')
f.write(' ipv4 unnumbered Loopback0\n')
f.write(f' signalled-name {num}_stress_tunnel-head_IXIA\n')
f.write(' priority 7 7' + '\n')
f.write(f' destination {sd.TUNNEL_DESTINATION}\n')
f.write(' record-route' + '\n')
f.write(' path-selection' + '\n')
# f.write(' metric igp' + '\n')
f.write('!\n')
# f.write(' path-option 10 explicit name Stress-Epath-head' + '\n')
f.write(' path-option 100 dynamic' + '\n')
f.write(' logging events link-status' + '\n')
f.write('!\n')
# TODO: NUM 調整
# T-LDP
with open(f'./Config/{FILE_BASENAME}_LDP_Targeted.txt', 'w', encoding='utf-8') as f:
f.write('mpls ldp')
f.write(' !')
for num in range(sd.TUNNEL_INTERFACE_id_start, sd.TUNNEL_INTERFACE_id_end):
f.write(f' interface tunnel-te{num}\n')
f.write(' !\n')