Documentation
¶
Index ¶
- Constants
- Variables
- func Caller() string
- func DecodeUint16(w []byte) uint16
- func DecodeUint24(w []byte) uint32
- func DecodeUint32(w []byte) uint32
- func DecodeUint48(w []byte) uint64
- func DecodeUint8(w []byte) uint8
- func EncodeUint16(u uint16, w []byte)
- func EncodeUint24(u uint32, w []byte)
- func EncodeUint32(u uint32, w []byte)
- func EncodeUint48(u uint64, w []byte)
- func EncodeUint8(u uint8, w []byte)
- func FetchCaller(skip int) (sfile string, sline int)
- func FitsIn16Bits(x uint64) bool
- func FitsIn23Bits(x uint64) bool
- func FitsIn24Bits(x uint64) bool
- func FitsIn32Bits(x uint64) bool
- func InstallCtrlCPanic()
- func InstallTimeout(ns int64)
- func NanoFromTenMicro(tenmicro uint32) int64
- func NewCongestionReset(resetCode byte) error
- func NewError(s string) error
- func Nstoa(ns int64) string
- func ParseServiceCode(p []byte) (uint32, error)
- func SavePanicTrace()
- func ServerString(isServer bool) string
- func ServiceCodeString(code uint32) string
- func StackTrace(labels []string, skip int, sfile string, sline int) string
- func StateString(state int) string
- func TenMicroDiff(t0, t1 uint32) uint32
- func TenMicroFromNano(ns int64) uint32
- func TrimFuncName(fname string) (trimmed string, isDCCP bool)
- func TrimSourceFile(sfile string) string
- func TypeOf(a interface{}) string
- type Addr
- type Amb
- func (t *Amb) Copy() *Amb
- func (t *Amb) E(event Event, comment string, args ...interface{})
- func (t *Amb) EC(skip int, event Event, comment string, args ...interface{})
- func (t *Amb) Filter() *filter.Filter
- func (t *Amb) Flags() *Flags
- func (t *Amb) GetState() string
- func (t *Amb) Labels() []string
- func (t *Amb) Push(l string) *Amb
- func (t *Amb) Refine(l string) *Amb
- func (t *Amb) SetState(s int)
- type Bytes
- type CCFixed
- type CCID
- type ChanLink
- type CongestionReset
- type Conn
- func (c *Conn) Abort()
- func (c *Conn) Amb() *Amb
- func (s *Conn) ChooseISS() int64
- func (c *Conn) Close() error
- func (c *Conn) Error() error
- func (s *Conn) GetAWLH() (AWL int64, AWH int64)
- func (s *Conn) GetCCMPS() int32
- func (s *Conn) GetGAR() int64
- func (s *Conn) GetGSR() int64
- func (s *Conn) GetGSS() int64
- func (s *Conn) GetISS() int64
- func (s *Conn) GetMPS() int32
- func (c *Conn) GetMTU() int
- func (s *Conn) GetOSR() int64
- func (s *Conn) GetPMTU() int32
- func (s *Conn) GetRTT() int64
- func (s *Conn) GetSWLH() (SWL int64, SWH int64)
- func (s *Conn) GetServiceCode() uint32
- func (s *Conn) GetState() int
- func (s *Conn) InAckWindow(x int64) bool
- func (s *Conn) IsServer() bool
- func (c *Conn) Joiner() Joiner
- func (c *Conn) LocalLabel() Bytes
- func (c *Conn) PlaceSeqAck(h *Header)
- func (c *Conn) Read() (b []byte, err error)
- func (c *Conn) RemoteLabel() Bytes
- func (s *Conn) SetCCIDA(v byte)
- func (s *Conn) SetCCIDB(v byte)
- func (s *Conn) SetCCMPS(v int32)
- func (s *Conn) SetGAR(v int64)
- func (s *Conn) SetGSR(v int64)
- func (s *Conn) SetGSS(v int64)
- func (s *Conn) SetISR(v int64)
- func (s *Conn) SetOSR(v int64)
- func (s *Conn) SetPMTU(v int32)
- func (s *Conn) SetRTT(v int64)
- func (c *Conn) SetReadExpire(nsec int64) error
- func (s *Conn) SetSWAF(v int64)
- func (s *Conn) SetSWBF(v int64)
- func (s *Conn) SetServer(v bool)
- func (s *Conn) SetServiceCode(v uint32)
- func (s *Conn) SetState(v int)
- func (s *Conn) String() string
- func (s *Conn) UpdateGAR(v int64)
- func (s *Conn) UpdateGSR(v int64)
- func (c *Conn) Write(data []byte) error
- func (c *Conn) WriteCC(h *Header, timeWrite int64)
- func (c *Conn) WriteSeqAck(h *writeHeader)
- type ElapsedTimeOption
- type Env
- func (t *Env) Close() error
- func (t *Env) Expire(test func() bool, onexpire func(), timeout, interval int64, fmt_ string, ...)
- func (t *Env) Filter() *filter.Filter
- func (t *Env) Go(f func(), fmt_ string, args_ ...interface{})
- func (t *Env) Joiner() Joiner
- func (t *Env) NewGoJoin(annotation string, group ...Joiner) *GoJoin
- func (t *Env) Now() int64
- func (t *Env) Sleep(ns int64)
- func (t *Env) Snap() (sinceZero int64, sinceLast int64)
- func (t *Env) Sync() error
- func (t *Env) TraceWriter() TraceWriter
- type Event
- type FeedbackHeader
- type FeedforwardHeader
- type FileTraceWriter
- type Flags
- type GoJoin
- type GoRoutine
- type Header
- func (h *Header) HasAckNo() bool
- func (h *Header) InitAckHeader()
- func (h *Header) InitCloseHeader()
- func (h *Header) InitDataAckHeader(data []byte)
- func (h *Header) InitDataHeader(data []byte)
- func (h *Header) InitRequestHeader(serviceCode uint32)
- func (h *Header) InitResetHeader(resetCode byte)
- func (h *Header) InitResponseHeader(serviceCode uint32)
- func (h *Header) InitSyncAckHeader()
- func (h *Header) InitSyncHeader()
- func (h *Header) String() string
- func (gh *Header) Write(sourceIP, destIP []byte, protoNo byte, allowShortSeqNoFeature bool) (header []byte, err error)
- type HeaderConn
- type Joiner
- type Label
- type Link
- type Mutex
- type Mux
- type Option
- type PreHeader
- type ProtoError
- type ReceiverCongestionControl
- type Sample
- type SegmentConn
- type SegmentDialAccepter
- type SenderCongestionControl
- type Stack
- type TimestampEchoOption
- type TimestampOption
- type Trace
- type TraceWriter
- type UDPLink
Constants ¶
const ( CCID2 = 2 // TCP-like Congestion Control, RFC 4341 CCID3 = 3 // TCP-Friendly Rate Control (TFRC), RFC 4342 )
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 )
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.
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
const ( CsCovAllData = iota CsCovNoData CsCov4 CsCov8 CsCov12 )
const ( MuxLingerTime = 60e9 // 1 min in nanoseconds MuxExpireTime = 600e9 // 10 min in nanoseconds MuxReadSafety = 5 )
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 )
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 )
const ( CLOSED = iota LISTEN REQUEST RESPOND PARTOPEN OPEN CLOSEREQ CLOSING TIMEWAIT )
The nine possible states of a DCCP socket. Listed in increasing order:
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 )
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 )
const (
AnyProto = iota
)
Constants for protoNo
const BackoffMin = 100e6
BackoffMin is the minimum time before two firings of the backoff timers
const CCID_FIXED = 0xf
const LabelLen = 16
const (
SEQNOMAX = (2 << 48) - 1
)
Variables ¶
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
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
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.
var (
LabelZero = Label{}
)
var SampleType = TypeOf(Sample{})
var ZeroAddr = &Addr{}
Functions ¶
func DecodeUint16 ¶
func DecodeUint24 ¶
func DecodeUint32 ¶
func DecodeUint48 ¶
func DecodeUint8 ¶
func EncodeUint16 ¶
func EncodeUint24 ¶
func EncodeUint32 ¶
func EncodeUint48 ¶
func EncodeUint8 ¶
func FetchCaller ¶
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 FitsIn23Bits ¶
func FitsIn24Bits ¶
func FitsIn32Bits ¶
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 ¶
NanoFromTenMicro converts a time length given in ten microsecond units into nanoseconds, without exceeding the maximum allowed time limit of MaxTenMicro.
func NewCongestionReset ¶
func ParseServiceCode ¶
func SavePanicTrace ¶
func SavePanicTrace()
func ServerString ¶
func ServiceCodeString ¶
func StackTrace ¶
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 TenMicroDiff ¶
TenMicroDiff returns the circular difference between t0 an t1. The arguments and the result are in ten microsecond units.
func TenMicroFromNano ¶
TenMicroFromNano converts a time length given in nanoseconds into units of 10 microseconds, capped by MaxTenMicro.
func TrimFuncName ¶
TrimFuncName shortens DCCP function names for readability and whether this is a DCCP or anonymous function
func TrimSourceFile ¶
TrimSourceFile shortens DCCP source file names for readability
Types ¶
type Addr ¶
Addr{} is a general-purpose data type intended for custom link layer addresses.
func (*Addr) Address ¶
Address() is identical to String(), included as a method so that Addr conforms to net.Addr
func (*Addr) Network ¶
Network() returns the name of the link address namespace, included to conform to net.Addr
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
func (*Amb) E ¶
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) GetState ¶
GetState retrieves the state of the owning object, using 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
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 ¶
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)
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) ChooseISS ¶
func (s *Conn) ChooseISS() int64
ChooseISS chooses a safe Initial Sequence Number
func (*Conn) GetMTU ¶
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) GetServiceCode ¶
func (s *Conn) GetServiceCode() uint32
func (*Conn) InAckWindow ¶
func (*Conn) Joiner ¶
Joiner returns a Joiner instance that can wait until all goroutines associated with the connection have completed.
func (*Conn) LocalLabel ¶
LocalLabel implements SegmentConn.LocalLabel
func (*Conn) PlaceSeqAck ¶
PlaceSeqAck() updates the socket registers upon receiving a header from the other side.
func (*Conn) Read ¶
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 ¶
RemoteLabel implements SegmentConn.RemoteLabel
func (*Conn) SetReadExpire ¶
SetReadExpire implements SegmentConn.SetReadExpire
func (*Conn) SetServiceCode ¶
func (s *Conn) SetServiceCode(v uint32)
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 ¶
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) 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) Go ¶
Go runs f in a new GoRoutine. The GoRoutine is also added to the GoJoin of the Env.
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.
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 ¶
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 ¶
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.
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 NewGoJoinCaller ¶
NewGoJoinCaller creates an object capable of waiting until all supplied GoRoutines complete.
func (*GoJoin) Add ¶
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 ¶
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.
type GoRoutine ¶
type GoRoutine struct {
// contains filtered or unexported fields
}
GoRoutine represents a running goroutine.
func GoCaller ¶
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.
type Header ¶
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 (*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 ¶
InitDataAckHeader() creates a new DataAck header
func (*Header) InitDataHeader ¶
InitDataHeader() creates a new Data header
func (*Header) InitRequestHeader ¶
InitRequestHeader() creates a new Request header
func (*Header) InitResetHeader ¶
InitResetHeader() creates a new Reset header
func (*Header) InitResponseHeader ¶
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) 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 ¶
ParseLabel() parses and creates a new label from the string representation in s@
type Link ¶
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 ¶
func (*Mutex) AssertLocked ¶
func (m *Mutex) AssertLocked()
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 (*Mux) Accept ¶
func (m *Mux) Accept() (c SegmentConn, err error)
Accept() returns the first incoming flow request
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 ¶
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
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 (*Stack) Accept ¶
func (s *Stack) Accept() (c SegmentConn, err error)
Accept blocks until a new connecion is established. It then returns the connection.
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 (*Trace) LabelString ¶
LabelString returns a textual representation of the label stack of this log
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 ¶
TraceWriter is a type that consumes log entries.
Source Files
¶
- addr.go
- amb.go
- backoff.go
- cc.go
- ccfixed.go
- chanlink.go
- checksum.go
- conn.go
- ctrlc.go
- dccp.go
- dial.go
- emit.go
- env.go
- err.go
- filetrace.go
- flags.go
- flow.go
- gen.go
- goto.go
- header.go
- headerutil.go
- inj.go
- join.go
- label.go
- link.go
- listener.go
- mono.go
- mutex.go
- mux.go
- muxmsg.go
- options.go
- pipe.go
- read.go
- reorder.go
- segment.go
- seqack.go
- servicecode.go
- socket.go
- stack.go
- steps.go
- string.go
- term.go
- timeopt.go
- trace.go
- udplink.go
- user.go
- util.go
- wire.go
- write.go