qmsk/net/transport/__init__.py
changeset 26 d8a71a675862
parent 24 f18b5787c46c
child 28 020c89baaa33
equal deleted inserted replaced
25:e60de189099d 26:d8a71a675862
     1 """
     1 """
     2     Transport-layer functionality.
     2     Transport-layer functionality.
     3 
     3 
     4     This implements TCP/UDP/SCTP functionality, plus relevant Transport-Application layer stuff like TLS, SOCKS, SSH-channels, etc.
     4     This implements TCP/UDP/SCTP functionality, plus relevant Transport-Application layer stuff like TLS, SOCKS, SSH-channels, etc.
       
     5 
       
     6     Firstly, this defines a set of abstract interfaces that model the actual implementation as built on top of the
       
     7     socket packages's network-layer implementation:
       
     8 
       
     9 
       
    10     Interfaces:
       
    11 
       
    12         Transport           - very abstract interface that embodies the notion of sending something somewhere
       
    13 
       
    14             ConnectedTransport      - connection-oriented transport
       
    15             
       
    16                 Stream                  - connection-oriented full-duplex byte stream (reliable, sequenced)
       
    17     
       
    18                 PacketStream            - connection-oriented full-duplex packet-oriented communication
       
    19  
       
    20 
       
    21             UnconnectedTransport    - non-connection-oriented transport dealing with packets
       
    22 
       
    23                 Peer                    - connectionless packet-oriented communication
       
    24 
       
    25 
       
    26         Endpoint        - some transport-level endpoint (local/remote address/socket)
       
    27 
       
    28             Client          - connection-oriented endpoint that can establish a Transport to some remote Service
       
    29 
       
    30             Service         - listening endpoint that recieves connections from remote Clients and represents those as Transports
       
    31 
       
    32 
       
    33     Next, there are some mid-level helpers, mostly for dealing with 
       
    34 
       
    35 
       
    36     Then there is are implementations of these interfaces for specific protocols, layering on top of the socket module,
       
    37     or other application-level protocols.
       
    38 
       
    39     TCP:
       
    40         TCP implementation using a SOCK_STREAM socket.
       
    41 
       
    42         Stream          - connected TCP socket with TCP's byte stream semantics
       
    43 
       
    44         Service         - TCP socket accept()'ing Streams from remote Clients
       
    45 
       
    46         Client          - TCP socket connect()'ing to a remote Service
       
    47 
       
    48 
       
    49     UDP:
       
    50         UDP implementation using a SOCK_DGRAM socket.
       
    51 
       
    52         Peer            - bind()'d UDP socket without any connection
       
    53 
       
    54         Client          - connect()'d UDP socket, representing a PacketStream
       
    55 
       
    56 
       
    57     UNIX:
       
    58         UNIX socket implementation support both SOCK_STREAM and SOCK_DGRAM.
       
    59 
       
    60         XXX: verify that this is correct...
       
    61 
       
    62         Stream          - connected AF_UNIX SOCK_STREAM
       
    63 
       
    64         Service         - accept()'ing AF_UNIX socket of either SOCK_STREAM mode
       
    65 
       
    66         Client          - connect()'ing AF_UNIX socket of SOCK_STREAM mode
       
    67 
       
    68         Peer            - bind()'d AF_UNIX socket of SOCK_DGRAM mode
       
    69 
       
    70     SCTP:
       
    71         SCTP implementation offering both SOCK_SEQPACKET and SOCK_STREAM -based socket interfaces.
       
    72 
       
    73         Stream          - a PacketStream carried by an Association
       
    74 
       
    75         Association     - a Transport that represents a SCTP association between a local and remote Endpoint
       
    76 
       
    77         Peer            - one-to-many style interface, with a single Peer holding multiple Associations
       
    78 
       
    79         Service         - a one-to-one style listen()'ing interface which accepts Associations from remote Endpoints
       
    80 
       
    81         Client          - a one-to-one style connect()'ing interface which establishes Associations with remote Endpoints
       
    82 
       
    83     SSL:
       
    84         SSL implementation using either OpenSSL or gnutls.
       
    85 
       
    86         Stream          - tcp.Stream carrying an encrypted byte stream
       
    87 
       
    88         Service         - tcp.Service accepting connections from SSL endpoints
       
    89 
       
    90         Client          - tcp.Client connecting to an SSL service
       
    91 
       
    92     SOCKS:
       
    93         SOCKSv5 client implementing TCP client serviecs.
       
    94 
       
    95         Stream          - tcp.Stream carried over a SOCKSv5 connections
       
    96 
       
    97         Client          - tcp.Client connecting via a SOCKSv5 server
       
    98         
     5 """
    99 """