dccp

package
v0.0.0-...-55a50c8 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2013 License: AGPL-3.0 Imports: 21 Imported by: 5

Documentation

Index

Constants

View Source
const (
	CCID2 = 2 // TCP-like Congestion Control, RFC 4341
	CCID3 = 3 // TCP-Friendly Rate Control (TFRC), RFC 4342
)
View Source
const (
	REQUEST_BACKOFF_FIRST   = 1e9  // Initial re-send period for client Request resends is 1 sec, in ns
	REQUEST_BACKOFF_FREQ    = 10e9 // Back-off Request resend every 10 secs, in ns
	REQUEST_BACKOFF_TIMEOUT = 30e9 // Request re-sends quit after 30 sec, in ns (shorter than RFC recommendation)

	RESPOND_TIMEOUT = 30e9 // Timeout in RESPOND state, 30 sec in ns

	LISTEN_TIMEOUT = REQUEST_BACKOFF_TIMEOUT // Timeout in LISTEN state

	CLOSING_BACKOFF_FREQ    = 64e9    // Backoff frequency of CLOSING timer, 64 seconds, Section 8.3
	CLOSING_BACKOFF_TIMEOUT = MSL / 4 // Maximum time in CLOSING (RFC recommends MSL, but seems too long)

	TIMEWAIT_TIMEOUT = MSL / 2 // Time to stay in TIMEWAIT, Section 8.3 recommends MSL*2

	PARTOPEN_BACKOFF_FIRST   = 200e6 // 200 miliseconds in ns, Section 8.1.5
	PARTOPEN_BACKOFF_FREQ    = 200e6 // 200 miliseconds in ns
	PARTOPEN_BACKOFF_TIMEOUT = 30e9  // 30 sec (Section 8.1.5 recommends 8 min)

	EXPIRE_INTERVAL = 1e9 // Interval for checking expiration conditions
)
View Source
const (
	Request  = 0
	Response = 1
	Data     = 2
	Ack      = 3
	DataAck  = 4
	CloseReq = 5
	Close    = 6
	Reset    = 7
	Sync     = 8
	SyncAck  = 9
)

Packet types. Stored in the Type field of the generic header. Receivers MUST ignore any packets with reserved type. That is, packets with reserved type MUST NOT be processed, and they MUST NOT be acknowledged as received.

View Source
const (
	ResetUnspecified       = 0
	ResetClosed            = 1
	ResetAborted           = 2
	ResetNoConnection      = 3
	ResetPacketError       = 4
	ResetOptionError       = 5
	ResetMandatoryError    = 6
	ResetConnectionRefused = 7
	ResetBadServiceCode    = 8
	ResetTooBusy           = 9
	ResetBadInitCookie     = 10
	ResetAgressionPenalty  = 11
)

Reset codes

View Source
const (
	CsCovAllData = iota
	CsCovNoData
	CsCov4
	CsCov8
	CsCov12
)
View Source
const (
	MuxLingerTime = 60e9  // 1 min in nanoseconds
	MuxExpireTime = 600e9 // 10 min in nanoseconds
	MuxReadSafety = 5
)
View Source
const (
	OptionPadding         = 0
	OptionMandatory       = 1
	OptionSlowReceiver    = 2
	OptionChangeL         = 32
	OptionConfirmL        = 33
	OptionChangeR         = 34
	OptionConfirmR        = 35
	OptionInitCookie      = 36
	OptionNDPCount        = 37
	OptionAckVectorNonce0 = 38
	OptionAckVectorNonce1 = 39
	OptionDataDropped     = 40
	OptionTimestamp       = 41
	OptionTimestampEcho   = 42
	OptionElapsedTime     = 43
	OptionDataChecksum    = 44
)
View Source
const (
	SEQWIN_INIT      = 100        // Initial value for SWAF and SWBF, Section 7.5.2
	SEQWIN_FIXED     = 700        // Large enough constant for SWAF/SWBF until the feature is implemented
	SEQWIN_MAX       = 2 ^ 46 - 1 // Maximum acceptable SWAF and SWBF value
	RoundtripDefault = 2e8        // 0.2 sec, default Round-Trip Time when no measurement is available
	RoundtripMin     = 2e6        // ...
	MSL              = 2 * 60e9   // 2 mins in nanoseconds, Maximum Segment Lifetime, Section 3.4
	MAX_OPTIONS_SIZE = 128
)
View Source
const (
	CLOSED = iota
	LISTEN
	REQUEST
	RESPOND
	PARTOPEN
	OPEN
	CLOSEREQ
	CLOSING
	TIMEWAIT
)

The nine possible states of a DCCP socket. Listed in increasing order:

View Source
const (
	TenMicroInNano       = 1e4         // 10 microseconds in nanoseconds
	OneSecInTenMicro     = 1e5         // 1 seconds in ten microsecond units
	MaxTenMicro          = 4294967295  // Maximum allowed time in ten microsecond units
	MaxElapsedInTenMicro = MaxTenMicro // Maximum elapsed time in ten microsecond units
)
View Source
const (
	EventTurn  = Event(iota) // Turn events mark new information that is admissible (within expectations)
	EventMatch               // Match events mark an admissible outcome of a complex event/computation sequence
	EventCatch               // Catch events are breakpoints on conditions
	EventInfo
	EventWarn
	EventError
	EventIdle  // Idle events are emitted on the turn of the DCCP idle loop
	EventDrop  // Drop events are related to a packet drop
	EventRead  // Read events are related to a packet read
	EventWrite // Write events are related to a packet write
)
View Source
const (
	AnyProto = iota
)

Constants for protoNo

View Source
const BackoffMin = 100e6

BackoffMin is the minimum time before two firings of the backoff timers

View Source
const CCID_FIXED = 0xf
View Source
const LabelLen = 16
View Source
const (
	SEQNOMAX = (2 << 48) - 1
)

Variables

View Source
var (
	ErrInvalid       = NewError("invalid argument") // Invalid arguments passed to a routine
	ErrAlign         = NewError("align")
	ErrSize          = NewError("size")
	ErrSemantic      = NewError("semantic")
	ErrSyntax        = NewError("syntax")
	ErrNumeric       = NewError("numeric")
	ErrOption        = NewError("option")
	ErrOptionsTooBig = NewError("options too big")
	ErrOversize      = NewError("over size")
	ErrCsCov         = NewError("cscov")
	ErrChecksum      = NewError("checksum")
	ErrIPFormat      = NewError("ip format")
	ErrUnknownType   = NewError("unknown packet type")
	ErrUnsupported   = NewError("unsupported")
	ErrProto         = NewError("protocol error")
	ErrDrop          = NewError("dropped")
	ErrReset         = NewError("reset")
	ErrTooBig        = NewError("too big")
	ErrOverflow      = NewError("overflow")
)

TODO: Annotate each error with the circumstances that can cause it

View Source
var (
	ErrEOF     = NewError("i/o eof")
	ErrAbort   = NewError("i/o aborted")
	ErrTimeout = NewError("i/o timeout")
	ErrBad     = NewError("i/o bad connection")
	ErrIO      = NewError("i/o error")
)

Connection errors

View Source
var CongestionAck = NewError("cc-ack")

CongestionAck is sent from Congestion Control to Conn to advise that an Ack packet should be sent to the other side.

View Source
var (
	LabelZero = Label{}
)
View Source
var SampleType = TypeOf(Sample{})
View Source
var ZeroAddr = &Addr{}

Functions

func Caller

func Caller() string

func DecodeUint16

func DecodeUint16(w []byte) uint16

func DecodeUint24

func DecodeUint24(w []byte) uint32

func DecodeUint32

func DecodeUint32(w []byte) uint32

func DecodeUint48

func DecodeUint48(w []byte) uint64

func DecodeUint8

func DecodeUint8(w []byte) uint8

func EncodeUint16

func EncodeUint16(u uint16, w []byte)

func EncodeUint24

func EncodeUint24(u uint32, w []byte)

func EncodeUint32

func EncodeUint32(u uint32, w []byte)

func EncodeUint48

func EncodeUint48(u uint64, w []byte)

func EncodeUint8

func EncodeUint8(u uint8, w []byte)

func FetchCaller

func FetchCaller(skip int) (sfile string, sline int)

FetchCaller returns a shortened (more readable) version of the source file name, as well as the source line number of the caller.

func FitsIn16Bits

func FitsIn16Bits(x uint64) bool

func FitsIn23Bits

func FitsIn23Bits(x uint64) bool

func FitsIn24Bits

func FitsIn24Bits(x uint64) bool

func FitsIn32Bits

func FitsIn32Bits(x uint64) bool

func InstallCtrlCPanic

func InstallCtrlCPanic()

InstallCtrlCPanic installs a Ctrl-C signal handler that panics

func InstallTimeout

func InstallTimeout(ns int64)

InstallTimeout panics the current process in ns time

func NanoFromTenMicro

func NanoFromTenMicro(tenmicro uint32) int64

NanoFromTenMicro converts a time length given in ten microsecond units into nanoseconds, without exceeding the maximum allowed time limit of MaxTenMicro.

func NewCongestionReset

func NewCongestionReset(resetCode byte) error

func NewError

func NewError(s string) error

func Nstoa

func Nstoa(ns int64) string

func ParseServiceCode

func ParseServiceCode(p []byte) (uint32, error)

func SavePanicTrace

func SavePanicTrace()

func ServerString

func ServerString(isServer bool) string

func ServiceCodeString

func ServiceCodeString(code uint32) string

func StackTrace

func StackTrace(labels []string, skip int, sfile string, sline int) string

StackTrace formats the stack trace of the calling goroutine, excluding pointer information and including DCCP runtime-specific information, in a manner convenient for debugging DCCP

func StateString

func StateString(state int) string

func TenMicroDiff

func TenMicroDiff(t0, t1 uint32) uint32

TenMicroDiff returns the circular difference between t0 an t1. The arguments and the result are in ten microsecond units.

func TenMicroFromNano

func TenMicroFromNano(ns int64) uint32

TenMicroFromNano converts a time length given in nanoseconds into units of 10 microseconds, capped by MaxTenMicro.

func TrimFuncName

func TrimFuncName(fname string) (trimmed string, isDCCP bool)

TrimFuncName shortens DCCP function names for readability and whether this is a DCCP or anonymous function

func TrimSourceFile

func TrimSourceFile(sfile string) string

TrimSourceFile shortens DCCP source file names for readability

func TypeOf

func TypeOf(a interface{}) string

Types

type Addr

type Addr struct {
	*Label
	Port uint16
}

Addr{} is a general-purpose data type intended for custom link layer addresses.

func ParseAddr

func ParseAddr(s string) (addr *Addr, n int, err error)

ParseAddr() parses a link address from s@ in string format

func ReadAddr

func ReadAddr(p []byte) (addr *Addr, n int, err error)

Read() reads a link address from p@ in wire format

func (*Addr) Address

func (addr *Addr) Address() string

Address() is identical to String(), included as a method so that Addr conforms to net.Addr

func (*Addr) Network

func (addr *Addr) Network() string

Network() returns the name of the link address namespace, included to conform to net.Addr

func (*Addr) String

func (addr *Addr) String() string

String() returns the string represenation of the link address

func (*Addr) Write

func (addr *Addr) Write(p []byte) (n int, err error)

Write() writes the link address to p@ in wire format

type Amb

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

Amb represents a runtime context, embodied by a runtime, a stack of labels and set of options. It is also capable of emitting structured logs, that are relative to the overall context, and are consequently used for debuging and analysis purposes. It lives in the context of a shared time framework and a shared filter framework, which may filter some logs out

var NoLogging *Amb = &Amb{}

A zero-value Amb has the special-case behavior of ignoring all emits

func NewAmb

func NewAmb(label string, env *Env) *Amb

NewAmb creates a new Amb object with a single entry in the label stack

func (*Amb) Copy

func (t *Amb) Copy() *Amb

Copy clones this amb into an identical new one

func (*Amb) E

func (t *Amb) E(event Event, comment string, args ...interface{})

E emits a new log record. The arguments args are scanned in turn. The first argument of type *Header, *PreHeader, *FeedbackHeader or *FeedforwardHeader is considered the DCCP header that this log pertains to. The first argument of type Args is saved in the log record.

func (*Amb) EC

func (t *Amb) EC(skip int, event Event, comment string, args ...interface{})

func (*Amb) Filter

func (t *Amb) Filter() *filter.Filter

func (*Amb) Flags

func (t *Amb) Flags() *Flags

Flags returns the flags associated with this Amb instance

func (*Amb) GetState

func (t *Amb) GetState() string

GetState retrieves the state of the owning object, using the runtime value store

func (*Amb) Labels

func (t *Amb) Labels() []string

Labels returns the label stack of this amb

func (*Amb) Push

func (t *Amb) Push(l string) *Amb

Push adds the label l onto this amb's label stack

func (*Amb) Refine

func (t *Amb) Refine(l string) *Amb

Refine clones this amb and stack the additional label l

func (*Amb) SetState

func (t *Amb) SetState(s int)

SetState saves the state s into the runtime value store

type Bytes

type Bytes interface {
	Bytes() []byte
}

Bytes is a type that has an equivalent representation as a byte slice We use it for addresses, since net.Addr does not require such representation

type CCFixed

type CCFixed struct {
}

func (CCFixed) NewReceiver

func (CCFixed) NewReceiver(env *Env, amb *Amb) ReceiverCongestionControl

func (CCFixed) NewSender

func (CCFixed) NewSender(env *Env, amb *Amb) SenderCongestionControl

type CCID

type CCID interface {
	NewSender(env *Env, amb *Amb, args ...interface{}) SenderCongestionControl
	NewReceiver(env *Env, amb *Amb, args ...interface{}) ReceiverCongestionControl
}

CCID is a factory type that creates instances of sender and receiver CCIDs

type ChanLink struct {
	Mutex
	// contains filtered or unexported fields
}

ChanLink treats one side of a channel as an incoming packet link

func NewChanPipe

func NewChanPipe() (p, q *ChanLink)

func (*ChanLink) Close

func (l *ChanLink) Close() error

func (*ChanLink) GetMTU

func (l *ChanLink) GetMTU() int

func (*ChanLink) ReadFrom

func (l *ChanLink) ReadFrom(buf []byte) (n int, addr net.Addr, err error)

func (*ChanLink) SetReadDeadline

func (l *ChanLink) SetReadDeadline(t time.Time) error

func (*ChanLink) WriteTo

func (l *ChanLink) WriteTo(buf []byte, addr net.Addr) (n int, err error)

type CongestionReset

type CongestionReset byte

CongestionReset is sent from Congestion Control to Conn to indicate that the connection must be reset. CongestionReset encloses the desired Reset Code.

func (CongestionReset) Error

func (ce CongestionReset) Error() string

func (CongestionReset) ResetCode

func (ce CongestionReset) ResetCode() byte

type Conn

type Conn struct {
	Mutex // Protects access to socket, ccidOpen and err
	// contains filtered or unexported fields
}

Conn

func NewConnClient

func NewConnClient(env *Env, amb *Amb, hc HeaderConn,
	scc SenderCongestionControl, rcc ReceiverCongestionControl, serviceCode uint32) *Conn

func NewConnServer

func NewConnServer(env *Env, amb *Amb, hc HeaderConn,
	scc SenderCongestionControl, rcc ReceiverCongestionControl) *Conn

func (*Conn) Abort

func (c *Conn) Abort()

func (*Conn) Amb

func (c *Conn) Amb() *Amb

Amb returns the Amb instance associated with this connection

func (*Conn) ChooseISS

func (s *Conn) ChooseISS() int64

ChooseISS chooses a safe Initial Sequence Number

func (*Conn) Close

func (c *Conn) Close() error

Close implements SegmentConn.Close. It closes the connection, Section 8.3.

func (*Conn) Error

func (c *Conn) Error() error

func (*Conn) GetAWLH

func (s *Conn) GetAWLH() (AWL int64, AWH int64)

GetAWLH() computes AWL and AWH, see Section 7.5.1

func (*Conn) GetCCMPS

func (s *Conn) GetCCMPS() int32

func (*Conn) GetGAR

func (s *Conn) GetGAR() int64

func (*Conn) GetGSR

func (s *Conn) GetGSR() int64

func (*Conn) GetGSS

func (s *Conn) GetGSS() int64

func (*Conn) GetISS

func (s *Conn) GetISS() int64

func (*Conn) GetMPS

func (s *Conn) GetMPS() int32

func (*Conn) GetMTU

func (c *Conn) GetMTU() int

GetMTU() returns the maximum size of an application-level data block that can be passed to Write This is an informative number. Packets are sent anyway, but they may be dropped by the link layer or a router.

func (*Conn) GetOSR

func (s *Conn) GetOSR() int64

func (*Conn) GetPMTU

func (s *Conn) GetPMTU() int32

func (*Conn) GetRTT

func (s *Conn) GetRTT() int64

func (*Conn) GetSWLH

func (s *Conn) GetSWLH() (SWL int64, SWH int64)

GetSWLH() computes SWL and SWH, see Section 7.5.1

func (*Conn) GetServiceCode

func (s *Conn) GetServiceCode() uint32

func (*Conn) GetState

func (s *Conn) GetState() int

func (*Conn) InAckWindow

func (s *Conn) InAckWindow(x int64) bool

func (*Conn) IsServer

func (s *Conn) IsServer() bool

func (*Conn) Joiner

func (c *Conn) Joiner() Joiner

Joiner returns a Joiner instance that can wait until all goroutines associated with the connection have completed.

func (*Conn) LocalLabel

func (c *Conn) LocalLabel() Bytes

LocalLabel implements SegmentConn.LocalLabel

func (*Conn) PlaceSeqAck

func (c *Conn) PlaceSeqAck(h *Header)

PlaceSeqAck() updates the socket registers upon receiving a header from the other side.

func (*Conn) Read

func (c *Conn) Read() (b []byte, err error)

Read blocks until the next packet of application data is received. Successfuly read data is returned in a slice. The error returned by Read behaves according to io.Reader. If the connection was never established or was aborted, Read returns ErrIO. If the connection was closed normally, Read returns io.EOF. In the event of a non-nil error, successive calls to Read return the same error.

func (*Conn) RemoteLabel

func (c *Conn) RemoteLabel() Bytes

RemoteLabel implements SegmentConn.RemoteLabel

func (*Conn) SetCCIDA

func (s *Conn) SetCCIDA(v byte)

func (*Conn) SetCCIDB

func (s *Conn) SetCCIDB(v byte)

func (*Conn) SetCCMPS

func (s *Conn) SetCCMPS(v int32)

func (*Conn) SetGAR

func (s *Conn) SetGAR(v int64)

func (*Conn) SetGSR

func (s *Conn) SetGSR(v int64)

func (*Conn) SetGSS

func (s *Conn) SetGSS(v int64)

func (*Conn) SetISR

func (s *Conn) SetISR(v int64)

func (*Conn) SetOSR

func (s *Conn) SetOSR(v int64)

func (*Conn) SetPMTU

func (s *Conn) SetPMTU(v int32)

func (*Conn) SetRTT

func (s *Conn) SetRTT(v int64)

func (*Conn) SetReadExpire

func (c *Conn) SetReadExpire(nsec int64) error

SetReadExpire implements SegmentConn.SetReadExpire

func (*Conn) SetSWAF

func (s *Conn) SetSWAF(v int64)

func (*Conn) SetSWBF

func (s *Conn) SetSWBF(v int64)

func (*Conn) SetServer

func (s *Conn) SetServer(v bool)

func (*Conn) SetServiceCode

func (s *Conn) SetServiceCode(v uint32)

func (*Conn) SetState

func (s *Conn) SetState(v int)

func (*Conn) String

func (s *Conn) String() string

func (*Conn) UpdateGAR

func (s *Conn) UpdateGAR(v int64)

func (*Conn) UpdateGSR

func (s *Conn) UpdateGSR(v int64)

func (*Conn) Write

func (c *Conn) Write(data []byte) error

Write blocks until the slice b is sent.

func (*Conn) WriteCC

func (c *Conn) WriteCC(h *Header, timeWrite int64)

func (*Conn) WriteSeqAck

func (c *Conn) WriteSeqAck(h *writeHeader)

type ElapsedTimeOption

type ElapsedTimeOption struct {
	Elapsed uint32
}

ElapsedTimeOption, Section 13.2 This option is permitted in any DCCP packet that contains an Acknowledgement Number; such options received on other packet types MUST be ignored. It indicates how much time has elapsed since the packet being acknowledged -- the packet with the given Acknowledgement Number -- was received.

The option data, Elapsed Time, represents an estimated lower bound on the amount of time elapsed since the packet being acknowledged was received, with units of hundredths of milliseconds (10 microseconds granularity).

func DecodeElapsedTimeOption

func DecodeElapsedTimeOption(opt *Option) *ElapsedTimeOption

func (*ElapsedTimeOption) Encode

func (opt *ElapsedTimeOption) Encode() (*Option, error)

type Env

type Env struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Env encapsulates the runtime environment of a DCCP endpoint. It includes a pluggable time interface, in order to allow for use of real as well as synthetic (accelerated) time (for testing purposes), as well as a amb interface.

func NewEnv

func NewEnv(guzzle TraceWriter) *Env

func (*Env) Close

func (t *Env) Close() error

func (*Env) Expire

func (t *Env) Expire(test func() bool, onexpire func(), timeout, interval int64, fmt_ string, args_ ...interface{})

Expire periodically, on every interval duration, checks if the test condition has been met. If the condition is met within the timeout period, no further action is taken. Otherwise, the onexpire function is invoked.

func (*Env) Filter

func (t *Env) Filter() *filter.Filter

func (*Env) Go

func (t *Env) Go(f func(), fmt_ string, args_ ...interface{})

Go runs f in a new GoRoutine. The GoRoutine is also added to the GoJoin of the Env.

func (*Env) Joiner

func (t *Env) Joiner() Joiner

func (*Env) NewGoJoin

func (t *Env) NewGoJoin(annotation string, group ...Joiner) *GoJoin

func (*Env) Now

func (t *Env) Now() int64

func (*Env) Sleep

func (t *Env) Sleep(ns int64)

func (*Env) Snap

func (t *Env) Snap() (sinceZero int64, sinceLast int64)

func (*Env) Sync

func (t *Env) Sync() error

func (*Env) TraceWriter

func (t *Env) TraceWriter() TraceWriter

type Event

