dummy

package
v4.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2023 License: BSD-2-Clause, BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Paused  = false
	Running = true
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager manages the sending of dummy messages.

func NewManager

func NewManager(maxNumMessages int,
	avgSendDelta, randomRange time.Duration,
	net *xxdk.Cmix) *Manager

NewManager creates a DummyTraffic manager and initialises the dummy traffic sending thread. Note that the manager is by default paused, and as such the sending thread must be started by calling DummyTraffic.Start. The time duration between each sending operation and the amount of messages sent each interval are randomly generated values with bounds defined by the given parameters below.

Params:

  • maxNumMessages - the upper bound of the random number of messages sent each sending cycle.
  • avgSendDeltaMS - the average duration, in milliseconds, to wait between sends.
  • randomRangeMS - the upper bound of the interval between sending cycles, in milliseconds. Sends occur every avgSendDeltaMS +/- a random duration with an upper bound of randomRangeMS.

func (*Manager) GetStatus

func (m *Manager) GetStatus() bool

GetStatus returns the current state of the DummyTraffic manager's sending thread. Note that the status returned here may lag behind a user's earlier call to pause the sending thread. This is a result of a small delay (see DummyTraffic.Pause for more details)

Returns:

  • bool - Returns true (dummy.Running) if the sending thread is sending messages and false (dummy.Paused) if the sending thread is not sending messages.

func (*Manager) Pause added in v4.4.4

func (m *Manager) Pause() error

Pause will pause the Manager's sending thread, meaning messages will no longer be sent. After calling Pause, the sending thread may only be resumed by calling Start.

There may be a small delay between this call and the pause taking effect. This is because Pause will not cancel the thread when it is in the process of sending messages, but will instead wait for that thread to complete. The thread will then be prevented from beginning another round of sending.

func (*Manager) Start added in v4.4.4

func (m *Manager) Start() error

Start will start up the Manager's sending thread, meaning messages will

be sent. This should be called after calling NewManager, as by default the
thread is paused. This may also be called after a call to Pause.

This will re-initialize the sending thread with a new randomly generated interval between sending dummy messages. This means that there is zero guarantee that the sending interval prior to pausing will be the same sending interval after a call to Start.

func (*Manager) StartDummyTraffic

func (m *Manager) StartDummyTraffic() (stoppable.Stoppable, error)

StartDummyTraffic starts the process of sending dummy traffic. This function adheres to xxdk.Service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL