tcp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HdrLenMax = 60 // byte
	HdrLenMin = 20
)

Variables

View Source
var PcbRepo *pcbRepo

Functions

func Bind

func Bind(id int, local EndPoint) psErr.E

func Connect

func Connect(id int, foreign EndPoint) psErr.E

func Listen

func Listen(id int, backlogSize int) psErr.E

func Open

func Open() (int, psErr.E)

func Receive

func Receive(msg *mw.TcpRxMessage) psErr.E

func Send

func Send(pcb *PCB, flag Flag, data []byte) psErr.E

func Start

func Start(wg *sync.WaitGroup) psErr.E

func Stop

func Stop()

Types

type Backlog

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

func (*Backlog) Pop

func (p *Backlog) Pop() *PCB

func (*Backlog) Push

func (p *Backlog) Push(pcb *PCB) psErr.E

type EndPoint

type EndPoint struct {
	Addr mw.V4Addr // ipv4 address
	Port uint16    // port number
}

func Accept

func Accept(id int) (int, EndPoint, psErr.E)

type Flag

type Flag uint8

func (Flag) IsSet

func (v Flag) IsSet(flag uint8) bool

type Hdr

type Hdr struct {
	Src      uint16 // source port
	Dst      uint16 // destination port
	Seq      uint32 // sequence number
	Ack      uint32 // acknowledgement number
	Offset   uint8  // offset (4bits), reserved (3bits), ns (1bit)
	Flag     Flag   // cwr, ece, urg, ack, psh, rst, syn, fin
	Wnd      uint16 // window size
	Checksum uint16
	Urg      uint16 // urgent pointer
}

type PCB

type PCB struct {
	ID      int
	State   int      // tcp state
	Local   EndPoint // local address/port
	Foreign EndPoint // foreign address/port
	MTU     uint16   // maximum transmission unit
	MSS     uint16   // maximum segment size
	SND     struct {
		UNA uint32 // oldest unacknowledged sequence number
		NXT uint32 // next sequence number to be sent
		WND uint16 // window size
		UP  uint16 // urgent pointer to be sent
		WL1 uint32 // segment sequence number at Last window update
		WL2 uint32 // segment acknowledgment number at Last window update
	}
	RCV struct {
		NXT uint32 // next sequence number to receive
		WND uint16 // window size
		UP  uint16 // urgent pointer to receive
	}
	ISS uint32
	IRS uint32 // initial receive sequence number
	// contains filtered or unexported fields
}

type PseudoHdr

type PseudoHdr struct {
	Src   mw.V4Addr // source address
	Dst   mw.V4Addr // destination address
	Zero  uint8     // zeros
	Proto uint8     // protocol
	Len   uint16    // segment length
}

type SegmentInfo

type SegmentInfo struct {
	Seq  uint32 // sequence number
	Ack  uint32 // acknowledgement number
	Wnd  uint16 // window size
	Flag Flag
}

Jump to

Keyboard shortcuts

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