Skip to content

Conversation

SuryyaKrJana
Copy link
Contributor

@SuryyaKrJana SuryyaKrJana commented Sep 15, 2025

OTG Model: BGP MPLS Labeled IPv4/IPv6 Unicast

  1. Added provision for MPLS IPv4/IPv6 capabilities device.bgp.capablity.ipv4_mpls/bgp.capabliti.ipv6_mpls or for multiple labels device.bgp.capablity.ipv4_mpls_multi/bgp.capabliti.ipv6_mpls_multi
  2. Added provision for adding one or more MPLS Label BGP V4/V6 route ranges.

Redocly References:
Redocly

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

	d1BgpIpv4Interface1 := d1Bgp.
		Ipv4Interfaces().Add().
		SetIpv4Name("p1d1ipv4")

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

	/*  Configure Mpls Single Label Capability */
	d1BgpIpv4Interface1Peer1.Capability().SetIpv4Mpls(true).SetIpv6Mpls(true)

	/* If it is needed to send multiple Labels, say, 2 labels then
	   d1BgpIpv4Interface1Peer1.Capability().SetIpv4MplsMulti(2).SetIpv6MplsMulti(2)
	*/

	d1BgpIpv4Interface1Peer1V4Route1 := d1BgpIpv4Interface1Peer1.
		V4Routes().
		Add().
		SetName("p1d1peer1rrv4")

	d1BgpIpv4Interface1Peer1V4Route1.Addresses().Add().
		SetAddress("10.10.10.1").
		SetPrefix(32).
		SetCount(2)

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

	Peer1MplsLabels :=
		d1BgpIpv4Interface1Peer1V4Route1.MplsLabels()

	Peer1MplsLabels.Labels().Add().SetStart(16000)

	/* For adding another Label in case of added multi-lable capability
	   Peer1MplsLabels.Labels().Add().SetStart(17000)
	*/

	// 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())

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

	d2Bgp := d2.Bgp().
		SetRouterId("2.2.2.2")

	d2BgpIpv4Interface1 := d2Bgp.
		Ipv4Interfaces().Add().
		SetIpv4Name("p2d1ipv4")

	d2BgpIpv4Interface1Peer1 := d2BgpIpv4Interface1.
		Peers().
		Add().
		SetAsNumber(3333).
		SetAsType(gosnappi.BgpV4PeerAsType.EBGP).
		SetPeerAddress("2.2.2.1").
		SetName("p2d1bgpv4")

	d1BgpIpv4Interface1Peer1.Capability().SetIpv4MplsMulti(2).SetIpv6MplsMulti(2)

	d2BgpIpv4Interface1Peer1V4Route1 := d2BgpIpv4Interface1Peer1.
		V4Routes().
		Add().
		SetName("p2d1peer1rrv4")

	d2BgpIpv4Interface1Peer1V4Route1.Addresses().Add().
		SetAddress("20.20.20.1").
		SetPrefix(32).
		SetCount(2)

	d2BgpIpv4Interface1Peer1V4Route1.Advanced().
		SetMultiExitDiscriminator(40).
		SetOrigin(gosnappi.BgpRouteAdvancedOrigin.EGP)

	Peer2V4Route1Label :=
		d2BgpIpv4Interface1Peer1V4Route1.MplsLabels()

	Peer2V4Route1Label.Labels().Add().SetStart(1000)
	Peer2V4Route1Label.Labels().Add().SetStart(2000)

	// add endpoints and packet description flow 1
	f1 := config.Flows().Items()[0]
	f1.SetName(p1.Name() + " -> " + p2.Name()).
		TxRx().Device().
		SetTxNames([]string{d1BgpIpv4Interface1Peer1V4Route1.Name()}).
		SetRxNames([]string{d2BgpIpv4Interface1Peer1V4Route1.Name()})

	f1Eth := f1.Packet().Add().Ethernet()
	f1Eth.Src().SetValue(d1Eth1.Mac())
	f1Eth.Dst().Auto()

	f1Mpls := f1.Packet().Add().Mpls()

	/* MPLS-IPv4 Labeled SIDs 16000  plus 1000 & 2000 were advertised from BGP Peer 2 */
	f1Mpls.Label().SetValue(uint32(17000))
	f1Mpls.Label().SetValue(uint32(18000))
	f1Mpls.TrafficClass().SetValues([]uint32{1, 2})

	f1Ip := f1.Packet().Add().Ipv4()
	f1Ip.Src().SetValue("10.10.10.1")
	f1Ip.Dst().SetValue("20.20.20.1")

	// add endpoints and packet description flow 2
	f2 := config.Flows().Items()[1]
	f2.SetName(p2.Name() + " -> " + p1.Name()).
		TxRx().Device().
		SetTxNames([]string{d2BgpIpv4Interface1Peer1V4Route1.Name()}).
		SetRxNames([]string{d1BgpIpv4Interface1Peer1V4Route1.Name()})

	f2Eth := f2.Packet().Add().Ethernet()
	f2Eth.Src().SetValue(d2Eth1.Mac())
	f2Eth.Dst().Auto()

	f2Mpls := f2.Packet().Add().Mpls()
	/* IPv4 Labeled SIDs 16000 was advertised from BGP Peer 1 */
	f2Mpls.Label().SetValue(uint32(16000))

	f2Ip := f2.Packet().Add().Ipv4()
	f2Ip.Src().SetValue("20.20.20.1")
	f2Ip.Dst().SetValue("10.10.10.1")

Copy link
Contributor

@apratimmukherjee apratimmukherjee left a comment

Choose a reason for hiding this comment

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

Some minor comments + query on disabling multi_label capability

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.

3 participants