From 1db55462d9b5b1b531739c0d47a82f290b694e29 Mon Sep 17 00:00:00 2001 From: bunert <32924537+bunert@users.noreply.github.com> Date: Mon, 12 Sep 2022 17:37:03 +0200 Subject: [PATCH] cmd/scion: add a ping flag that allows setting the final packet size (#4251) The new flag `packet-size` allows specifying the size of the packet, which takes the variable header size into account. The new flag overwrites the `payload-size` flag similar to how the `max-mtu` flag handles it, while the `max-mtu` flag now overrides the `payload-size` and the `packet-size` flag. --- scion/cmd/scion/ping.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/scion/cmd/scion/ping.go b/scion/cmd/scion/ping.go index 987a307398..9500fdf9d9 100644 --- a/scion/cmd/scion/ping.go +++ b/scion/cmd/scion/ping.go @@ -53,6 +53,7 @@ func newPing(pather CommandPather) *cobra.Command { healthyOnly bool sequence string size uint + pktSize uint timeout time.Duration tracer string epic bool @@ -180,6 +181,19 @@ On other errors, ping will exit with code 2. Host: &net.UDPAddr{IP: localIP}, } pldSize := int(flags.size) + + if cmd.Flags().Changed("packet-size") { + overhead, err := ping.Size(local, remote, 0) + if err != nil { + return err + } + if overhead > int(flags.pktSize) { + return serrors.New( + "desired packet size smaller than header overhead", + "minimum_packet_size", overhead) + } + pldSize = int(flags.pktSize - uint(overhead)) + } if flags.maxMTU { mtu := int(path.Metadata().MTU) pldSize, err = calcMaxPldSize(local, remote, mtu) @@ -249,11 +263,16 @@ On other errors, ping will exit with code 2. `number of bytes to be sent in addition to the SCION Header and SCMP echo header; the total size of the packet is still variable size due to the variable size of the SCION path.`, + ) + cmd.Flags().UintVar(&flags.pktSize, "packet-size", 0, + `number of bytes to be sent including the SCION Header and SCMP echo header, +the desired size must provide enough space for the required headers. This flag +overrides the 'payload_size' flag.`, ) cmd.Flags().BoolVar(&flags.maxMTU, "max-mtu", false, `choose the payload size such that the sent SCION packet including the SCION Header, SCMP echo header and payload are equal to the MTU of the path. This flag overrides the -'payload_size' flag.`) +'payload_size' and 'packet_size' flags.`) cmd.Flags().StringVar(&flags.logLevel, "log.level", "", app.LogLevelUsage) cmd.Flags().StringVar(&flags.tracer, "tracing.agent", "", "Tracing agent address") cmd.Flags().BoolVar(&flags.epic, "epic", false, "Enable EPIC for path probing.")