Documentation ¶
Overview ¶
Package util contains necessary type definitions and helper methods for tgc, tgen and tapp modules
Index ¶
- Constants
- func GetInterfaces() (*types.InterfaceResponse, error)
- func GetMessageHeaderLength() (int, error)
- func GetNetInterfaces() (map[string]string, error)
- func GetPaddingPayload(payloadSize int) ([]byte, error)
- func GetResolvableAddress(ip string) (address string, err error)
- func GetTimestampMicroSec() int64
- func IsIPv4(ipAddress string) bool
- func IsIPv6(ipAddress string) bool
- func MicroSecToDuration(msec int) time.Duration
- func NewCounter(namespace, subsystem, name, help string, labelMap map[string]string) prometheus.Counter
- func NewGauge(namespace, subsystem, name, help string, labelMap map[string]string) prometheus.Gauge
- func NewSummary(namespace, subsystem, name, help string, labelMap map[string]string, ...) prometheus.Summary
- func RegisterPromHandler(promPort int, reg *prometheus.Registry)
- func SecToMicroSec(sec int) int
- type BatPair
- type ClientImpl
- type Config
- type EnvResponse
- type Error
- type Message
- type PodInfo
- type ProtocolClientModule
- type ProtocolServerModule
- type Remote
- type Server
- type ServerImpl
- type Source
Constants ¶
const (
// PromNamespace prometheus udp namespace string
PromNamespace = "netbat"
)
Variables ¶
This section is empty.
Functions ¶
func GetInterfaces ¶
func GetInterfaces() (*types.InterfaceResponse, error)
GetInterfaces get interfaces from /etc/podinfo/annotations file
func GetMessageHeaderLength ¶
GetMessageHeaderLength get message header length
func GetNetInterfaces ¶
GetNetInterfaces return interfaces map[name]ipAddress
func GetPaddingPayload ¶
GetPaddingPayload get payload for the given length
func GetResolvableAddress ¶
GetResolvableAddress get resolvable address for given ip address
func GetTimestampMicroSec ¶
func GetTimestampMicroSec() int64
GetTimestampMicroSec get timestamp in microseconds
func MicroSecToDuration ¶
MicroSecToDuration convert give msec into duration
func NewCounter ¶
func NewCounter(namespace, subsystem, name, help string, labelMap map[string]string) prometheus.Counter
NewCounter API to create a new counter
func NewGauge ¶
func NewGauge(namespace, subsystem, name, help string, labelMap map[string]string) prometheus.Gauge
NewGauge API to create a new gauge metric
func NewSummary ¶
func NewSummary(namespace, subsystem, name, help string, labelMap map[string]string, objectives map[float64]float64) prometheus.Summary
NewSummary API to create a new summary metric
func RegisterPromHandler ¶
func RegisterPromHandler(promPort int, reg *prometheus.Registry)
RegisterPromHandler register prometheus http handler
func SecToMicroSec ¶
SecToMicroSec convert given seconds into microseconds
Types ¶
type BatPair ¶
type BatPair struct { Source *Source Destination *Remote TrafficProfile string TrafficScenario string PendingRequestsMap map[int64]int64 ClientConnection ClientImpl }
BatPair represents the BAT traffic to be run between two entities
type ClientImpl ¶
type ClientImpl interface { SetupConnection() error TearDownConnection() SocketRead() HandleTimeouts() StartPackets() }
ClientImpl methods to be implemented by a client
type Config ¶
type Config interface { SuspendTraffic() bool GetProfileMap() map[string]map[string]string GetResourceVersion() string }
Config interface
func LoadConfig ¶
LoadConfig parse the config map and returns Config
type Message ¶
type Message struct { SequenceNumber int64 SendTimeStamp int64 RespondTimeStamp int64 ServerInfoLength int Length int }
Message to be sent and received by protocol clients
func NewMessage ¶
NewMessage creates a new message
type ProtocolClientModule ¶
type ProtocolClientModule interface { CreateClient(p *BatPair, readBufferSize int, reg *prometheus.Registry) (ClientImpl, error) LoadBatProfileConfig(profileMap map[string]map[string]string) error }
ProtocolClientModule contract to create protocol clients and loading its config
type ProtocolServerModule ¶
type ProtocolServerModule interface { CreateServer(namespace, podName, nodeName, ipAddress, ifName string, readBufferSize int, reg *prometheus.Registry) (ServerImpl, error) LoadBatProfileConfig(profileMap map[string]map[string]string) error }
ProtocolServerModule contract to create protocol servers and loading its config
type ServerImpl ¶
type ServerImpl interface { SetupServerConnection() error ReadFromSocket() HandleIdleConnections() TearDownServer() }
ServerImpl methods to be implemented by a server