Documentation
¶
Overview ¶
Package netlab provides virtual network simulation for protocol testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LinkConfig ¶
type LinkConfig struct {
From string `json:"from"`
To string `json:"to"`
Latency time.Duration `json:"latency"`
LossRate float64 `json:"loss_rate"` // 0.0 to 1.0
Bandwidth int64 `json:"bandwidth"` // bytes per second
}
LinkConfig defines a virtual network link.
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
Network is a running virtual network.
func NewNetwork ¶
func NewNetwork(config *NetworkConfig) *Network
NewNetwork creates a virtual network from config.
func (*Network) SimulateTraffic ¶
func (n *Network) SimulateTraffic(from, to string, pattern TrafficPattern) *SimResult
SimulateTraffic simulates traffic between two nodes.
type NetworkConfig ¶
type NetworkConfig struct {
Name string `json:"name"`
Nodes []NodeConfig `json:"nodes"`
Links []LinkConfig `json:"links"`
}
NetworkConfig defines a virtual network topology.
type NodeConfig ¶
type NodeConfig struct {
ID string `json:"id"`
Type string `json:"type"` // "host", "router", "switch"
IP string `json:"ip"`
Protocol string `json:"protocol,omitempty"`
}
NodeConfig defines a virtual network node.
type SimResult ¶
type SimResult struct {
From string `json:"from"`
To string `json:"to"`
TotalPackets int `json:"total_packets"`
Delivered int `json:"delivered"`
Dropped int `json:"dropped"`
DeliveryRate float64 `json:"delivery_rate"`
AvgLatency time.Duration `json:"avg_latency"`
Error string `json:"error,omitempty"`
}
SimResult holds simulation results.
type TrafficPattern ¶
type TrafficPattern struct {
Type string `json:"type"` // "constant", "burst", "poisson"
Rate int `json:"rate"` // packets per second
Duration time.Duration `json:"duration"`
Size int `json:"size"` // packet size in bytes
}
TrafficPattern defines how traffic is generated.
type VirtualNode ¶
type VirtualNode struct {
Config NodeConfig
Sent int64
Received int64
Dropped int64
}
VirtualNode is a simulated network node.
Click to show internal directories.
Click to hide internal directories.