protocol

package
v0.0.0-...-63ff7ac Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_VERSION      = 4
	MIN_IP_HEADER_LENGTH = 5
	ICMP_PROTO           = 1
	ECHO_REQUEST         = 8
	NO_FRAGMENT          = 2
	MAX_TTL              = 255
	DEFAULT_TIMEOUT      = 2
)

Variables

This section is empty.

Functions

func ParseTimestamp

func ParseTimestamp(timestamp []byte) time.Time

Types

type IcmpProto

type IcmpProto struct {
	Type           uint8
	Code           uint8
	Checksum       uint16
	Identifier     uint16
	SequenceNumber uint16
	Data           []byte
}

func NewIcmpProto

func NewIcmpProto() *IcmpProto

func (*IcmpProto) ClearChecksum

func (packet *IcmpProto) ClearChecksum()

func (*IcmpProto) ComputeChecksum

func (packet *IcmpProto) ComputeChecksum()

func (*IcmpProto) SetSequenceNumber

func (packet *IcmpProto) SetSequenceNumber(sequenceNumber uint16)

func (*IcmpProto) SetTimestamp

func (packet *IcmpProto) SetTimestamp()

func (*IcmpProto) ToBytes

func (packet *IcmpProto) ToBytes() []byte

type IcmpReply

type IcmpReply struct {
	IpHeader *IpProtoHeader
	Reply    *IcmpProto
}

type IcmpRequest

type IcmpRequest struct {
	IpHeader *IpProtoHeader
	Request  *IcmpProto
}

func NewIcmpRequest

func NewIcmpRequest(dst net.IP) *IcmpRequest

func (*IcmpRequest) SendRequest

func (icmp *IcmpRequest) SendRequest(dstAddr [4]byte) *IcmpReply

func (*IcmpRequest) ToBytes

func (icmpReq *IcmpRequest) ToBytes() []byte

type IpProtoHeader

type IpProtoHeader struct {
	Version        uint8
	IHL            uint8
	TypeOfService  uint8
	TotalLength    uint16
	Identifier     uint16
	Flags          uint16
	FragmentOffset uint16
	TTL            uint8
	Protocol       uint8
	Checksum       uint16
	SrcAddr        net.IP
	DstAddr        net.IP
}

func NewIPHeader

func NewIPHeader(dstAddr net.IP) *IpProtoHeader

func (*IpProtoHeader) ToBytes

func (ipProto *IpProtoHeader) ToBytes() []byte

type Statistics

type Statistics struct {
	Received    int
	Transmitted int
	TotalTime   time.Duration
}

func NewStatistics

func NewStatistics() *Statistics

func (*Statistics) IncrementReceived

func (stats *Statistics) IncrementReceived()

func (*Statistics) IncrementTransmitted

func (stats *Statistics) IncrementTransmitted()

func (*Statistics) PrettyStats

func (stats *Statistics) PrettyStats(dstAddr string)

func (*Statistics) SetTotalTime

func (stats *Statistics) SetTotalTime(startTime time.Time)

Jump to

Keyboard shortcuts

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