type Event int

Event is the type of logging event. Events are wrapped in a special type to make sure that modifications/additions to the set of events impose respective modifications in the reducer and the inspector.

func (Event) String

func (e Event) String() string

String returns a textual representation of the event

type FeedbackHeader

type FeedbackHeader struct {
	Type    byte
	X       bool
	SeqNo   int64
	Options []*Option
	AckNo   int64

	// Time when header received
	Time int64
}

FeedbackHeader contains information that is shown to the sender congesion control at packet reception. FeedbackHeader encloses the parts of the packet header that are sent by the HC-Receiver and received by the HC-Sender

type FeedforwardHeader

type FeedforwardHeader struct {

	// These fields are copied directly from the header
	Type    byte
	X       bool
	SeqNo   int64
	CCVal   int8
	Options []*Option

	// Time when header received
	Time int64

	// Length of application data in bytes
	DataLen int
}

FeedforwardHeader contains information that is shown to the receiver congesion control at packet reception. FeedforwardHeader encloses the parts of the packet header that are sent by the HC-Sender and received by the HC-Receiver

type FileTraceWriter

type FileTraceWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FileTraceWriter saves all log entries to a file in JSON format

func NewFileTraceWriter

func NewFileTraceWriter(filename string) *FileTraceWriter

func NewFileTraceWriterDup

func NewFileTraceWriterDup(filename string, dup TraceWriter) *FileTraceWriter

NewFileTraceWriterDup creates a TraceWriter that saves logs in a file and also passes them to dup.

func (*FileTraceWriter) Close

func (t *FileTraceWriter) Close() error

func (*FileTraceWriter) Sync

func (t *FileTraceWriter) Sync() error

func (*FileTraceWriter) Write

func (t *FileTraceWriter) Write(r *Trace)

type Flags

type Flags struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Flags is a general purpose key-value map, which is used inside Amb to allow an Amb and all of its refinements to share a collection of debug flags.

func NewFlags

func NewFlags() *Flags

NewFlags creates and initializes a new Flags instance

func (*Flags) GetInt64

func (x *Flags) GetInt64(key string) (value int64, present bool)

func (*Flags) GetUint32

func (x *Flags) GetUint32(key string) (value uint32, present bool)

func (*Flags) Has

func (x *Flags) Has(key string) bool

func (*Flags) Init

func (x *Flags) Init()

Init clears a Flags instance for fresh use

func (*Flags) Set

func (x *Flags) Set(key string, value interface{})

func (*Flags) SetUint32

func (x *Flags) SetUint32(key string, value uint32)

type GoJoin

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

GoJoin waits until a set of GoRoutines all complete. It also allows new routines to be added dynamically before the completion event.

func NewGoJoin

func NewGoJoin(annotation string, group ...Joiner) *GoJoin

func NewGoJoinCaller

func NewGoJoinCaller(skip int, annotation string, group ...Joiner) *GoJoin

NewGoJoinCaller creates an object capable of waiting until all supplied GoRoutines complete.

func (*GoJoin) Add

func (t *GoJoin) Add(u Joiner)

Add adds a Joiner to the group. It can be called at any time as long as the current set of goroutines hasn't completed. For instance, as long as you call Add from a GoRoutine which is waited on by this object, the condtion will be met.

func (*GoJoin) Go

func (t *GoJoin) Go(f func(), fmt_ string, args_ ...interface{})

Go is a convenience method which forks f into a new GoRoutine and adds the latter to the waiting queue. fmt is a formatted annotation with arguments args.

func (*GoJoin) Join

func (t *GoJoin) Join()

Join blocks until all goroutines in the group have completed. Join can be called concurrently. If called post-completion of the goroutine group, Join returns immediately.

func (*GoJoin) String

func (t *GoJoin) String() string

String returns a unique, readable string representation of this instance.

type GoRoutine

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

GoRoutine represents a running goroutine.

func Go

func Go(f func(), fmt_ string, args_ ...interface{}) *GoRoutine

func GoCaller

func GoCaller(f func(), skip int, fmt_ string, args_ ...interface{}) *GoRoutine

Go runs f in a new goroutine and returns a handle object, which can then be used for various synchronization mechanisms.

func (*GoRoutine) Join

func (g *GoRoutine) Join()

Join blocks until the goroutine completes; otherwise, if the goroutine has completed, it returns immediately. Join can be called concurrently.

func (*GoRoutine) Source

func (g *GoRoutine) Source() (sfile string, sline int)

Source returns the file and line where the goroutine was forked.

func (*GoRoutine) String

func (g *GoRoutine) String() string

Strings returns a unique and readable string representation of this instance.

type Header struct {
	SourcePort  uint16    // Sender port
	DestPort    uint16    // Receiver port
	CCVal       int8      // Used by the HC-Sender's CCID to transmit 4-bit values
	CsCov       byte      // Specifies the parts of packet covered by the checksum
	Type        byte      // Packet type: Data, Ack, Sync, etc.
	X           bool      // Extended seq numbers: generally always true (for us)
	SeqNo       int64     // 48-bit if X=1
	AckNo       int64     // 48-bit if X=1
	ServiceCode uint32    // ServiceCode: Applicaton level service (in Req,Resp pkts)
	ResetCode   byte      // ResetCode: Reason for reset (in Reset pkts)
	ResetData   []byte    // ResetData: Additional reset info (in Reset pkts)
	Options     []*Option // Used for feature negotiation, padding, mandatory flags
	Data        []byte    // Application data (in Req, Resp, Data, DataAck pkts)

}

func ReadHeader

func ReadHeader(buf []byte,
	sourceIP, destIP []byte,
	protoNo byte,
	allowShortSeqNoFeature bool) (header *Header, err error)

func (*Header) HasAckNo

