Documentation ¶
Index ¶
- func MakePathway(ctx model.SimContext, l2rByteDuration, r2lByteDuration time.Duration) (*Connection, *Connection)
- type ByteSchedule
- func (cs *ByteSchedule) ClearBytes(startTime model.VirtualTime)
- func (cs *ByteSchedule) FillBytes(startTime model.VirtualTime, byteDuration time.Duration, bytes []byte)
- func (cs *ByteSchedule) LastEndTime() model.VirtualTime
- func (cs *ByteSchedule) LookupEndTime(nth int) model.VirtualTime
- func (cs *ByteSchedule) PeekAllBytes() (out []byte)
- func (cs *ByteSchedule) ReceiveBytes(endTime model.VirtualTime) []byte
- type Connection
- func (tc *Connection) ConsumeBytesUpTo(upto model.VirtualTime, count int)
- func (tc *Connection) CountTxBytesRemaining() (count int, remainingStartAt model.VirtualTime)
- func (tc *Connection) LastEndTime() model.VirtualTime
- func (tc *Connection) LookupEndTime(nth int) model.VirtualTime
- func (tc *Connection) PeekAllBytes() []byte
- func (tc *Connection) PullBytesAvailable() []byte
- func (tc *Connection) Subscribe(callback func()) (cancel func())
- func (tc *Connection) UpdateTransmission(transmissionStart model.VirtualTime, newBytes []byte)
- type ScheduleItem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakePathway ¶
func MakePathway(ctx model.SimContext, l2rByteDuration, r2lByteDuration time.Duration) (*Connection, *Connection)
Types ¶
type ByteSchedule ¶
type ByteSchedule struct {
// contains filtered or unexported fields
}
ByteSchedule is a data structure reflecting an unlimited sequence of timestamped bytes. Each data item can be considered a 3-tuple of (start-time, end-time, byte-value). This sequence is *predicted*... that means that each data item does not become finalized until sim.Now() is strictly greater than the data item's start time.
Contract:
- New data items can only be added with start-times no earlier than sim.Now()
- Data items with start-times no earlier than sim.Now() may be deleted.
- Data items may never overlap, though end-time[n] = start-time[n+1] does not qualify as an overlap.
- Sequence changes (deletions, appends) may only occur on suffixes of the unlimited sequence. Changes may not be made in the middle.
- The recipient, however, may excise prefixes with end times no later than sim.Now(), as an optimization.
func MakeByteSchedule ¶
func MakeByteSchedule(ctx model.SimContext) *ByteSchedule
func (*ByteSchedule) ClearBytes ¶
func (cs *ByteSchedule) ClearBytes(startTime model.VirtualTime)
ClearBytes deletes a suffix of existing bytes. Any data items with start-times equal to or later than startTime will be removed from the sequence. startTime must be no earlier than sim.Now().
func (*ByteSchedule) FillBytes ¶
func (cs *ByteSchedule) FillBytes(startTime model.VirtualTime, byteDuration time.Duration, bytes []byte)
FillBytes appends a suffix of additional bytes. Each byte is translated to a data item: (startTime + byteDuration * i, startTime + byteDuration * (i+1), byte[i]) startTime must be no earlier than sim.Now().
func (*ByteSchedule) LastEndTime ¶
func (cs *ByteSchedule) LastEndTime() model.VirtualTime
LastEndTime determines the last transmission time of the final byte scheduled, or the current time, whichever is later.
func (*ByteSchedule) LookupEndTime ¶
func (cs *ByteSchedule) LookupEndTime(nth int) model.VirtualTime
LookupEndTime determines the end time of the nth byte returned by PeekAllBytes()
func (*ByteSchedule) PeekAllBytes ¶
func (cs *ByteSchedule) PeekAllBytes() (out []byte)
PeekAllBytes returns the complete sequence of bytes, including predicted bytes.
func (*ByteSchedule) ReceiveBytes ¶
func (cs *ByteSchedule) ReceiveBytes(endTime model.VirtualTime) []byte
ReceiveBytes extracts the prefix of existing bytes that are finalized and returns them as a byte array.
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) ConsumeBytesUpTo ¶
func (tc *Connection) ConsumeBytesUpTo(upto model.VirtualTime, count int)
func (*Connection) CountTxBytesRemaining ¶
func (tc *Connection) CountTxBytesRemaining() (count int, remainingStartAt model.VirtualTime)
func (*Connection) LastEndTime ¶
func (tc *Connection) LastEndTime() model.VirtualTime
func (*Connection) LookupEndTime ¶
func (tc *Connection) LookupEndTime(nth int) model.VirtualTime
func (*Connection) PeekAllBytes ¶
func (tc *Connection) PeekAllBytes() []byte
func (*Connection) PullBytesAvailable ¶
func (tc *Connection) PullBytesAvailable() []byte
func (*Connection) Subscribe ¶
func (tc *Connection) Subscribe(callback func()) (cancel func())
Subscribe to changes in the future transmission schedule
func (*Connection) UpdateTransmission ¶
func (tc *Connection) UpdateTransmission(transmissionStart model.VirtualTime, newBytes []byte)
type ScheduleItem ¶
type ScheduleItem struct { StartTime model.VirtualTime EndTime model.VirtualTime Byte byte }