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

IP options in IPv4 header #349

Merged
merged 32 commits into from
Jan 15, 2024
Merged

IP options in IPv4 header #349

merged 32 commits into from
Jan 15, 2024

Conversation

indraniBh
Copy link
Contributor

@indraniBh indraniBh commented Dec 6, 2023

ReDocly link:
ReDoc Interactive Demo (redocly.github.io)

( New object at : set_config/flows/packet/ipv4/options )

IPv4 RFC: RFC791
Router Alert Option RFC: RFC2113
IPv4 Options parameters

Objective: IPv4 options are optional extensions for the IPv4 header that can be utilised to provide additional information about the IPv4 datagram. It is encoded as a series of type, length and value attributes. The IP header length MUST be increased to accommodate the extra bytes needed to encode the IP options.
Currently IP options supported are:

  1. router_alert Option allows devices to intercept packets not addressed to them directly as defined in RFC2113.
  2. custom option is provided for to be able to configure user defined IP options as needed.
    IPv4 Options is an array option objects.
    To support RSVP control packet, router alert option is required in IP header.

Sample IPv4 Options (Router Alert and Custom):

        srcIP := "10.10.0.1"
	dstIP := "10.10.0.2"

	config := gosnappi.NewConfig()
	// add ports
	p1 := config.Ports().Add().SetName("p1").SetLocation("eth1")
	p2 := config.Ports().Add().SetName("p2").SetLocation("eth2")

	f1 := config.Flows().Items()[0]
	f1.SetName("f1:p1->p2").
		TxRx().Port().SetTxName(p1.Name()).SetRxName(p2.Name())
	f1.Duration().FixedPackets().SetPackets(100)
	f1.Rate().SetPps(10)

	f1.Packet().Add().Ethernet()
	ip := f1.Packet().Add().Ipv4()

	ip.Src().SetChoice("value").SetValue(srcIP)
	ip.Dst().SetChoice("value").SetValue(dstIP)

	// Sample of router_alert option:
	ip.Options().Add().SetChoice("router_alert")

	// Sample of user defined custom TLV options (Stream ID)
	ipOptionCustom := ip.Options().Add().SetChoice("custom")
	ipOptionCustom.Custom().Type().CopiedFlag().SetChoice("value").SetValue(0)
	ipOptionCustom.Custom().Type().OptionClass().SetChoice("value").SetValue(0)
	ipOptionCustom.Custom().Type().OptionNumber().SetChoice("value").SetValue(8)

	ipOptionCustom.Custom().Length().SetChoice("value").SetValue(4)
	ipOptionCustom.Custom().SetValue("0088")

@indraniBh indraniBh added the enhancement New feature or request label Dec 6, 2023
@rudranil-das
Copy link
Contributor

Please update example by actually adding item in ip.Options() for usage in each of the choices

Copy link
Contributor

@rudranil-das rudranil-das left a comment

Choose a reason for hiding this comment

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

rest LGTM

flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
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.

Minor documentation comments. Rest looks good to me.

flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
flow/packet-headers/ipv4.yaml Outdated Show resolved Hide resolved
@apratimmukherjee
Copy link
Contributor

Please update the example to reflect the changes for adding custom option. Also need to actually add option to packet template I think as @rudranil-das had mentioned to make it a valid snippet.

@indraniBh
Copy link
Contributor Author

Updated code snippet. @rudranil-das @apratimmukherjee

@indraniBh indraniBh merged commit 09e957c into master Jan 15, 2024
@indraniBh indraniBh deleted the dev-ip-options branch January 15, 2024 09:07
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.

4 participants