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

cmd/scion: add a ping flag that allows setting the final packet size #4251

Merged
merged 6 commits into from
Sep 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 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,20 @@ 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")
}

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 +264,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' flag.`)
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