func (h *Header) HasAckNo() bool

func (*Header) InitAckHeader

func (h *Header) InitAckHeader()

InitAckHeader() creates a new Ack header

func (*Header) InitCloseHeader

func (h *Header) InitCloseHeader()

InitCloseHeader() creates a new Close header

func (*Header) InitDataAckHeader

func (h *Header) InitDataAckHeader(data []byte)

InitDataAckHeader() creates a new DataAck header

func (*Header) InitDataHeader

func (h *Header) InitDataHeader(data []byte)

InitDataHeader() creates a new Data header

func (*Header) InitRequestHeader

func (h *Header) InitRequestHeader(serviceCode uint32)

InitRequestHeader() creates a new Request header

func (*Header) InitResetHeader

func (h *Header) InitResetHeader(resetCode byte)

InitResetHeader() creates a new Reset header

func (*Header) InitResponseHeader

func (h *Header) InitResponseHeader(serviceCode uint32)

InitResponseHeader() creates a new Response header

func (*Header) InitSyncAckHeader

func (h *Header) InitSyncAckHeader()

InitSyncAckHeader() creates a new Sync header

func (*Header) InitSyncHeader

func (h *Header) InitSyncHeader()

InitSyncHeader() creates a new Sync header

func (*Header) String

func (h *Header) String() string

func (*Header) Write

func (gh *Header) Write(sourceIP, destIP []byte,
	protoNo byte,
	allowShortSeqNoFeature bool) (header []byte, err error)

Write() writes the DCCP header to two return buffers. The first one is the header part, and the second one is the data part which simply equals the slice Header.Data

type HeaderConn

type HeaderConn interface {
	// GetMTU() returns the Maximum Transmission Unit size. This is the maximum
	// byte size of the header and app data wire-format footprint.
	GetMTU() int

	// Read returns ErrTimeout in the event of timeout. See SetReadExpire.
	Read() (h *Header, err error)

	// Write can return ErrTooBig, if the wire-format of h exceeds the MTU
	Write(h *Header) (err error)

	LocalLabel() Bytes

	RemoteLabel() Bytes

	// SetReadExpire behaves similarly to SegmentConn.SetReadExpire
	SetReadExpire(nsec int64) error

	Close() error
}

Implementors of this interface MUST only return i/o errors defined in the dccp package (ErrEOF, ErrBad, ErrTimeout, etc.)

func NewHeaderConn

func NewHeaderConn(bc SegmentConn) HeaderConn

————— NewHeaderConn creates a HeaderConn on top of a SegmentConn

type Joiner

type Joiner interface {
	// Join blocks until an underlying event occurs.
	// It returns immediately if called post-event.
	// It is re-entrant.
	Join()
	String() string
}

Joiner is an interface to objects that can wait for some event.

type Label

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

Label{} is an immutable object, representing a general-purpose address similar to IPv6 in that it consists of 16 opaque bytes.

func ChooseLabel

func ChooseLabel() *Label

ChooseLabel() creates a new label by choosing its bytes randomly

func ParseLabel

func ParseLabel(s string) (label *Label, n int, err error)

ParseLabel() parses and creates a new label from the string representation in s@

func ReadLabel

func ReadLabel(p []byte) (label *Label, n int, err error)

ReadLabel() reads and creates a new label from a wire format representation in p@

func (*Label) Address

func (label *Label) Address() string

func (*Label) Bytes

func (label *Label) Bytes() []byte

func (*Label) Equal

func (label *Label) Equal(q *Label) bool

Equal() performs a deep check for equality with q@

func (*Label) Hash

func (label *Label) Hash() uint64

Hash() returns the hash code of this label

func (*Label) String

func (label *Label) String() string

String() returns a string representation of the label

func (*Label) Write

func (label *Label) Write(p []byte) (n int, err error)

Write() writes the wire format representation of the label into p@

type Link interface {

	// Returns the Maximum Transmission Unit
	// Writes smaller than this are guaranteed to be sent whole
	GetMTU() int

	// ReadFrom receives the next packet of data. It returns net.Error errors. So in the event
	// of a timeout e.g. it will return a net.Error with Timeout() true, rather than an
	// ErrTimeout. The latter is used internally to DCCP in types that implement HeaderConn and
	// SegmentConn.
	ReadFrom(buf []byte) (n int, addr net.Addr, err error)

	// WriteTo sends a packet of data
	WriteTo(buf []byte, addr net.Addr) (n int, err error)

	// SetReadDeadline has the same meaning as net.Conn.SetReadDeadline
	SetReadDeadline(t time.Time) error

	// Close terminates the link gracefully
	Close() error
}

Link is an abstract interface to a physical connection-less packet layer which sends and receives packets

type Mutex

type Mutex struct {
	sync.Mutex
}

func (*Mutex) AssertLocked

func (m *Mutex) AssertLocked()

func (*Mutex) Lock

func (m *Mutex) Lock()

func (*Mutex) Unlock

func (m *Mutex) Unlock()

type Mux

type Mux struct {
	Mutex
	// contains filtered or unexported fields
}

Mux is a thin protocol layer that works on top of a connection-less packet layer, like UDP. Mux multiplexes packets into flows. A flow is a point-to-point connection, which has no congestion or reliability mechanism.

Mux implements a mechanism for dropping packets that linger (are received) for up to one minute after their respective flow has been closed.

Mux force-closes flows that have experienced no activity for 10 mins

func NewMux

func NewMux(link Link) *Mux

NewMux creates a new Mux object, using the connection-less packet interface link

func (*Mux) Accept

func (m *Mux) Accept() (c SegmentConn, err error)

Accept() returns the first incoming flow request

func (*Mux) Close

func (m *Mux) Close() error

Close() closes the mux and signals all outstanding connections that it is time to terminate

