Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support of DHCPV4 & Client and Server #361

Open
wants to merge 68 commits into
base: master
Choose a base branch
from
Open

Conversation

SuryyaKrJana
Copy link
Contributor

@SuryyaKrJana SuryyaKrJana commented Mar 13, 2024

https://redocly.github.io/redoc/?url=https://raw.githubusercontent.com/open-traffic-generator/models/dhcp_support_pr/artifacts/openapi.yaml&nocors

_This model is designed to take care of following implementation: _
1. DHCP Client & Server are Keysight and Relay Agent as DUT:
In this the construct dhcp_v4interfaces and dhcp_v4interfaces are exposed under an Ethernet Interface to configure DHCP Client parameters. The configuration of a DHCP client is placed under Ethernet Interface as parallel to IP configuration as protocol like BGP can be configured referring an IP interface or a DHCP interface.
2. DHCP Client Behind the Relay Agent and are Keysight and DHCP Server as Keysight/DUT:
In this case DHCP client sits beside the Relay Agent that runs on top of connection Interfaces.
Hence new in chained_ethernet_name connection type in Connection under Ethernets Interface under the Device. This chained Ethernet can be linked to another chained Ethernet or a connected Ethernet interface.
dhcp_v4interface and dhcp_v4interface are exposed under a Chained Ethernet interface to configure DHCP Client parameters.
3. BGP peer can be configured on top of DHCP interface:
BGP peer is to refer ipv4_name or ipv6_name for IPv4/IPv6 connected or loopback interfaces. Now BGP peer can also refer to dhcp_v4interface or dhcp_v6interface interfaces.

_Please note that DHCPv6 Client & Server and V4/V6 Relay-Agent are just place holders to show position of these when will come into implementation. _

example-1

`
// Case-1: DHCP Client & Server are Keysight and Relay Agent as DUT.
// DHCPV4-Client(x.x.x.x)<-------> (1.1.1.1)RelayAgent(DUT)(2.2.2.1) <------>(2.2.2.2) DHCPV4-Server(Pool: 100.1.1.1)
// DHCP Client is configured on connected interface.

```

config := gosnappi.NewConfig()
// add ports
p1 := config.Ports().Add().SetName("p1").SetLocation(opts.IxiaCPorts()[0])
p2 := config.Ports().Add().SetName("p2").SetLocation(opts.IxiaCPorts()[1])

// add devices
d1 := config.Devices().Add().SetName("p1d1")
d2 := config.Devices().Add().SetName("p2d1")

// add protocol stacks for device d1
d1Eth1 := d1.Ethernets().
	Add().
	SetName("p1d1eth").
	SetMac("00:00:01:01:01:01").
	SetMtu(1500)
d1Eth1.Connection().SetPortName(p1.Name())

p1d1DhcpV4Client := d1Eth1.
	DhcpV4interfacea().Add().
	SetName("p1d1dhcpv4").
	SetEthName(d1Eth1.Name())

// add protocol stacks for device d2
d2Eth1 := d2.Ethernets().
	Add().
	SetName("p2d1eth").
	SetMac("00:00:02:02:02:02").
	SetMtu(1500)
d2Eth1.Connection().SetPortName(p2.Name())

d2p2Ipv4 := d2Eth1.
	Ipv4Addresses().
	Add().
	SetName("p2d1ipv4").
	SetAddress("2.2.2.2").
	SetGateway("2.2.2.1").
	SetPrefix(32)

d2p2DhcpServerv4Iface1 := d2.DhcpServer().V4Server().
	Ipv4Interfaces().Add().
	SetIpv4Name("p2d1ipv4") //

p2d2DhcpV4Server := d2Dhcpv4Iface1.
	v4().
	SetName("p2d2DhcpV4Server")

p2d2DhcpV4Server.SetLeaseTime(1000).
	SetPoolSize(100).
	SetStartPoolAddress("100.1.1.1").
	SetPrefix(24).
	SetStep(1)
