Documentation
¶
Index ¶
- Constants
- Variables
- func IPChecksum(packet []byte) uint16
- func IPSetChecksum(packet []byte, sum uint16)
- func LogDebug(format string, v ...any)
- func LogError(format string, v ...any)
- func LogFatal(format string, v ...any)
- func LogInfo(format string, v ...any)
- func LogWarn(format string, v ...any)
- func OpenIPSocket(addr net.IP) (*net.IPConn, error)
- func OpenRawSocket() (io.ReadWriteCloser, error)
- func SetLogLevel(l LogLevel)
- func TCPChecksum(packet []byte, srcAddr, dstAddr net.IP) uint16
- func TCPSetChecksum(packet []byte, sum uint16)
- type IPConn
- type IPPacket
- type IPProtcolHandler
- type IPSender
- type IPStack
- type LogLevel
- type SyncClient
- type SyncHandler
- type SyncServer
- type SyncedBuffer
- func (b *SyncedBuffer) Ack(ack uint32) bool
- func (b *SyncedBuffer) Append(buf []byte) int
- func (b *SyncedBuffer) Cap() int
- func (b *SyncedBuffer) Consume(n int)
- func (b *SyncedBuffer) EndSeq() uint64
- func (b *SyncedBuffer) Fetch(buf []byte, offset int) int
- func (b *SyncedBuffer) FillStateUpdate(update *pb.BufferStateUpdate)
- func (b *SyncedBuffer) Free() int
- func (b *SyncedBuffer) HasUnsentData() bool
- func (b *SyncedBuffer) Len() int
- func (b *SyncedBuffer) NextSendSeq() uint64
- func (b *SyncedBuffer) ResetNextSeq()
- func (b *SyncedBuffer) SendData(numBytes int)
- func (b *SyncedBuffer) StartSeq() uint64
- func (b *SyncedBuffer) Sync(req *pb.BufferStateUpdate, reply *pb.BufferStateUpdate)
- func (b *SyncedBuffer) UpdateState(req *pb.BufferStateUpdate)
- type TCPConnMap
- type TCPConnState
- func (s *TCPConnState) AppendAt(b []byte, offset uint64) (int, error)
- func (s *TCPConnState) Close() error
- func (s *TCPConnState) ConsumePacket(hdr *TCPHeader, data []byte) error
- func (s *TCPConnState) ConsumeThenRead(b []byte, offset uint64) (int, error)
- func (s *TCPConnState) Read(b []byte) (int, error)
- func (s *TCPConnState) RemoteIPAddr() *net.IPAddr
- func (s *TCPConnState) RemotePort() uint16
- func (s *TCPConnState) Sync(req *pb.SyncRequest, reply *pb.SyncReply) error
- func (s *TCPConnState) Write(b []byte) (int, error)
- type TCPHeader
- type TCPSender
- type TCPStack
- func (s *TCPStack) GetConn(remoteAddr *net.IPAddr, remotePort uint16) *TCPConnState
- func (s *TCPStack) HandleIPPacket(packet *IPPacket) error
- func (s *TCPStack) Listen() (*TCPConnState, error)
- func (s *TCPStack) SendSyncRequest(req *pb.SyncRequest, reply *pb.SyncReply) error
- func (s *TCPStack) SendTCPPacket(b []byte, addr *net.IPAddr, port uint16) error
- func (s *TCPStack) SetSyncClient(c *SyncClient)
- func (s *TCPStack) Sync(req *pb.SyncRequest, reply *pb.SyncReply) error
- type TCPTimestamp
Constants ¶
View Source
const ( TcpOptionMss = 2 TcpOptionWindowScaling = 3 TcpOptionSackPermitted = 4 TcpOptionSack = 5 TcpOptionTimestamp = 8 TcpMinHeaderSize = 20 )
Variables ¶
View Source
var (
ErrTimeout = errors.New("sync_client: timeout")
)
Functions ¶
func IPChecksum ¶
func IPSetChecksum ¶
func OpenRawSocket ¶
func OpenRawSocket() (io.ReadWriteCloser, error)
func SetLogLevel ¶
func SetLogLevel(l LogLevel)
func TCPSetChecksum ¶
Types ¶
type IPPacket ¶
func MakeIPPacket ¶
type IPProtcolHandler ¶
type IPStack ¶
type IPStack struct {
// contains filtered or unexported fields
}
func (*IPStack) RegisterProtocolHandler ¶
func (s *IPStack) RegisterProtocolHandler(proto int, handler IPProtcolHandler)
type SyncClient ¶
type SyncClient struct {
// contains filtered or unexported fields
}
func NewSyncClient ¶
func NewSyncClient(addr string) *SyncClient
func (*SyncClient) Close ¶
func (c *SyncClient) Close() error
func (*SyncClient) SendSync ¶
func (c *SyncClient) SendSync(req *pb.SyncRequest, reply *pb.SyncReply) error
type SyncHandler ¶
type SyncHandler interface {
Sync(*pb.SyncRequest, *pb.SyncReply) error
}
type SyncServer ¶
type SyncServer struct {
// contains filtered or unexported fields
}
func NewSyncServer ¶
func NewSyncServer(l net.Listener, h SyncHandler) *SyncServer
type SyncedBuffer ¶
type SyncedBuffer struct {
// contains filtered or unexported fields
}
func NewSyncedBuffer ¶
func NewSyncedBuffer(initSeq uint32, initWindowSize int) *SyncedBuffer
func (*SyncedBuffer) Ack ¶
func (b *SyncedBuffer) Ack(ack uint32) bool
func (*SyncedBuffer) Append ¶
func (b *SyncedBuffer) Append(buf []byte) int
func (*SyncedBuffer) Cap ¶
func (b *SyncedBuffer) Cap() int
func (*SyncedBuffer) Consume ¶
func (b *SyncedBuffer) Consume(n int)
func (*SyncedBuffer) EndSeq ¶
func (b *SyncedBuffer) EndSeq() uint64
Sequence number of one past the end of the buffer
func (*SyncedBuffer) FillStateUpdate ¶
func (b *SyncedBuffer) FillStateUpdate(update *pb.BufferStateUpdate)
func (*SyncedBuffer) Free ¶
func (b *SyncedBuffer) Free() int
func (*SyncedBuffer) HasUnsentData ¶
func (b *SyncedBuffer) HasUnsentData() bool
func (*SyncedBuffer) Len ¶
func (b *SyncedBuffer) Len() int
func (*SyncedBuffer) NextSendSeq ¶
func (b *SyncedBuffer) NextSendSeq() uint64
func (*SyncedBuffer) ResetNextSeq ¶
func (b *SyncedBuffer) ResetNextSeq()
func (*SyncedBuffer) SendData ¶
func (b *SyncedBuffer) SendData(numBytes int)
func (*SyncedBuffer) StartSeq ¶
func (b *SyncedBuffer) StartSeq() uint64
func (*SyncedBuffer) Sync ¶
func (b *SyncedBuffer) Sync(req *pb.BufferStateUpdate, reply *pb.BufferStateUpdate)
func (*SyncedBuffer) UpdateState ¶
func (b *SyncedBuffer) UpdateState(req *pb.BufferStateUpdate)
type TCPConnMap ¶
type TCPConnMap struct {
// contains filtered or unexported fields
}
func MakeTCPConnMap ¶
func MakeTCPConnMap() *TCPConnMap
func (*TCPConnMap) GetState ¶
func (m *TCPConnMap) GetState(ip net.IP, port uint16) *TCPConnState
func (*TCPConnMap) PutState ¶
func (m *TCPConnMap) PutState(ip net.IP, port uint16, state *TCPConnState)
type TCPConnState ¶
type TCPConnState struct {
// contains filtered or unexported fields
}
func NewTCPConnState ¶
func NewTCPConnState(localPort, remotePort uint16, sender TCPSender, remoteAddr *net.IPAddr) *TCPConnState
func (*TCPConnState) AppendAt ¶
func (s *TCPConnState) AppendAt(b []byte, offset uint64) (int, error)
func (*TCPConnState) Close ¶
func (s *TCPConnState) Close() error
func (*TCPConnState) ConsumePacket ¶
func (s *TCPConnState) ConsumePacket(hdr *TCPHeader, data []byte) error
func (*TCPConnState) ConsumeThenRead ¶
func (s *TCPConnState) ConsumeThenRead(b []byte, offset uint64) (int, error)
func (*TCPConnState) RemoteIPAddr ¶
func (s *TCPConnState) RemoteIPAddr() *net.IPAddr
func (*TCPConnState) RemotePort ¶
func (s *TCPConnState) RemotePort() uint16
func (*TCPConnState) Sync ¶
func (s *TCPConnState) Sync(req *pb.SyncRequest, reply *pb.SyncReply) error
type TCPHeader ¶
type TCPHeader struct {
SrcPort uint16
DstPort uint16
SeqNum uint32
AckNum uint32
DataOff int
Fin bool
Syn bool
Rst bool
Psh bool
Ack bool
Urg bool
WindowSize int
Checksum uint16
UrgentPointer int
Options []byte
Timestamp *TCPTimestamp
}
func ParseTCPHeader ¶
func (*TCPHeader) MarshalSize ¶
type TCPStack ¶
type TCPStack struct {
// contains filtered or unexported fields
}
func (*TCPStack) GetConn ¶
func (s *TCPStack) GetConn(remoteAddr *net.IPAddr, remotePort uint16) *TCPConnState
func (*TCPStack) HandleIPPacket ¶
func (*TCPStack) Listen ¶
func (s *TCPStack) Listen() (*TCPConnState, error)
func (*TCPStack) SendSyncRequest ¶
func (*TCPStack) SendTCPPacket ¶
func (*TCPStack) SetSyncClient ¶
func (s *TCPStack) SetSyncClient(c *SyncClient)
type TCPTimestamp ¶
func (*TCPTimestamp) String ¶
func (t *TCPTimestamp) String() string
Source Files
¶
Click to show internal directories.
Click to hide internal directories.