sim

package
v0.0.0-...-b785d8d Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Counter

type Counter struct {
	Cur Matrix
	Sum Matrix
}

func NewCounter

func NewCounter() *Counter

func (*Counter) Clear

func (self *Counter) Clear()

func (*Counter) ClearSum

func (self *Counter) ClearSum()

func (*Counter) Count

func (self *Counter) Count(lane int, n uint64)

func (*Counter) CountMatrix

func (self *Counter) CountMatrix(m Matrix)

func (*Counter) CountPacket

func (self *Counter) CountPacket(p *Packet)

func (*Counter) CurTotal

func (self *Counter) CurTotal() uint64

type Display

type Display interface {
	Start(setup *Setup)

	TakesHour() bool
	DrawHour(r *HourReport)

	Stop()
}

type Estimator

type Estimator interface {
	// Returns the demand for the next weeklen
	Estimate() (structs.Matrix, uint64)
}

type Events

type Events uint64
const (
	Noop    Events = 0
	NewWeek Events = 0x1
	Dusk    Events = 0x2
	Dawn    Events = 0x4
)

func (Events) Set

func (self Events) Set(e Events) Events

func (Events) Test

func (self Events) Test(e Events) bool

type Flows

type Flows interface {
	Nflow() int
}

type Hosts

type Hosts interface {
	// Called every tick, may send packets to the sender,
	// which will be relayed to the switch.
	Tick(sender blocks.Sender)

	// Hosts are blocks. They receive packets from the switch.
	blocks.Block
}

type HourReport

type HourReport struct {
	T        uint64
	NewWeek  bool
	Send     Matrix
	Recv     Matrix
	CircRecv Matrix
	PackRecv Matrix
	Drop     Matrix
	Sched    Matrix
}

type LineProgress

type LineProgress struct {
	NoSingleLine bool

	Flows Flows
	// contains filtered or unexported fields
}

func NewLineProgress

func NewLineProgress() *LineProgress

func (*LineProgress) Start

func (self *LineProgress) Start(s *ProgressStat)

func (*LineProgress) Stop

func (self *LineProgress) Stop(s *ProgressStat)

func (*LineProgress) Tick

func (self *LineProgress) Tick(s *ProgressStat)

type Monitor

type Monitor interface {
	// Tells the demand for the current tick.
	Tell(demand structs.Matrix)
}

type Progress

type Progress interface {
	Start(s *ProgressStat)
	Tick(s *ProgressStat)
	Stop(s *ProgressStat)
}

type ProgressStat

type ProgressStat struct {
	T        uint64 // time now
	Goodput  uint64 // Bytes delivered
	Circput  uint64 // Bytes delivered via circuit
	Packput  uint64 // Bytes delivered via packet
	Dropped  uint64 // Bytes dropped
	Capacity uint64 // Bytes could deliver
}

type Recorder

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

func NewRecorder

func NewRecorder(w io.Writer) *Recorder

func (*Recorder) Record

func (self *Recorder) Record(t *Tick)

type SchedRecorder

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

func NewSchedRecorder

func NewSchedRecorder(out io.Writer) *SchedRecorder

func (*SchedRecorder) Log

func (self *SchedRecorder) Log(days []*Day)

type Scheduler

type Scheduler interface {
	// Based on the "demand" given for the next "wind" amount of ticks
	// Returns a series of days, and the allocated bandwidth matrix
	Schedule(leftover, demand Matrix, wind uint64) (days []*Day, bandw Matrix)
}

type Setup

type Setup struct {
	Nhost     int
	LinkBw    uint64
	PackBw    uint64
	WeekLen   uint64
	MinDayLen uint64
	AvgDayLen uint64
	NightLen  uint64

	NicBufSize    uint64
	SwitchBufSize uint64

	TickPerHour uint64

	TickTime time.Duration
}

type Stopper

type Stopper interface {
	ShouldStop() bool
}

type Switch

type Switch interface {
	// Tells if the switch is a TDMA switch.
	Tdma() bool

	/*
		A switch is a sender where other parts can
		queue some packet onto the switch.
		Nics queues are also part of the switch.
	*/
	blocks.Sender

	/*
		Moves packet inside the switch to the sink.

		If the switch is a TDMA switch (a circuit switch or a
		hybrid switches), it uses the estimator to estimate
		the demand in the near future. Returns the schedule for
		current tick, and the schedule events that happens at
		the end of the tick.

		If the switch is not a TDMA switch (a packet switch),
		then it just moves packets, and always returns (nil, 0)
	*/
	Tick(sink blocks.Block, estimator Estimator) (Matrix, Events)

	// Sets the switch to use a particular scheduler
	Bind(s Scheduler, logger *SchedRecorder)

	Served() (circ Matrix, pack Matrix)
}

type Testbed

type Testbed struct {
	Hosts     Hosts     // Send and receive packets
	Switch    Switch    // Transmits packets from host to host
	Estimator Estimator // (TDMA switch only), estimates the upcoming demands
	Scheduler Scheduler // (TDMA switch only), breaks the demand into days
	Monitor   Monitor   // (optional) tracks past demands
	Stopper   Stopper   // (optional) tells the testbed to stop
	Display   Display   // (optional) displays the simulation status
	Progress  Progress  // (optional) shows the simulation progress

	WarmUp  uint64
	EndTime uint64 // The time that the simulation ends

	*ProgressStat
	// contains filtered or unexported fields
}

A Testbed runs a simulation

func NewTestbed

func NewTestbed(h Hosts, s Switch) *Testbed

func (*Testbed) LogSchedTo

func (self *Testbed) LogSchedTo(w io.Writer)

func (*Testbed) RecordTo

func (self *Testbed) RecordTo(w io.Writer)

func (*Testbed) Run

func (self *Testbed) Run(t uint64) error

func (*Testbed) Summarize

func (self *Testbed) Summarize(out io.Writer) error

type Tick

type Tick struct {
	T uint64

	NewWeek bool
	Dusk    bool
	Dawn    bool

	Send  Matrix
	Recv  Matrix
	Circ  Matrix
	Pack  Matrix
	Drop  Matrix
	Sched Matrix
}

Directories

Path Synopsis
Package dem takes a demand file and convert it to a number of hosts
Package dem takes a demand file and convert it to a number of hosts

Jump to

Keyboard shortcuts

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