// Case-2: DHCP Client Behind the Relay Agent and are Keysight and DHCP Server as Keysight/DUT.
// DHCPV4-Client(x.x.x.x)<------->(100.1.1.1)RelayAgent(DUT)(2.2.2.1) <------>(2.2.2.2) DHCPV4-Server(Pool: 100.1.1.1)
// DHCP Client is configured on unconnected connected interface.

	```
config := gosnappi.NewConfig()

	// add ports
	p1 := config.Ports().Add().SetName("p1").SetLocation(opts.IxiaCPorts()[0])
	p2 := config.Ports().Add().SetName("p2").SetLocation(opts.IxiaCPorts()[1])

	// add devices
	d1 := config.Devices().Add().SetName("p1d1")
	d1_chained := config.Devices().Add().SetName("p1d1_chained")

	d2 := config.Devices().Add().SetName("p2d1")

	// add protocol stacks for device d1 where Relay Agent will be configureds
	d1Eth1 := d1.Ethernets().
		Add().
		SetName("p1d1eth").
		SetMac("00:00:01:01:01:01").
		SetMtu(1500)
	d1Eth1.Connection().SetPortName(p1.Name())

// Configure a IPv4 stack
	d1p1Ipv4 := d1Eth1.
		Ipv4Addresses().
		Add().
		SetName("p1d1ipv4").
		SetAddress("2.2.2.1").
		SetGateway("2.2.2.2").
		SetPrefix(24)

	// Configure a (place holder) Relay Agent
	d1p1RelayAgent := d2.RelayAgent()
	  IpV4interfaces().Add().V4RAInst().
		SetName("d1p1RelayAgent1").
		SetIpv4Name(d1p1Ipv4.Name()).
		SetCliendSideAddress("100.1.1.1")
		SetDhcpServer("2.2.2.2")

 // Chained Ethernet where DHCPClient behind the Relay Agent will be configured.
	d1ChainedEth2 := d1.Ethernets().
		Add().
		SetName("p1d1eth2_chained").
		SetMac("00:00:01:01:01:01").
	d1Eth1.Connection().SetChainedEthernetName(d1Eth1.Name())

	p1d1DhcpV4Client := d1ChainedEth2.
		DhcpV4interfaces().Add()
		SetName("p1d1dhcpv4")
	
	// add protocol stacks for device d2
	d2Eth1 := d2.Ethernets().
		Add().
		SetName("p2d1eth").
		SetMac("00:00:02:02:02:02").
		SetMtu(1500)

	d2Eth1.Connection().SetPortName(p2.Name())

	d2p2Ipv4 := d2Eth1.
		Ipv4Addresses().
		Add().
		SetName("p2d1ipv4").
		SetAddress("2.2.2.2").
		SetGateway("2.2.2.1").
		SetPrefix(24)

	d2p2DhcpServerv4Iface1 := d2.DhcpServer().V4Server().
		Ipv4Interfaces().Add().
		SetIpv4Name("p2d1ipv4") //

	p2d2DhcpV4Server := d2Dhcpv4Iface1.
		v4().
		SetName("p2d2DhcpV4Server")

	p2d2DhcpV4Server.SetLeaseTime(1000).
		SetPoolSize(100).
		SetStartPoolAddress("100.1.1.2").
		SetPrefix(24).
		SetStep(1)

//Case-3: BGP over DHCP Client on Port 1 & DHCP Server and BGP peer (over loopback)on Port2.
   ```

config := gosnappi.NewConfig()

// add ports
p1 := config.Ports().Add().SetName("p1").SetLocation(opts.IxiaCPorts()[0])
p2 := config.Ports().Add().SetName("p2").SetLocation(opts.IxiaCPorts()[1])

// add devices
d1 := config.Devices().Add().SetName("p1d1")
d2 := config.Devices().Add().SetName("p2d1")
p2Chained1 := config.Devices().Add().SetName("p2_chained1")

// add protocol stacks for device d1
d1Eth1 := d1.Ethernets().
	Add().
	SetName("p1d1eth").
	SetMac("00:00:01:01:01:01").
	SetMtu(1500)

d1Eth1.Connection().SetPortName(p1.Name())

p1d1DhcpV4Client := d1Eth1.
	DhcpV4interfaces().Add().
	SetName("p1d1dhcpv4").
	SetEthName(d1Eth1.Name())

d1Bgp := d1.Bgp().
	SetRouterId("1.1.1.2")

