-
Hi @florianl I am trying to set a basic netem delay/latency, and likely do something wrong, because when I apply the netem to an interface, all traffic is stopped over this iface. This is how I do it: // open tc session
tcnl, err := tc.Open(&tc.Config{
NetNS: nsFd,
})
if err != nil {
return err
}
defer func() {
if err := tcnl.Close(); err != nil {
log.Errorf("could not close rtnetlink socket: %v\n", err)
}
}()
err = tcnl.SetOption(netlink.ExtendedAcknowledge, true)
if err != nil {
return fmt.Errorf("could not set option ExtendedAcknowledge: %v", err)
}
qdisc := tc.Object{
Msg: tc.Msg{
Family: unix.AF_UNSPEC,
Ifindex: uint32(link.Index),
Handle: core.BuildHandle(0x1, 0x0),
Parent: tc.HandleRoot,
Info: 0,
},
Attribute: tc.Attribute{
Kind: "netem",
Netem: &tc.Netem{},
},
}
delay64 := delay.Milliseconds() // delay is time.Duration
qdisc.Attribute.Netem.Latency64 = &delay64
err = tcnl.Qdisc().Replace(&qdisc)
if err != nil {
return err
} When I print out the resulting netem on that interface I get:
|
Beta Was this translation helpful? Give feedback.
Answered by
florianl
Jul 29, 2023
Replies: 1 comment 2 replies
-
Hi @hellt
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
hellt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @hellt
Latency64
is not the correct attribute for this use case. Here is an example fortc qdisc add dev tcDev root netem delay 100ms
: