From 44c3873d0422080d5ea1e1b965bef2b010e5657c Mon Sep 17 00:00:00 2001 From: Charan <123436521+charans29@users.noreply.github.com> Date: Mon, 27 May 2024 23:56:01 -0700 Subject: [PATCH] #361 Issue: Update SetLatencyAndJitter func of Go doc (#366) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * doc Update on SetLatencyAndJitter func * Update on SetLatencyAndJitter func doc * doc update with example --------- Co-authored-by: Jose Ramon MaƱes <32740567+jrmanes@users.noreply.github.com> --- pkg/knuu/instance.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/knuu/instance.go b/pkg/knuu/instance.go index 6e207a6..5cc5278 100644 --- a/pkg/knuu/instance.go +++ b/pkg/knuu/instance.go @@ -1199,11 +1199,17 @@ func (i *Instance) SetBandwidthLimit(limit int64) error { return nil } -// SetLatency sets the latency of the instance -// latency in ms (e.g. 1000 for 1s) -// jitter in ms (e.g. 1000 for 1s) -// Currently, only one of bandwidth, jitter, latency or packet loss can be set -// This function can only be called in the state 'Commited' +// SetLatencyAndJitter simulates variable network conditions by applying both latency and jitter to packet transmission. +// Latency establishes a base delay, while jitter adds variability that can lead to packet reordering, mimicking real-world network behavior. +// Example: +// To set a latency of 100ms and jitter of 75ms: +// err := instance.SetLatencyAndJitter(100, 75) +// if err != nil { +// log.Fatalf("Error: %v", err) +// } +// With this configuration, if one packet is assigned a 100ms delay and the following packet has a delay of only 50ms, +// the second packet may be transmitted first. This is due to the jitter, which can cause variability in delay times, +// allowing subsequent packets to potentially be sent earlier than those queued before them. func (i *Instance) SetLatencyAndJitter(latency, jitter int64) error { if !i.IsInState(Started) { return ErrSettingLatencyJitterNotAllowed.WithParams(i.state.String())