Documentation ¶
Overview ¶
Package tcpcl provides a library for the Delay-Tolerant Networking TCP Convergence Layer Protocol Version 4, draft-ietf-dtn-tcpclv4-14.
A new TCPCL server can be started by the Listener, which provides multiple connection to its Clients. To reach a remote server, a new Client connection can be dialed.
Index ¶
- Constants
- type Client
- func (client *Client) Address() string
- func (client *Client) Channel() chan cla.ConvergenceStatus
- func (client *Client) Close()
- func (client *Client) GetEndpointID() bundle.EndpointID
- func (client *Client) GetPeerEndpointID() bundle.EndpointID
- func (client *Client) IsPermanent() bool
- func (client *Client) Send(bndl *bundle.Bundle) error
- func (client *Client) Start() (err error, retry bool)
- func (client *Client) String() string
- type ClientState
- type ContactFlags
- type ContactHeader
- type DataAcknowledgementMessage
- type DataTransmissionMessage
- type IncomingTransfer
- type KeepaliveMessage
- type Listener
- type Message
- type MessageRejectionMessage
- type MessageRejectionReason
- type OutgoingTransfer
- type SegmentFlags
- type SessionInitMessage
- type SessionTerminationCode
- type SessionTerminationFlags
- type SessionTerminationMessage
- type TransferRefusalCode
- type TransferRefusalMessage
Constants ¶
const KEEPALIVE uint8 = 0x04
KEEPALIVE is the Message Header code for a Keepalive Message.
const MSG_REJECT uint8 = 0x06
MSG_REJECT is the Message Header code for a Message Rejection Message.
const SESS_INIT uint8 = 0x07
SESS_INIT is the Message Header code for a Session Initialization Message.
const SESS_TERM uint8 = 0x05
SESS_TERM is the Message Header code for a Session Termination Message.
const XFER_ACK uint8 = 0x02
XFER_ACK is the Message Header code for a Data Acknowledgement Message.
const XFER_REFUSE uint8 = 0x03
XFER_REFUSE is the Message Header code for a Transfer Refusal Message.
const XFER_SEGMENT uint8 = 0x01
XFER_SEGMENT is the Message Header code for a Data Transmission Message.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a TCPCL client for a bidirectional Bundle exchange. Thus, the Client type implements both cla.ConvergenceReceiver and cla.ConvergenceSender. A Client can be created by the Listener for incoming connections or dialed for outbounding connections.
func DialClient ¶
func DialClient(address string, endpointID bundle.EndpointID, permanent bool) *Client
DialClient tries to establish a new TCPCL Client to a remote server.
func NewClient ¶
func NewClient(conn net.Conn, endpointID bundle.EndpointID) *Client
NewClient creates a new Client on an existing connection. This function is used from the Listener.
func (*Client) Channel ¶
func (client *Client) Channel() chan cla.ConvergenceStatus
func (*Client) GetEndpointID ¶
func (client *Client) GetEndpointID() bundle.EndpointID
func (*Client) GetPeerEndpointID ¶
func (client *Client) GetPeerEndpointID() bundle.EndpointID
func (*Client) IsPermanent ¶
type ClientState ¶
type ClientState struct {
// contains filtered or unexported fields
}
ClientState describes the state of a TCPCL Client. Each Client can always upgrade its state to a later one, but cannot go back to a previous state. A transition can be made into the following or the termination state.
func (*ClientState) IsContact ¶
func (cs *ClientState) IsContact() bool
IsContact checks if the ClientState is in the contact state.
func (*ClientState) IsEstablished ¶
func (cs *ClientState) IsEstablished() bool
IsEstablished checks if the ClientState is in the established state.
func (*ClientState) IsInit ¶
func (cs *ClientState) IsInit() bool
IsInit checks if the ClientState is in the initialization state.
func (*ClientState) IsTerminated ¶
func (cs *ClientState) IsTerminated() bool
IsTerminated checks if the ClientState is in the terminated state.
func (*ClientState) String ¶
func (cs *ClientState) String() string
func (*ClientState) Terminate ¶
func (cs *ClientState) Terminate()
Terminate sets the ClientState into the termination state.
type ContactFlags ¶
type ContactFlags uint8
ContactFlags are single-bit flags used in the ContactHeader.
const ( // ContactCanTls indicates that the sending peer is capable of TLS security. ContactCanTls ContactFlags = 0x01 )
func (ContactFlags) String ¶
func (cf ContactFlags) String() string
type ContactHeader ¶
type ContactHeader struct {
Flags ContactFlags
}
ContactHeader will be exchanged at first after a TCP connection was established. Both entities are sending a ContactHeader and are validating the peer's one.
func NewContactHeader ¶
func NewContactHeader(flags ContactFlags) ContactHeader
NewContactHeader creates a new ContactHeader with given ContactFlags.
func (ContactHeader) String ¶
func (ch ContactHeader) String() string
type DataAcknowledgementMessage ¶
type DataAcknowledgementMessage struct { Flags SegmentFlags TransferId uint64 AckLen uint64 }
DataAcknowledgementMessage is the XFER_ACK message for data acknowledgements.
func NewDataAcknowledgementMessage ¶
func NewDataAcknowledgementMessage(flags SegmentFlags, tid, acklen uint64) DataAcknowledgementMessage
NewDataAcknowledgementMessage creates a new DataAcknowledgementMessage with given fields.
func (DataAcknowledgementMessage) Marshal ¶
func (dam DataAcknowledgementMessage) Marshal(w io.Writer) error
func (DataAcknowledgementMessage) String ¶
func (dam DataAcknowledgementMessage) String() string
type DataTransmissionMessage ¶
type DataTransmissionMessage struct { Flags SegmentFlags TransferId uint64 Data []byte }
DataTransmissionMessage is the XFER_SEGMENT message for data transmission.
func NewDataTransmissionMessage ¶
func NewDataTransmissionMessage(flags SegmentFlags, tid uint64, data []byte) DataTransmissionMessage
NewDataTransmissionMessage creates a new DataTransmissionMessage with given fields.
func (DataTransmissionMessage) Marshal ¶
func (dtm DataTransmissionMessage) Marshal(w io.Writer) error
func (DataTransmissionMessage) String ¶
func (dtm DataTransmissionMessage) String() string
type IncomingTransfer ¶
type IncomingTransfer struct { Id uint64 // contains filtered or unexported fields }
IncomingTransfer represents an incoming Bundle Transfer for the TCPCL.
func NewIncomingTransfer ¶
func NewIncomingTransfer(id uint64) *IncomingTransfer
NewIncomingTransfer creates a new IncomingTransfer for the given Transfer ID.
func (IncomingTransfer) IsFinished ¶
func (t IncomingTransfer) IsFinished() bool
IsFinished indicates if this Transfer is finished.
func (*IncomingTransfer) NextSegment ¶
func (t *IncomingTransfer) NextSegment(dtm DataTransmissionMessage) (dam DataAcknowledgementMessage, err error)
NextSegment reads data from a XFER_SEGMENT and retruns a XFER_ACK or an error.
func (IncomingTransfer) String ¶
func (t IncomingTransfer) String() string
type KeepaliveMessage ¶
type KeepaliveMessage struct{}
KeepaliveMessage is the KEEPALIVE message for session upkeep.
func NewKeepaliveMessage ¶
func NewKeepaliveMessage() KeepaliveMessage
NewKeepaliveMessage creates a new KeepaliveMessage.
func (KeepaliveMessage) String ¶
func (_ KeepaliveMessage) String() string
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener is a TCPCL server bound to a TCP port to accept incoming TCPCL connections. This type implements the cla.ConvergenceProvider and should be supervised by a cla.Manager.
func NewListener ¶
func NewListener(listenAddress string, endpointID bundle.EndpointID) *Listener
NewListener creates a new Listener which should be bound to the given address and advertises the endpoint ID as its own node identifier.
func (*Listener) RegisterManager ¶
type Message ¶
Message describes all kind of TCPCL messages, which have their serialization and deserialization in common.
func NewMessage ¶
NewMessage creates a new Message type for a given type code.
type MessageRejectionMessage ¶
type MessageRejectionMessage struct { ReasonCode MessageRejectionReason MessageHeader uint8 }
MessageRejectionMessage is the MSG_REJECT message for message rejection.
func NewMessageRejectionMessage ¶
func NewMessageRejectionMessage(reasonCode MessageRejectionReason, messageHeader uint8) MessageRejectionMessage
NewMessageRejectionMessage creates a new MessageRejectionMessage with given fields.
func (MessageRejectionMessage) Marshal ¶
func (mrm MessageRejectionMessage) Marshal(w io.Writer) error
func (MessageRejectionMessage) String ¶
func (mrm MessageRejectionMessage) String() string
type MessageRejectionReason ¶
type MessageRejectionReason uint8
MessageRejectionReason is the one-octet refusal code from a MessageRejectionMessage.
const ( // RejectionTypeUnknown indicates an unknown Message Type Code. RejectionTypeUnknown MessageRejectionReason = 0x01 // RejectionUnsupported indicates that this TCPCL node cannot comply with // the message content. RejectionUnsupported MessageRejectionReason = 0x02 // RejectionUnexptected indicates that this TCPCL node received a message // while the session is in a state in which the message is not expected. RejectionUnexptected MessageRejectionReason = 0x03 )
func (MessageRejectionReason) IsValid ¶
func (mrr MessageRejectionReason) IsValid() bool
IsValid checks if this MessageRejectionReason represents a valid value.
func (MessageRejectionReason) String ¶
func (mrr MessageRejectionReason) String() string
type OutgoingTransfer ¶
type OutgoingTransfer struct { Id uint64 // contains filtered or unexported fields }
OutgoingTransfer represents an outgoing Bundle Transfer for the TCPCL.
func NewBundleOutgoingTransfer ¶
func NewBundleOutgoingTransfer(id uint64, b bundle.Bundle) *OutgoingTransfer
NewBundleOutgoingTransfer creates a new OutgoingTransfer for a Bundle.
func NewOutgoingTransfer ¶
func NewOutgoingTransfer(id uint64) (t *OutgoingTransfer, w io.Writer)
NewOutgoingTransfer creates a new OutgoingTransfer for data written into the returned Writer.
func (*OutgoingTransfer) NextSegment ¶
func (t *OutgoingTransfer) NextSegment(mru uint64) (dtm DataTransmissionMessage, err error)
NextSegment creates the next XFER_SEGMENT for the given MRU or an EOF in case of a finished Writer.
func (OutgoingTransfer) String ¶
func (t OutgoingTransfer) String() string
type SegmentFlags ¶
type SegmentFlags uint8
SegmentFlags are an one-octet field of single-bit flags for a XFER_SEGMENT.
const ( // SegmentEnd indicates that this segment is the last of the transfer. SegmentEnd SegmentFlags = 0x01 // SegmentStart indicates that this segment is the first of the transfer. SegmentStart SegmentFlags = 0x02 )
func (SegmentFlags) String ¶
func (sf SegmentFlags) String() string
type SessionInitMessage ¶
type SessionInitMessage struct { KeepaliveInterval uint16 SegmentMru uint64 TransferMru uint64 Eid string }
SessionInitMessage is the SESS_INIT message to negotiate session parameters.
func NewSessionInitMessage ¶
func NewSessionInitMessage(keepaliveInterval uint16, segmentMru, transferMru uint64, eid string) SessionInitMessage
NewSessionInitMessage creates a new SessionInitMessage with given fields.
func (SessionInitMessage) String ¶
func (si SessionInitMessage) String() string
type SessionTerminationCode ¶
type SessionTerminationCode uint8
SessionTerminationCode is the one-octet refusal reason code for a SESS_TERM message.
const ( // TerminationUnknown indicates an unknown or not specified reason. TerminationUnknown SessionTerminationCode = 0x00 // TerminationIdleTimeout indicates a session being closed due to idleness. TerminationIdleTimeout SessionTerminationCode = 0x01 // TerminationVersionMismatch indicates that the node cannot conform to the // specified TCPCL protocol version number. TerminationVersionMismatch SessionTerminationCode = 0x02 // TerminationBusy indicates a too busy node. TerminationBusy SessionTerminationCode = 0x03 // TerminationContactFailure indicates that the node cannot interpret or // negotiate contact header options. TerminationContactFailure SessionTerminationCode = 0x04 // TerminationResourceExhaustion indicates that the node has run into some // resource limit. TerminationResourceExhaustion SessionTerminationCode = 0x05 )
func (SessionTerminationCode) IsValid ¶
func (stc SessionTerminationCode) IsValid() bool
IsValid checks if this SessionTerminationCode represents a valid value.
func (SessionTerminationCode) String ¶
func (stc SessionTerminationCode) String() string
type SessionTerminationFlags ¶
type SessionTerminationFlags uint8
SessionTerminationFlags are single-bit flags used in the SessionTerminationMessage.
const ( // TerminationReply indicates that this message is an acknowledgement of an // earlier SESS_TERM message. TerminationReply SessionTerminationFlags = 0x01 )
func (SessionTerminationFlags) String ¶
func (stf SessionTerminationFlags) String() string
type SessionTerminationMessage ¶
type SessionTerminationMessage struct { Flags SessionTerminationFlags ReasonCode SessionTerminationCode }
SessionTerminationMessage is the SESS_TERM message for session termination.
func NewSessionTerminationMessage ¶
func NewSessionTerminationMessage(flags SessionTerminationFlags, reason SessionTerminationCode) SessionTerminationMessage
NewSessionTerminationMessage creates a new SessionTerminationMessage with given fields.
func (SessionTerminationMessage) Marshal ¶
func (stm SessionTerminationMessage) Marshal(w io.Writer) error
func (SessionTerminationMessage) String ¶
func (stm SessionTerminationMessage) String() string
type TransferRefusalCode ¶
type TransferRefusalCode uint8
TransferRefusalCode is the one-octet refusal reason code for a XFER_REFUSE message.
const ( // RefusalUnknown indicates an unknown or not specified reason. RefusalUnknown TransferRefusalCode = 0x00 // RefusalExtensionFailure indicates a failure processing the Transfer Extension Items. RefusalExtensionFailure TransferRefusalCode = 0x01 // RefusalCompleted indicates that the receiver already has the complete bundle. RefusalCompleted TransferRefusalCode = 0x02 // RefusalNoResources indicate that the receiver's resources are exhausted. RefusalNoResources TransferRefusalCode = 0x03 // RefusalRetransmit indicates a problem on the receiver's side. This requires // the complete bundle to be retransmitted. RefusalRetransmit TransferRefusalCode = 0x04 )
func (TransferRefusalCode) IsValid ¶
func (trc TransferRefusalCode) IsValid() bool
IsValid checks if this TransferRefusalCode represents a valid value.
func (TransferRefusalCode) String ¶
func (trc TransferRefusalCode) String() string
type TransferRefusalMessage ¶
type TransferRefusalMessage struct { ReasonCode TransferRefusalCode TransferId uint64 }
TransferRefusalMessage is the XFER_REFUSE message for transfer refusals.
func NewTransferRefusalMessage ¶
func NewTransferRefusalMessage(reason TransferRefusalCode, tid uint64) TransferRefusalMessage
NewTransferRefusalMessage creates a new TransferRefusalMessage with given fields.
func (TransferRefusalMessage) Marshal ¶
func (trm TransferRefusalMessage) Marshal(w io.Writer) error
func (TransferRefusalMessage) String ¶
func (trm TransferRefusalMessage) String() string
Source Files ¶
- 0doc.go
- client.go
- client_contact.go
- client_established.go
- client_handler.go
- client_init.go
- client_state.go
- contact_header.go
- listener.go
- message.go
- message_keepalive.go
- message_reject.go
- message_sess_init.go
- message_sess_term.go
- message_xfer_ack.go
- message_xfer_refuse.go
- message_xfer_segment.go
- transfer_in.go
- transfer_out.go