Skip to content

Commit

Permalink
Merge pull request #451 from open-traffic-generator/bgp_use_case
Browse files Browse the repository at this point in the history
Bgp use case
  • Loading branch information
ANISH-GOTTAPU authored Dec 15, 2021
2 parents c726735 + f1d8a9c commit 751b681
Show file tree
Hide file tree
Showing 52 changed files with 3,134 additions and 2,200 deletions.
46 changes: 26 additions & 20 deletions do.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ def lint():


def test():
coverage_threshold = 78
# args = [
# '--location="https://10.39.71.97:443"',
# (
# '--ports="10.39.65.230;6;1 10.39.65.230;6;2 10.39.65.230;6;3'
# ' 10.39.65.230;6;4"'
# ),
# '--media="fiber"',
# "tests",
# '-m "not e2e and not l1_manual"',
# '--cov=./snappi_ixnetwork --cov-report term --cov-report html:cov_report',
# ]
coverage_threshold = 67
# args = [
# '--location="https://10.39.71.97:443"',
# (
# '--ports="10.39.65.230;6;1 10.39.65.230;6;2 10.39.65.230;6;3'
# ' 10.39.65.230;6;4"'
# ),
# '--media="fiber"',
# "tests",
# '-m "not e2e and not l1_manual"',
# '--cov=./snappi_ixnetwork --cov-report term --cov-report html:cov_report',
# ]
args = [
'--location="https://otg-novus100g.lbj.is.keysight.com:5000"',
(
Expand All @@ -60,7 +60,7 @@ def test():
"--speed=speed_100_gbps",
"tests",
'-m "not e2e and not l1_manual"',
'--cov=./snappi_ixnetwork --cov-report term --cov-report html:cov_report',
"--cov=./snappi_ixnetwork --cov-report term --cov-report html:cov_report",
]
run(
[
Expand All @@ -69,17 +69,23 @@ def test():
]
)
import re

with open("./cov_report/index.html") as fp:
out = fp.read()
result = re.findall(r'data-ratio.*?[>](\d+)\b', out)[0]
result = re.findall(r"data-ratio.*?[>](\d+)\b", out)[0]
if int(result) < coverage_threshold:
raise Exception("Coverage thresold[{0}] is NOT achieved[{1}]".format(
coverage_threshold, result
))
raise Exception(
"Coverage thresold[{0}] is NOT achieved[{1}]".format(
coverage_threshold, result
)
)
else:
print("Coverage thresold[{0}] is achieved[{1}]".format(
coverage_threshold, result
))
print(
"Coverage thresold[{0}] is achieved[{1}]".format(
coverage_threshold, result
)
)


def dist():
clean()
Expand Down
301 changes: 301 additions & 0 deletions docs/deviceUsecase/deviceBgpUsecase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
# Scenario-1: Simple BGP and Route
```python
device = config.devices.device(name="d1")[-1]
eth = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth.ipv4_addresses.ipv4(name="ip1")

bgp = device.bgp
bgp.router_id = "10.10.0.1"
bgp_int = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer = bgp_int.peers.add(name="bgp1")
bgp_peer.peer_address = "10.10.0.2"
bgp_peer.as_type = bgp_peer.IBGP
bgp_peer.as_number = 2
v4_routes = bgp_peer.v4_routes.add(name="route1")
v4_routes.addresses.add(address="10.10.0.0")
v4_routes = bgp_peer.v4_routes.add(name="route2")
v4_routes.addresses.add(address="20.20.0.0")
```
- Single ethernet(“eth1”) configurate on top of port “p1”
- Single IPv4(“ip1”) present on top of ethernet(“eth1”)
- Single BGP map with IPv4(“ip1”)
- Two v4_route configure on that bgp_peer
## IxNetwork Mapping
<img src="scr_bgp_1.png" alt="drawing" width="500"/>

- Create topology per port
- Ether, IP and BGP can map one to one
- Create network group (NG) according to v4_routes
- Use NG multiplier to accommodate number of address

# Scenario-2: Multiple devices configured top of same Port
```python
device1 = config.devices.device(name="d1")[-1]
device2 = config.devices.device(name="d2")[-1]

eth1 = device1.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth1.vlans.add(name="vlan1", id=1)
eth2 = device2.ethernets.ethernet(name='eth2', port_name="p1")[-1]
eth2.vlans.add(name="vlan2", id=2)
eth1.ipv4_addresses.ipv4(name="ip1")
eth2.ipv4_addresses.ipv4(name="ip2")

bgp1 = device1.bgp
bgp1.router_id = "1.1.1.1"
bgp_int1 = bgp1.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer1 = bgp_int1.peers.add(name="bgp1")
v4_routes1 = bgp_peer1.v4_routes.add(name="route1")
v4_routes1.addresses.add(address="10.10.0.0")

bgp2 = device2.bgp
bgp2.router_id = "1.1.1.2"
bgp_int2 = bgp2.ipv4_interfaces.add(ipv4_name="ip2")
bgp_peer2 = bgp_int2.peers.add(name="bgp2")
v4_routes2 = bgp_peer2.v4_routes.add(name="route2")
v4_routes2.addresses.add(address="20.20.0.0")
```
- Two device configured on top of same port ("p1")
- Different VLAN segregate BGP Peer
- Two BGP peers map with Two interface
## IxNetwork Mapping
<img src="scr_bgp_4.png" alt="drawing" width="500"/>

- Add device multiplier ("2") according to the number of device
- Compact all values related to Ethernet, IP and BGP. And configure those in respective rows
- Different router ID should configure
- Stack Multiplier should be 1 for all those stack

# Scenario-3: Multiple Interface and BGP
```python
device = config.devices.device(name="d1")[-1]
eth1 = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth2 = device.ethernets.ethernet(name='eth2', port_name="p1")[-1]
eth1.ipv4_addresses.ipv4(name="ip1")
eth2.ipv4_addresses.ipv4(name="ip2")

bgp = device.bgp
bgp.router_id = "1.1.1.1"
bgp_int1 = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer1 = bgp_int1.peers.add(name="bgp1")
v4_routes = bgp_peer1.v4_routes.add(name="route1")
v4_routes.addresses.add(address="10.10.0.0")
bgp_int2 = bgp.ipv4_interfaces.add(ipv4_name="ip2")
bgp_peer2 = bgp_int2.peers.add(name="bgp2")
v4_routes = bgp_peer2.v4_routes.add(name="route2")
v4_routes.addresses.add(address="20.20.0.0")
```
- Two interfaces on top of single port
- Two BGP peers map with Two interface
## IxNetwork Mapping
<img src="scr_bgp_4.png" alt="drawing" width="500"/>

- Add device multiplier ("2") according to the number of interfaces
- Compact all values related to Ethernet, IP and BGP. And configure those in respective rows
- Same router ID should configure
- Stack Multiplier should be 1 for all those stack

# Scenario-4: Single BGP and multiple Route Addresses
```python
device = config.devices.device(name="d1")[-1]
eth = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth.ipv4_addresses.ipv4(name="ip1")

bgp = device.bgp
bgp.router_id = "10.10.0.1"
bgp_int = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer = bgp_int.peers.add(name="bgp1")
v4_routes = bgp_peer.v4_routes.add(name="route1")
v4_routes.addresses.add(address="10.10.0.0")
v4_routes.addresses.add(address="20.20.0.0")
```
- Best practice to configure multiple routes.
- Anyway as model is supporting, we configured two addresses within same route

## IxNetwork Mapping
<img src="scr_bgp_1.png" alt="drawing" width="500"/>

- Create a Network group (NG) with multiplier 2
- We need to configured all route related properties("v4_routes") within two BGP Route range

# Scenario-5: Multiple devices with multiple different routes
```python
device1 = config.devices.device(name="d1")[-1]
device2 = config.devices.device(name="d2")[-1]

eth1 = device1.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth2 = device2.ethernets.ethernet(name='eth2', port_name="p1")[-1]
eth1.ipv4_addresses.ipv4(name="ip1")
eth2.ipv4_addresses.ipv4(name="ip2")

bgp1 = device1.bgp
bgp1.router_id = "1.1.1.1"
bgp_int1 = bgp1.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer1 = bgp_int1.peers.add(name="bgp1")
v4_routes1 = bgp_peer1.v4_routes.add(name="route1")
v4_routes1.addresses.add(address="10.10.0.0")

bgp2 = device2.bgp
bgp2.router_id = "1.1.1.2"
bgp_int2 = bgp2.ipv4_interfaces.add(ipv4_name="ip2")
bgp_peer2 = bgp_int2.peers.add(name="bgp2")
v4_routes2 = bgp_peer2.v4_routes.add(name="route2")
v4_routes2.addresses.add(address="20.20.0.0")
v6_routes2 = bgp_peer2.v6_routes.add(name="route3")
v6_routes2.addresses.add(address="3000:0:1:1:0:0:0:0")
```
- Two device configured on top of same port ("p1")
- First BGP Peer has one IPv4 route
- Second BGP Peer has one IPv4 and one IPv6 route
## IxNetwork Mapping
<img src="scr_bgp_4_route.png" alt="drawing" width="500"/>

- Add device multiplier ("2") according to the number of device
- Create two Network Group (IPv4 and IPv6)
- Disable first IPv6 within IPv6 Network Group

# Scenario-6: Single Interface and Multiple BGP Peer
```python
device = config.devices.device(name="d1")[-1]
eth1 = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth1.ipv4_addresses.ipv4(name="ip1")

bgp = device.bgp
bgp.router_id = "1.1.1.1"
bgp_int1 = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer1 = bgp_int1.peers.add(name="bgp1")
v4_routes1 = bgp_peer1.v4_routes.add(name="route1")
v4_routes1.addresses.add(address="10.10.0.0")
bgp_int2 = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer2 = bgp_int2.peers.add(name="bgp2")
v4_routes2 = bgp_peer2.v4_routes.add(name="route2")
v4_routes2.addresses.add(address="20.20.0.0")
```
- Single Ethernet and IP
- Two BGP peers map to single IP
## IxNetwork Mapping
<img src="scr_bgp_2.png" alt="drawing" width="500"/>

- Device multiplier set to 1
- IP stack Multiplier set to 1
- BGP stack Multiplier should set according to the number of BGP peers ("2")
- Compact all values related BGP. And configure those in respective rows.

# Scenario-7: 2Eth > 1IP in each eth > 2 BGP Peer in one IP and 1 BGP Peer in another IP
```python
device = config.devices.device(name="d1")[-1]
eth1 = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth2 = device.ethernets.ethernet(name='eth2', port_name="p1")[-1]
eth1.ipv4_addresses.ipv4(name="ip11")
eth2.ipv4_addresses.ipv4(name="ip21")

bgp = device.bgp
bgp.router_id = "1.1.1.1"
bgp_int1 = bgp.ipv4_interfaces.add(ipv4_name="ip11")
bgp_int1.peers.add(name="bgp11")
bgp_int1.peers.add(name="bgp12")
bgp_int3 = bgp.ipv4_interfaces.add(ipv4_name="ip21")
bgp_int3.peers.add(name="bgp21")
```
## IxNetwork Mapping
<img src="scr_bgp_6.png" alt="drawing" width="500"/>

- IxNetwork: DG Multiplier(2)
- IP stack Multiplier (1)
- BGP stack Multiplier (2)
- Max within Two BGP Peer. And disable one Peer within another set

# Scenario-8: BGP and interface top of Lag
```python
device = config.devices.device(name="d1")[-1]
eth = device.ethernets.ethernet(name='eth1', port_name="lag1")[-1]
eth.ipv4_addresses.ipv4(name="ip1")

bgp = device.bgp
bgp.router_id = "10.10.0.1"
bgp_int = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer = bgp_int.peers.add(name="bgp1")
bgp_peer.peer_address = "10.10.0.2"
bgp_peer.as_type = bgp_peer.IBGP
bgp_peer.as_number = 2
v4_routes = bgp_peer.v4_routes.add(name="route1")
v4_routes.addresses.add(address="10.10.0.0")
v4_routes = bgp_peer.v4_routes.add(name="route2")
v4_routes.addresses.add(address="20.20.0.0")
```
- Single ethernet(“eth1”) configurate on top of lag “lag1”
- Single IPv4(“ip1”) present on top of ethernet(“eth1”)
- Single BGP map with IPv4(“ip1”)
- Two v4_route configure on that bgp_peer
## IxNetwork Mapping
<img src="scr_bgp_1.png" alt="drawing" width="500"/>

- Create topology per Lag
- Ether, IP and BGP can map one to one
- Create network group (NG) according to v4_routes
- Use NG multiplier to accommodate number of address

# Scenario-9: (Not Supported) Add multiple IPv4 on top of an Ethernet
```python
device = config.devices.device(name="d1")[-1]
eth1 = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth1.ipv4_addresses.ipv4(name="ip1")
eth1.ipv4_addresses.ipv4(name="ip2")

bgp = device.bgp
bgp.router_id = "1.1.1.1"
bgp_int1 = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_peer1 = bgp_int1.peers.add(name="bgp1")
v4_routes = bgp_peer1.v4_routes.add(name="route1")
v4_routes.addresses.add(address="10.10.0.0")
bgp_int2 = bgp.ipv4_interfaces.add(ipv4_name="ip2")
bgp_peer2 = bgp_int2.peers.add(name="bgp2")
v4_routes = bgp_peer2.v4_routes.add(name="route2")
v4_routes.addresses.add(address="20.20.0.0")
```
- configured one Ethernet ("eth1")
- Try to map two IPv4 addresses ("ip1" and "ip2") on top of same ethernet ("eth1")
```diff
- Error when add multiple IPv4 on top of an Ethernet
```

# Scenario-10: (Not Supported) Single BGP run on two different ports
```python
device = config.devices.device(name="d1")[-1]
eth1 = device.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth2 = device.ethernets.ethernet(name='eth2', port_name="p2")[-1]
eth1.ipv4_addresses.ipv4(name="ip1")
eth2.ipv4_addresses.ipv4(name="ip2")

bgp = device.bgp
bgp.router_id = "1.1.1.1"
bgp_int1 = bgp.ipv4_interfaces.add(ipv4_name="ip1")
bgp_int1.peers.add(name="bgp1")
bgp_int2 = bgp.ipv4_interfaces.add(ipv4_name="ip2")
bgp_int2.peers.add(name="bgp2")
```
- Create one bgp
- Map two IP interfaces ("ip1" and "ip2")
```diff
- This should not be a valid use case and we will raise error
```

# Scenario-11: (Not Supported) BGP configure top of different device interface
```python
device1 = config.devices.device(name="d1")[-1]
device2 = config.devices.device(name="d2")[-1]

eth1 = device1.ethernets.ethernet(name='eth1', port_name="p1")[-1]
eth2 = device2.ethernets.ethernet(name='eth2', port_name="p1")[-1]
eth1.ipv4_addresses.ipv4(name="ip1")
eth2.ipv4_addresses.ipv4(name="ip2")

bgp1 = device1.bgp
bgp1.router_id = "1.1.1.1"
bgp_int1 = bgp1.ipv4_interfaces.add(ipv4_name="ip2")
```
- "bgp1" configured on top of "device1"
- Try to map interface "ip2" which is configured in different device ("device2")
```diff
- We will raise error
- Same also true for loopback interafce (we will revisit for loopback)
```
Binary file added docs/deviceUsecase/scr_bgp_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_4_route.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/deviceUsecase/scr_bgp_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# snappi Extension for IxNetwork
# Snappi Extension for IxNetwork
[![license](https://img.shields.io/badge/license-MIT-green.svg)](https://en.wikipedia.org/wiki/MIT_License)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Build](https://github.com/open-traffic-generator/snappi-ixnetwork/workflows/Build/badge.svg)](https://github.com/open-traffic-generator/snappi-ixnetwork/actions)
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import setuptools

pkg_name = "snappi_ixnetwork"
version = "0.5.6"
version = "0.5.4"

# read long description from readme.md
base_dir = os.path.abspath(os.path.dirname(__file__))
Expand Down Expand Up @@ -37,8 +37,8 @@
install_requires=["ixnetwork-restpy>=1.0.52"],
extras_require={
"testing": [
"snappi==0.5.8",
"snappi_convergence==0.1.1",
"snappi==0.7.1",
"snappi_convergence==0.2.2",
"pytest",
"mock",
"dpkt==1.9.4",
Expand Down
Loading

0 comments on commit 751b681

Please sign in to comment.