scamper

package
v0.0.0-...-d0596d9 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2017 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package scamper is a library to work with scamper control sockets

Package scamper is a library to work with scamper control sockets

Package scamper is a library to work with scamper control sockets

Package scamper is a library to work with scamper control sockets

Index

Constants

View Source
const (
	// IPv4 Mode
	IPv4 = "-4"
	// IPv6 Mode
	IPv6 = "-6"
	// PORT to use
	PORT = "-P"
	// SOCKETDIR The Socket directory
	SOCKETDIR = "-U"
	// REMOTE Flag
	REMOTE = "-R"
	// SUDO the cmd must be run with sudo
	SUDO = "/usr/bin/sudo"
	// ADDRINDEX is the index of the addr arg
	ADDRINDEX = 2
	// PPS is the packet per second rate of the scamper process
	PPS = "-p"
)

Options for the scamper process

Variables

View Source
var (
	// ErrorBadDataResponse is returned when the data received by scamper couldnt
	// be converted
	ErrorBadDataResponse = errors.New("Bad DATA Response")
	// ErrorBadOKResponse is returned when an OK response fails to parse
	ErrorBadOKResponse = errors.New("Bad OK Response")
	// ErrorBadResponse is the generic error when a response can't be parsed
	ErrorBadResponse = errors.New("Bad Response")
	// ErrorTimeout returned when a command times out
	ErrorTimeout = errors.New("Timeout")
)
View Source
var (
	// ErrorCmdNotFound returned when no cmd is found in the cmdMap
	ErrorCmdNotFound = fmt.Errorf("No command found matching given Id")
	// ErrorDupCommand returned when a socket as a cmd with the same id already
	// running
	ErrorDupCommand = fmt.Errorf("Command already exists with the give Id")
)
View Source
var (
	// ErrSocketClosed is returned when the socket is closed
	ErrSocketClosed = fmt.Errorf("Socket closed.")
	// ErrFailedToIssueCmd is returned when issueCmd fails
	ErrFailedToIssueCmd = fmt.Errorf("Error issuing command.")
)
View Source
var (
	// ErrorSocketNotFound is used when a socketMap doesn't contain a socket
	ErrorSocketNotFound = fmt.Errorf("No socket found")
)

Functions

func GetProc

func GetProc(sockDir, scampPort, scamperPath string) *proc.Process

GetProc returns a process which will run scamper

func GetVPProc

func GetVPProc(scpath, host, port string) *proc.Process

GetVPProc returns a process which is suitable to run on a planet-lab VP

func ParseConfig

func ParseConfig(sc Config) error

ParseConfig checks the given confiuration options to ensure validity

Types

type Client

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

Client is the main object for interacting with scamper

func NewClient

func NewClient() *Client

NewClient creates a new Client

func (*Client) AddSocket

func (c *Client) AddSocket(s *Socket)

AddSocket adds a socket to the client

func (*Client) DoMeasurement

func (c *Client) DoMeasurement(addr string, arg interface{}) (<-chan Response, uint32, error)

DoMeasurement run the measurement described by arg from the address addr

func (*Client) GetAllSockets

func (c *Client) GetAllSockets() <-chan *Socket

GetAllSockets gets all the sockets

func (*Client) GetSocket

func (c *Client) GetSocket(addr string) (*Socket, error)

GetSocket gets a socket registered in the client

func (*Client) RemoveMeasurement

func (c *Client) RemoveMeasurement(addr string, id uint32) error

RemoveMeasurement removes a measurement

func (*Client) RemoveSocket

func (c *Client) RemoveSocket(addr string)

RemoveSocket removes a socket from the client

type Cmd

type Cmd struct {
	ID  uint32
	Arg interface{}
	// contains filtered or unexported fields
}

Cmd is a command that can run on scamper

func (*Cmd) IssueCommand

func (c *Cmd) IssueCommand(w io.Writer) error

IssueCommand write the command to w

type Config

type Config struct {
	Port         string
	Path         string
	ScPath       string
	IP           string
	ScParserPath string
}

Config is the configuration options for the scamper process

type Response

type Response struct {
	RType  responseT
	Data   []byte
	Ret    interface{}
	DS     int
	UserID uint32
	Err    error
	Header bool
}

Response represents a response from scamper

func (Response) Bytes

func (r Response) Bytes() []byte

Bytes get the data as bytes from a scamper response

func (Response) WriteTo

func (r Response) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes the response to the given io.Writer

type Socket

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

Socket represents a scamper control socket

func NewSocket

func NewSocket(fname string, con net.Conn) (*Socket, error)

NewSocket creates a new scamper socket

func (*Socket) DoMeasurement

func (s *Socket) DoMeasurement(arg interface{}) (<-chan Response, uint32, error)

DoMeasurement perform the measurement described by arg

func (*Socket) Done

func (s *Socket) Done() <-chan struct{}

Done indicates when the socket is closed

func (*Socket) IP

func (s *Socket) IP() string

IP Gets the ip of the remote machine that is connected to the socket

func (*Socket) Port

func (s *Socket) Port() string

Port gets the port of the remote machine that is connected to the socket

func (*Socket) RemoveMeasurement

func (s *Socket) RemoveMeasurement(id uint32) error

RemoveMeasurement remove a measurment being run with id id

func (*Socket) Stop

func (s *Socket) Stop()

Stop closes the connection the socket represents

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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