// Link with DHCP Client name
d1BgpIpv4Interface1 := d1Bgp.
	Ipv4Interfaces().Add().
	SetIpv4Name(p1d1DhcpV4Client.Name())

d1BgpIpv4Interface1Peer1 := d1BgpIpv4Interface1.
	Peers().
	Add().
	SetAsNumber(2222).
	SetAsType(gosnappi.BgpV4PeerAsType.EBGP).
	SetPeerAddress("22.22.22.1").
	SetName("p1d1bgpv4")

d1BgpIpv4Interface1Peer1V4Route1 := d1BgpIpv4Interface1Peer1.
	V4Routes().
	Add().
	SetNextHopIpv4Address("1.1.1.2").
	SetName("p1d1peer1rrv4").
	SetNextHopAddressType(gosnappi.BgpV4RouteRangeNextHopAddressType.IPV4).
	SetNextHopMode(gosnappi.BgpV4RouteRangeNextHopMode.MANUAL)

d1BgpIpv4Interface1Peer1V4Route1.Addresses().Add().
	SetAddress("100.10.10.1").
	SetPrefix(32).
	SetCount(4).
	SetStep(1)

d1BgpIpv4Interface1Peer1V4Route1.Advanced().
	SetMultiExitDiscriminator(50).
	SetOrigin(gosnappi.BgpRouteAdvancedOrigin.EGP)

	// add protocol stacks for device d2
d2Eth1 := d2.Ethernets().
	Add().
	SetName("p2d1eth").
	SetMac("00:00:02:02:02:02").
	SetMtu(1500)

d2Eth1.Connection().SetPortName(p2.Name())

d2p2Ipv4 := d2Eth1.
	Ipv4Addresses().
	Add().
	SetName("p2d1ipv4").
	SetAddress("2.2.2.2").
	SetGateway("2.2.2.1").
	SetPrefix(32)

d2p2DhcpServerv4Iface1 := d2.DhcpServer().V4Server().
	Ipv4Interfaces().Add().
	SetIpv4Name("p2d1ipv4") //

p2d2DhcpV4Server := d2Dhcpv4Iface1.
	v4().
	SetName("p2d2DhcpV4Server")

p2d2DhcpV4Server.SetLeaseTime(1000).
	SetPoolSize(100).
	SetStartPoolAddress("21.21.21.1").
	SetPrefix(24).
SetStep(1)

// Port2 first chained device.
p2Lo1 := p2Chained1.Ipv4Loopbacks().
Add().
SetName("p2chaineddev1.v4lo1").
SetAddress("22.22.22.1").
SetEthName(d1Eth1.Name())

p2Lo1Bgp := p2Chained1.Bgp().
	SetRouterId(p2Lo1.Address())

p2Lo1BgpIpv4Interface1 := p2Lo1Bgp.
	Ipv4Interfaces().Add().
	SetIpv4Name("p2chaineddev1.v4lo1")

p2Lo1BgpIpv4Interface1Peer1 := p2Lo1BgpIpv4Interface1.
	Peers().
	Add().
	SetAsNumber(1111).
	SetAsType(gosnappi.BgpV4PeerAsType.IBGP).
	SetPeerAddress("21.21.21.1").
	SetName("p2lo1bgpv4")

p2Lo1BgpIpv4Interface1Peer1V4Route1 := p2Lo1BgpIpv4Interface1Peer1.
	V4Routes().
	Add().
	SetName("p2lo1peer1rrv4")

p2Lo1BgpRrAddr := p2Lo1BgpIpv4Interface1Peer1V4Route1.Addresses().Add().
	SetAddress("200.1.1.1").
	SetPrefix(32)

p2Lo1BgpIpv4Interface1Peer1V4Route1.Advanced().
	SetMultiExitDiscriminator(50).
	SetOrigin(gosnappi.BgpRouteAdvancedOrigin.EGP)
`

@@ -0,0 +1,30 @@
components:
schemas:
DhcpServer.V4:
Copy link
Contributor

@alakendu alakendu Apr 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name would be DhcpServer.V4Interface which is align with BGP (Bgp.V4Interface). Also this object acts like an interface.
Same also true for Dhcpv6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DHCPv4 OTG Model
7 participants