Skip to content

Commit

Permalink
cmd/scion: add a ping flag that allows setting the final packet size (s…
Browse files Browse the repository at this point in the history
…cionproto#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.
  • Loading branch information
bunert authored and benthor committed Nov 24, 2022
1 parent 944972e commit 1db5546
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion scion/cmd/scion/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.")
Expand Down

0 comments on commit 1db5546

Please sign in to comment.