func (*Mux) Dial

func (m *Mux) Dial(addr net.Addr) (c SegmentConn, err error)

Dial opens a packet-based connection to the Link-layer addr

type Option

type Option struct {
	Type      byte
	Data      []byte
	Mandatory bool
}

type PreHeader

type PreHeader struct {
	Type  byte
	X     bool
	SeqNo int64
	AckNo int64

	// TimeWrite is the time just before the packet is handed off to the
	// network layer.  The bulk of the time difference between TimeWrite and
	// TimeMake reflects the duration that the packet spends in the write
	// queue before it is pulled for sending, which itself is a function of
	// the send rate. TimeWrite is currently used by the CC logic to measure
	// the roundtrip time without factoring rate-related wait times in
	// endpoint queues.
	TimeWrite int64
}

PreHeader contains information that is shown to the sender and receiver congesion controls before a packet is sent. PreHeader contains the parts of the DCCP header than are fixed before the CCID has made its changes to CCVal and Options.

type ProtoError

type ProtoError string

ProtoError is a type that wraps all DCCP-specific errors. It is utilized to distinguish these errors from others, using type checks.

func (ProtoError) Error

func (e ProtoError) Error() string

type ReceiverCongestionControl

type ReceiverCongestionControl interface {

	// GetID() returns the CCID of this congestion control algorithm
	GetID() byte

	// Open tells the Congestion Control that the connection has entered
	// OPEN or PARTOPEN state and that the CC can now kick in.
	Open()

	// Conn calls OnWrite before a packet is sent to give CongestionControl
	// an opportunity to add CCVal and options to an outgoing packet
	// NOTE: If the CC is not active, OnWrite MUST return nil.
	OnWrite(ph *PreHeader) (options []*Option)

	// Conn calls OnRead after a packet has been accepted and validated
	// If OnRead returns ErrDrop, the packet will be dropped and no further processing
	// will occur.
	// NOTE: If the CC is not active, OnRead MUST return nil.
	OnRead(ff *FeedforwardHeader) error

	// OnIdle behaves identically to the same method of the HC-Sender CCID
	OnIdle(now int64) error

	// Close terminates the half-connection congestion control when it is not needed any longer
	Close()
}

ReceiverCongestionControl specifies the interface for the congestion control logic of a DCCP receiver (aka Half-Connection Receiver CCID)

type Sample

type Sample struct {
	Series string
	Value  float64
	Unit   string
}

One Sample argument can be attached to a log. The inspector interprets it as a data point in a time series where:

(i)   The time series name is given by the label stack of the amb
(ii)  The X-value of the data point equals the time the log was emitted
(iii) The Y-value of the data point is stored inside the Sample object

func NewSample

func NewSample(name string, value float64, unit string) Sample

type SegmentConn

type SegmentConn interface {
	// GetMTU returns th he largest allowable block size (for read and write). The MTU may vary.
	GetMTU() int

	// Read returns an ErrTimeout in the event of a timeout. See SetReadExpire.
	Read() (block []byte, err error)

	// If the user attempts to write a block that is too big, an ErrTooBig is returned
	// and the block is not sent.
	Write(block []byte) (err error)

	LocalLabel() Bytes

	RemoteLabel() Bytes

	// SetReadExpire sets the expiration time for any blocked calls to Read
	// as a time represented in nanoseconds from now. It's semantics are similar to that
	// of net.Conn.SetReadDeadline except that the deadline is specified in time from now,
	// rather than absolute time. Also note that Read is expected to return
	// an ErrTimeout in the event of timeouts.
	SetReadExpire(nsec int64) error

	Close() error
}

A SegmentConn is an I/O facility that explicitly reads/writes data in the form of indivisible blocks of data. Implementors of this interface MUST only return i/o errors defined in the dccp package (ErrEOF, ErrBad, ErrTimeout, etc.)

type SegmentDialAccepter

type SegmentDialAccepter interface {
	Accept() (c SegmentConn, err error)
	Dial(addr net.Addr) (c SegmentConn, err error)
	Close() error
}

SegmentDialAccepter represents a type that can accept and dial lossy packet connections

type SenderCongestionControl

type SenderCongestionControl interface {

	// GetID() returns the CCID of this congestion control algorithm
	GetID() byte

	// GetCCMPS returns the Congestion Control Maximum Packet Size, CCMPS. Generally, PMTU <= CCMPS
	GetCCMPS() int32

	// GetRTT returns the Round-Trip Time as measured by this CCID
	GetRTT() int64

	// Open tells the Congestion Control that the connection has entered
	// OPEN or PARTOPEN state and that the CC can now kick in. Before the
	// call to Open and after the call to Close, the Strobe function is
	// expected to return immediately.
	Open()

	// Conn calls OnWrite before a packet is sent to give CongestionControl
	// an opportunity to add CCVal and options to an outgoing packet
	// NOTE: If the CC is not active, OnWrite should return 0, nil.
	OnWrite(ph *PreHeader) (ccval int8, options []*Option)

	// Conn calls OnRead after a packet has been accepted and validated
	// If OnRead returns ErrDrop, the packet will be dropped and no further processing
	// will occur. If OnRead returns ResetError, the connection will be reset.
	// NOTE: If the CC is not active, OnRead MUST return nil.
	OnRead(fb *FeedbackHeader) error

	// Strobe blocks until a new packet can be sent without violating the
	// congestion control rate limit.
	// NOTE: If the CC is not active, Strobe MUST return immediately.
	Strobe()

	// OnIdle is called periodically, giving the CC a chance to:
	// (a) Request a connection reset by returning a CongestionReset, or
	// (b) Request the injection of an Ack packet by returning a CongestionAck
	// NOTE: If the CC is not active, OnIdle MUST to return nil.
	OnIdle(now int64) error

	// SetHeartbeat advices the CCID of the desired frequency of heartbeat packets.
	// A heartbeat interval value of zero indicates that no heartbeat is needed.
	SetHeartbeat(interval int64)

	// Close terminates the half-connection congestion control when it is not needed any longer
	Close()
}

