packet

package
v0.0.0-...-70695b7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MPL-2.0 Imports: 4 Imported by: 0

README

packet - rdtp segment header structure

Documentation license

Header Format
 0      7 8     15 16    23 24    31
+--------+--------+--------+--------+
|     Src. Port   |    Dst. Port    |
+--------+--------+--------+--------+
|      Length     |    Checksum     |
+--------+--------+--------+--------+
|          Sequence Number          |
+--------+-----------------+--------+
|       Acknowledgement Number      |
+--------+-----------------+--------+
|  Flags |                          |
+--------+                          |
|             ( Data )              |
+               ....                +

Documentation

Index

Constants

View Source
const (
	// MaxPacketBytes is the maximum size of an RDTP packet incl. header
	MaxPacketBytes = 1500 // will chunk otherwise

	// HeaderByteSize is the byte size of an RDTP header
	HeaderByteSize = 17

	// MaxPayloadBytes is the maximum size of a payload that
	// a single RDTP packet can carry
	MaxPayloadBytes = MaxPacketBytes - HeaderByteSize
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Packet

type Packet struct {
	// connection identifyers
	SrcPort uint16
	DstPort uint16

	// processing and integrity
	Length   uint16
	Checksum uint16

	// reliability
	SeqNo uint32
	AckNo uint32

	// control
	Flags uint8 // {SYN, FIN, ACK, ERR, XXXX, XXXX, XXXX, XXXX}

	// data
	Payload []byte
	// contains filtered or unexported fields
}

Packet is an RDTP packet

func Deserialize

func Deserialize(data []byte) (*Packet, error)

Deserialize byte decodes an RDTP packet

func NewPacket

func NewPacket(src, dst uint16, payload []byte) (*Packet, error)

NewPacket populates an RDTP packet onto a serializable state representation

func (*Packet) CheckSum

func (p *Packet) CheckSum() bool

CheckSum verifies the checksum on an rdtp packet

func (*Packet) GetDestinationIPv4

func (p *Packet) GetDestinationIPv4() (net.IP, error)

GetDestinationIPv4 returns the destination IPv4 set on the packet or an error if none is set

func (*Packet) GetSourceIPv4

func (p *Packet) GetSourceIPv4() (net.IP, error)

GetSourceIPv4 returns the source IPv4 set on the packet or an error if none is set

func (*Packet) IsACK

func (p *Packet) IsACK() bool

IsACK returns true if the ACK flag is set

func (*Packet) IsERR

func (p *Packet) IsERR() bool

IsERR returns true if the ERR flag is set

func (*Packet) IsFIN

func (p *Packet) IsFIN() bool

IsFIN returns true if the FIN flag is set

func (*Packet) IsSYN

func (p *Packet) IsSYN() bool

IsSYN returns true if the SYN flag is set

func (*Packet) Serialize

func (p *Packet) Serialize() []byte

Serialize byte-encodes an RDTP packet ready to be encapsulated in a network layer protocol packet (i.e. IP datagram)

func (*Packet) SetAckNo

func (p *Packet) SetAckNo(ack uint32)

SetAckNo sets the acknowledgement number of this packet

func (*Packet) SetDestinationIPv4

func (p *Packet) SetDestinationIPv4(ip net.IP)

SetDestinationIPv4 sets the destination IPv4 on the packet

func (*Packet) SetFlagACK

func (p *Packet) SetFlagACK()

SetFlagACK sets the ACK flag on a packet

func (*Packet) SetFlagERR

func (p *Packet) SetFlagERR()

SetFlagERR sets the ERR flag on a packet

func (*Packet) SetFlagFIN

func (p *Packet) SetFlagFIN()

SetFlagFIN sets the FIN flag on a packet

func (*Packet) SetFlagSYN

func (p *Packet) SetFlagSYN()

SetFlagSYN sets the SYN flag on a packet

func (*Packet) SetSeqNo

func (p *Packet) SetSeqNo(seq uint32)

SetSeqNo sets the sequence number of this packet

func (*Packet) SetSourceIPv4

func (p *Packet) SetSourceIPv4(ip net.IP)

SetSourceIPv4 sets the source IPv4 on the packet

func (*Packet) SetSum

func (p *Packet) SetSum()

SetSum sets the checksum on an rdtp packet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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