Documentation
¶
Index ¶
Constants ¶
const ( // KB is 2³ bytes. KB = int64(1) << 10 // MB is 2⁶ bytes. MB = KB << 10 // GB is 2⁹ bytes. GB = MB << 10 // TB is 2¹² bytes. TB = GB << 10 // PB is 2¹⁶ bytes. PB = TB << 10 )
const ( // TCP is the key for the TCP protocol. TCP = Protocol("TCP") // UDP is the key for the UDP protocol. UDP = Protocol("UDP") )
const ( // VpnConnectionTimeout is the maximum amount of time given to open the // VPN tunnel. VpnConnectionTimeout = 10 * time.Second // LogFileName is the name of the file written in the temporary folder // where the logs of the vpn are written. LogFileName = "vpn.log" // PIDFileName is the name of the file written in the temporary folder // containing the PID of the VPN process. PIDFileName = "running_pid" // MessageInitDone is the message to look for to assume the tunnel is // opened. MessageInitDone = "Initialization Sequence Completed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Certificates ¶
Certificates holds the location of the different files.
type DefaultTunnel ¶
type DefaultTunnel struct {
// contains filtered or unexported fields
}
DefaultTunnel is an implementation of the tunnel interface that is using OpenVPN.
func NewDefaultTunnel ¶
func NewDefaultTunnel(output string) *DefaultTunnel
NewDefaultTunnel creates a new OpenVPN process.
func (*DefaultTunnel) Start ¶
func (v *DefaultTunnel) Start(opts ...TunOption) error
Start runs the openvpn process and returns any error that could happen before the tunnel is setup.
type ExecOptions ¶
ExecOptions is the options to pass to a command execution.
type IO ¶
type IO interface { // Tag allows to mark a point in time with a given tag. The moment the // function is called will be saved and it can be reported to the plot. Tag(name string) // Read reads a file on a simulation node at the given path. It returns a // stream through a reader, or an error if something bad happened. Read(node, path string) (io.ReadCloser, error) // Write writes a file on a simulation node at the given path. It will // write everything from the reader until it reaches EOF. It also returns // an error if something bad happened. Write(node, path string, content io.Reader) error // Exec executes a command on a simulation node and returns the output if // the command is successful, an error otherwise. Exec(node string, cmd []string, options ExecOptions) error // Disconnect provides an API to simulate a network failure between two // nodes. Disconnect(src string, targets ...string) error // Revert all the disconnection on the given node so that it will again be // able to contact all the nodes. Reconnect(node string) error // FetchStats gathers the statistics from the nodes and write into filename. FetchStats(from, to time.Time, filename string) error }
IO provides an API to interact with the nodes.
type NodeInfo ¶
NodeInfo is the element value of the array available in the execution context. Use `nodes := ctx.Value(NodesKey{}).([]NodeInfo)` to retrieve the data.
type Option ¶
type Option func(opts *Options)
Option is a function that changes the global options.
func WithImage ¶
WithImage is an option for simulation engines to use this Docker image as the base application to run.
func WithOutput ¶
WithOutput is an option to change the default directory that will be used to write data about the simulation.
func WithTmpFS ¶
WithTmpFS is an option for simulation engines to mount a tmpfs at the given destination.
func WithTopology ¶
WithTopology is an option for simulation engines to use the topology when deploying the nodes.
type Options ¶
type Options struct { OutputDir string Topology network.Topology Image string Cmd []string Args []string Ports []Port TmpFS []TmpVolume VPNExecutable string Data map[string]interface{} }
Options contains the different options for a simulation execution.
type Port ¶
Port is a parameter for the container image to open a port with a given protocol. It can also be a range.
type Round ¶
type Round interface { // Before is run once after deployment so that initialization can be // performed before the simulation is executed. Before(simio IO, nodes []NodeInfo) error // Execute is run during the execution step of the simulation, which is // after the nodes are deployed. Execute(simio IO, nodes []NodeInfo) error // After is run after each execution of the simulation to give a chance // to read files from simulation nodes. After(simio IO, nodes []NodeInfo) error }
Round is executed during the simulation.
type Strategy ¶
type Strategy interface { Option(Option) // Deploy takes care of deploying the application according to the // topology. The simulation should be able to run after it returns // with no error. Deploy(context.Context, Round) error // Execute takes the round provided to execute a round of the simulation. Execute(context.Context, Round) error // WriteStats reads the data writtent by the monitors on each node of the // simulation. WriteStats(ctx context.Context, filename string) error // Clean wipes off any resources that has been created for the simulation. Clean(context.Context) error }
Strategy provides the primitives to run a simulation from the deployment, to the execution of the simulation round and finally the cleaning.
type TCPPort ¶
type TCPPort struct {
// contains filtered or unexported fields
}
TCPPort is a single TCPPort port.
type TunOption ¶
type TunOption func(opts *TunOptions)
TunOption is a function that transforms the vpn options.
func WithCertificate ¶
func WithCertificate(certs Certificates) TunOption
WithCertificate updates the options to include the certificate elements in the parameters used to start the vpn.
func WithCommand ¶
WithCommand updates the options to use a different executable.
type TunOptions ¶
type TunOptions struct { Cmd string Host string Port int32 Certificates Certificates }
TunOptions contains the data that will be used to start the vpn.