SenderCongestionControl specifies the interface for the congestion control logic of a DCCP sender (aka Half-Connection Sender CCID)

type Stack

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

func NewStack

func NewStack(link Link, ccid CCID) *Stack

NewStack creates a new connection-handling object.

func (*Stack) Accept

func (s *Stack) Accept() (c SegmentConn, err error)

Accept blocks until a new connecion is established. It then returns the connection.

func (*Stack) Dial

func (s *Stack) Dial(addr net.Addr, serviceCode uint32) (c SegmentConn, err error)

Dial initiates a new connection to the specified Link-layer address.

type TimestampEchoOption

type TimestampEchoOption struct {
	// The timestamp echo option value in 10 microsecond circular units
	Timestamp uint32
	// The elapsed time in nanoseconds
	Elapsed uint32
}

————— TimestampEchoOption, Section 13.3 Time values are based on a circular uint32 value at 10 microseconds granularity

func DecodeTimestampEchoOption

func DecodeTimestampEchoOption(opt *Option) *TimestampEchoOption

func (*TimestampEchoOption) Encode

func (opt *TimestampEchoOption) Encode() (*Option, error)

type TimestampOption

type TimestampOption struct {
	// Timestamp is given in 10 microsecond circular units
	Timestamp uint32
}

TimestampOption, Section 13.1 Time values are based on a circular uint32 value at 10 microseconds granularity

func DecodeTimestampOption

func DecodeTimestampOption(opt *Option) *TimestampOption

func (*TimestampOption) Encode

func (opt *TimestampOption) Encode() (*Option, error)

type Trace

type Trace struct {

	// Time is the DCCP runtime time when the log was emitted
	Time int64 `json:"t"`

	// Labels is a list of runtime labels that identify some dynamic
	// instance of the DCCP stack.  For example, if two instances of Conn
	// are available at runtime (as in the case of tests in the sandbox),
	// one can be labeled "client" and the other "server". The labels slice
	// is kept as a field inside the Amb object, so that it can be
	// filled in automatically upon calls to the Amb's E method.
	Labels []string `json:"l"`

	// Event is an identifier representing the type of event that this trace represents. It
	// can be something like "Warn", "Info", etc.
	Event Event `json:"e"`

	// If applicable, State is the DCCP state of the runtime instance (or system) that this log
	// record pertains to. This is typically used only if the system is a dccp.Conn.
	State string `json:"s"`

	// Comment is a free-form textual comment
	Comment string `json:"c"`

	// Args are any additional arguments in the form of string keys mapped to open-ended values.
	// See documentation of E method for details how it is typically used.
	Args map[string]interface{} `json:"a"`

	// If this trace pertains to a DCCP header, Type is the DCCP type of this header.
	Type string `json:"ht"`

	// If this trace pertains to a DCCP header, SeqNo is the DCCP sequence number of this header.
	SeqNo int64 `json:"hs"`

	// If this trace pertains to a DCCP header, AckNo is the DCCP acknowledgement number of
	// this header.
	AckNo int64 `json:"ha"`

	// SourceFile is the name of the source file where this trace was emitted.
	SourceFile string `json:"sf"`

	// SourceLine is the line number in the source file where this trace was emitted.
	SourceLine int `json:"sl"`

	// Trace is the stack trace at the log entry's creation point
	Trace string `json:"st"`

	// Highlight indicates whether this record is of particular interest. Used for visualization purposes.
	// Currently, the inspector draws time series only for highlighted records.
	Highlight bool
}

Trace stores a log event. It can be used to marshal to JSON and pass to external visualisation tools.

func (*Trace) ArgOfType

func (x *Trace) ArgOfType(example interface{}) interface{}

ArgOfType returns an argument of the same type as example, if one is present in the log, or nil otherwise

func (*Trace) IsHighlighted

func (x *Trace) IsHighlighted() bool

func (*Trace) LabelString

func (x *Trace) LabelString() string

LabelString returns a textual representation of the label stack of this log

func (*Trace) Sample

func (x *Trace) Sample() (sample *Sample, present bool)

Sample returns the value of a sample embedded in this trace, if it exists

func (*Trace) SetHighlight

func (x *Trace) SetHighlight()

Highlight sets the highlight flag on this Trace. This is used in test-specific TraceWriters to indicate to the inspector that this record is of particular interest for visualization purposes.

type TraceWriter

type TraceWriter interface {
	Write(*Trace)
	Sync() error
	Close() error
}

TraceWriter is a type that consumes log entries.

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

UDPLink binds to a UDP port and acts as a Link.

func BindUDPLink(netw string, laddr *net.UDPAddr) (link *UDPLink, err error)

func (*UDPLink) Close

func (u *UDPLink) Close() error

func (*UDPLink) GetMTU

func (u *UDPLink) GetMTU() int

func (*UDPLink) ReadFrom

func (u *UDPLink) ReadFrom(buf []byte) (n int, addr net.Addr, err error)

func (*UDPLink) SetReadDeadline

func (u *UDPLink) SetReadDeadline(t time.Time) error

func (*UDPLink) WriteTo

func (u *UDPLink) WriteTo(buf []byte, addr net.Addr) (n int, err error)

Directories

Path Synopsis
This package contains utilities for testing DCCP and CCID in a controlled, simulated environment.
This package contains utilities for testing DCCP and CCID in a controlled, simulated environment.

Jump to

Keyboard shortcuts

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