Title: Advanced Network Programming Chapter 1
1Advanced Network ProgrammingChapter 1
- Introduction
- to
- Transport Layer and TCP
2Networking (OSI) Reference Model
- OSI 7-layer Reference Model
- Application (WEB, NFS, FTP, Telnet, etc.)
- Presentation (Conversion, Compression,
Cryptography) - Session (Synchronization)
- Transport (End-to-end Messages)
- Network (Packet Routing)
- Data Link (Station-to-station Frames)
- Physical (Bit Transmission)
3Networking
- Distinction between service and protocol is
important! - This will be discussed later.
- Some widely known transport protocols
- UDP, TP0, TP4, SNA-APPN, DECnet-NSP, ATM, XTP,
T/TCP, RTP, VMTP, NETBLT
4Transport Layer (Layer-4)
- Lowest layer that operates on an end-to-end
basis. - Lies at the boundary between hosts and an
internetwork of routers, bridges, and
communication links. - A good transport layer service
- Allows applications to use a standard set of
primitives. - Run on variety of networks w/o worrying about
different network interfaces and reliabilities. - Isolates applications from the technology.
5Transport Layer (Layer-4)
- Layer-4 provides interprocess communication
between two processes that most often are running
on different hosts. - TCP and its companion UDP (User Datagram
Protocol) are the most widely used protocols. - Other are from IBMs SNA, and Digitals (Compaq)
DECnet. - Connection to proprietary protocol suites.
- Ongoing research
- tcp-impl WG of IETF (www.ietf.org)
- end2end WG of IRTF (www.irtf.org)
6Transport Layer (Layer-4)
- Basic Issues
- Addressing
- Connection-oriented (CO) vs. Connectionless (CL)
- Reliability
- Loss
- Duplicate
- Ordering
- Integrity
- Blocking vs. Non-Blocking
- Multicast, Unicast
- Priority
- Security
- Status Reporting
7Role of TCP
- The Web
- An example of client/server application
- Web browser (client)
- Runs on local machine
- Communicates with a server on some remote
machine - Uses an application layer protocol called the
HTTP (Hypertext Transfer Protocol). - HTTP is a simple request/response protocol.
- We will use HTTP 0.9 (the simplest) in examples.
8Role of TCP
- Web browser (client)
- Access TCPs service thru function calls that
comprise that Transport Layers Application
-Programming Interface (API). - API provides
- (at a minimum) functions to send and receive
messages - e.g. Berkeley Sockets read(), write()
- Connection setup and close for CO protocols
- e.g. connect(), close()
9Terminology
- Simplified Communication Model (OSI) Figure-1
- User Sender / User Receiver at the top
- Application Entities use the services of the
transport layer - Peer Entities exchange Protocol Data Units (PDUs)
- APDU
- The request get /index.html
- sent from client (application entity) to the
server (its peer application entity). - Bi-directional Protocol
- Both sides can send and receive data
simultaneously.
10Terminology
- Transport Entity
- Hardware and/or software within a given host that
implements a particular transport service and
protocol. - User Sender
- submits a chunk of user data (Transport Service
Data Unit TSDU informally a message) to the
transport sender. - Transport Sender
- transmits or sends this data to the transport
receiver over a network which may provide
different levels of reliability.
11Terminology
- Transport Receiver
- receives the data that arrives from the network
and delivers it to the user receiver. - TPDUs may flow in both directions even when user
data flows only from sender to receiver - Control TPDUs
- Separate and/or Piggybacked
12Terminology
- What happens to the request APDU?
- APDU becoming a single TSDU, being encapsulated
in a single TPDU, which in turn becomes a single
NSDU, which is encapsulated in a single NPDU
(Figure-2) - TCPs TPDU ? TCP segment
- Packet ? IP datagram (NPDU) or TCP segment
(informally) - IPs PDU ? Datagram
- Datagram ? IPs NPDU or UDPs TPDU (informally)
13Example TCP Connection (1)
- Enter http//ozgit.nom.tr/index.html from web
client. - http indicates application layer protocol to be
used. - TCP port number 80 (implicitly) to be used.
- ozgit.nom.tr is the host name (mapped to an IP
number 144.122.71.91- by DNS) - Transport Service Access Point (TSAP)
- TSAP ? IP Address TCP Port Number
- One end point of a communication channel between
a process on a local m/c and a process on a
remote m/c. - index.html is the file being requested.
- http request (APDU) ? GET /index.html
14Example TCP Connection (2)
- Connection request to the transport entity at
(144.122.71.91, 80). - By calling connect()
- Local TCP initiates a 3-way handshake with the
remote server. - TPDUs are exchanged between TCP entities to
ensure reliable connection establishment and to
establish initial sequence numbers. - If 3-way handshake fails, TCP notifies the
application. - Otherwise success code is returned -confirmation.
- OSI Model
- Request Indication
- Response - Confirmation
15Example TCP Connection (3)
- Web client submits a request to send data (APDU
GET /index.html) - Local TCP sends this data most likely in a single
TPDU. - TCP Segment ? TSDU Transport Layer Header
16Example TCP Connection (4)
- Remote TCP receives the TPDU, the data (APDU
GET /index.html) is buffered. - Delivered when Web server does a read()
- This delivery is known as a data indication in
OSI terminology. - Remote TCP also sends back an acknowledgement
(ACK) -control TPDU- to the local TCP
17Example TCP Connection (5)
- The Web server responds with contents of
index.html. - File may be too large to be efficiently submitted
to TCP in one write() call i.e., one TSDU. - Web Server divides APDU into multiple write()
calls i.e., multiple TSDUs. - Remote TCP then sends these TSDUs to local the
TCP in multiple TPDUs. - TCP treats the data as a byte stream and segments
it as necessary i.e., does not care about TSDU
boundaries. - Boundaries between APDUs, submitted TSDUs, TPDUs,
and delivered TSDUs may all be different.
18Example TCP Connection (6)
- TCP must detect and recover from network errors.
- As the remote TCP send the TPDUs, it includes a
sequence number in each TPDU. - It also copies each TPDU into a buffer, and sets
a timer. - Retransmits the TPDU if timer expires before
getting an ACK. - Retransmission is done in a new TPDU.
- Individual byte-stream sequence numbers are used.
- TPDUs retransmitted may or may not correspond
exactly to the original TPDUs. - Remote TCP also places a checksum is the TPDU
header to detect bit errors.
19Example TCP Connection (7)
- As TPDUs are received by the local TCP
- TPDUs with checksum errors are discarded.
- It ensures that no pieces of the byte-stream are
missing - Out-of-order arrivals are reordered.
- It responds to the remote TCP with ACK TPDUs.
- Duplicates are discarded (e.g., as a consequence
of lost ACK TPDUs). - Pieces of byte-stream are buffered in local TCP
- Web client requests them by doing read() calls.
- Each read() results in delivery of a TSDU.
20Example TCP Connection (8)
- TCP connection is bi-directional.
- Either side may initiate the closing of the
connection - In first generation web systems the server
initiates the close by calling close() function
(Disconnect Request). - Disconnect is handled with a 4-way handshake
procedure.
21Transport Service
- A transport service abstracts a set of functions
that is provided to a higher layer. - A protocol, refers to the details of how a
transport sender and a transport receiver
cooperate to provide that service. - Distinction between service and protocol is
important (Contribution of OSI Reference Model).
22CO-message vs. CO-byte vs. CL
- Two types of transport services
- Connection-oriented (CO)
- Provides for the establishment, maintenance, and
termination of a logical connection between
transport users (three distinct phases of
operation). - Connection Establishment (T-Connect)
- Data Transfer (T-Data)
- Connection Termination (T-Disconnect)
- CO service has two variations
- Message-oriented (TP4)
- Byte-stream
- Connectionless (CL)
- Provides only one phase of operation data
transfer.
23Reliability
- A service is reliable if and only if it satisfies
all of the following - No-loss
- No-duplicates
- Ordered
- Data Integrity
24No-loss vs. Uncontrolled-loss vs. Controlled-loss
- No-loss (at-least-once delivery) service
guarantees either of the two results - The data is delivered to the user receiver, or
- The user sender is notified that some data may
not have been delivered. - Uncontrolled-loss (best-effort)
- No assurance
- Example UDP
- Controlled-loss
- Loss may occur, but there is control over the
degree of loss. - Example k-XP
25No-duplicates vs. Maybe-duplicates
- No-duplicates
- At-most-once delivery
- e.g., TCP
- Maybe-duplicates
- Efforts by the protocol may or may not be made to
avoid delivering duplicates. - e.g., UDP
26Ordered vs. Unordered vs. Partially-ordered
- Ordered service
- Preserves user senders submission order of data.
- e.g., TCP
- Unordered service
- Does not provide the above guarantee.
- e.g., UDP
- Partially-ordered service
- Guarantees to deliver pieces of data in one of a
set of permitted orders as predefined by a
partial order relation agreed upon by the user
sender and user receiver. - e.g., Multimedia comm., distributed databases.
27Data-integrity vs. No-data-integrity vs.
Partial-data-integrity
- Data-integrity
- Ensures with high probability that all data bits
delivered to a user receiver are identical to
those originally submitted. - Strength of the error detection method.
- TCP uses 16-bit checksum.
- No-data-integrity
- Provide no guarantees regarding bit errors.
- Partial-data-integrity
- A controlled amount of bit errors (as a means of
achieving higher throughput). - e.g., real-time multimedia application
28Remarks on Reliability and CO vs. CL
- All aspects of reliability (loss, duplicates,
order, data-integrity) are orthogonal. - Data might get lost while the order is preserved.
- Relationship between a service being CO or CL and
whether or not it is reliable. - These two services are orthogonal.
- CO service is assumed to be reliable. Why?
29Remarks on Reliability and CO vs. CL
- Whereas TCP service is CO and TCP service is
reliable, - Whereas TP4 service is CO and TP4 service is
reliable, - Whereas X.25 service is CO and X.25 service is
reliable - CO service ? Reliable Service ?
30Remarks on Reliability and CO vs. CL
- Whereas UDP service is CL and UDP service is
unreliable, - CL service ? Unreliable Service ?
31Blocking vs. Non-blocking
- Blocking service
- Ensures that the transport layer is not
overwhelmed with incoming data. - Provides flow control between user sender and
transport sender. - Non-blocking service
- Allows the user sender to submit data and
continue processing w/o awaiting the transport
senders OK.
32Multicast vs. Unicast
- Multicast service
- Enables a user sender to submit data, a copy of
which will be delivered to one or more user
receiver(s). - Unicast service
- Delivery of data to exactly one user receiver.
33Priority vs. No-priority
- Priority service
- Enables a user sender to indicate the relative
importance of various messages. - May be combined with uncontrolled-loss or
controlled-loss service to drop lower priority
data, thereby allowing the delivery of
high-priority data with smaller delay and/or
higher probability. - No-priority service
- No differentiation of the importance of the
classes of data.
34Security vs. No-security
- Security service
- A security service provides one or more security
functions such as authentication, access control,
confidentiality, and integrity ISO-7498-2. - Authentication is the verification of user
senders and user receivers identity. - Access control checks a users permission status,
allowing the use of different resources. - Confidentiality guarantees that only the intended
user receiver(s) can decode and understand the
user senders data. - Integrity detects any modification, insertion,
deletion, or replay of transport senders data. - e.g., TP4
- No-security service
- Does not provide any of the above security
functions.
35Status-reporting vs. Non-status-reporting
- Status-reporting service
- Allows a user sender to obtain specific
information about the transport entity or its
connections. - Non-status reporting service
- Does not provide any information about the
transport entity and its connections.
36QoS vs. No-QoS
- QoS service
- Allows a user sender to specify the quality of
transmission service desired. - No-QoS service
- Delivery of data to exactly one user receiver.
37QoS Parameters (ISO)
- Connection Establishment Delay
- Connection Establishment Failure Probability
- Throughput
- Transit Delay
- Residual Error Rate
- Transfer Failure Probability
- Connection Release Delay
- Connection Release Failure Probability
38QoS Parameters (ISO)
- Protection
- Priority
- Resilience
- The ATM environment supports only two QoS
parameters - (sustained) target, acceptable, and minimum
throughput - Transit delay
39Transport Protocol Features
- CO vs. CL
- Establishment and maintenance of state
information - A record of characteristics and events related to
the communication between the transport sender
and receiver. - CO state information is maintained
- Three phases
- Connection Establishment
- Data Transfer
- Connection Termination
- CL no state information is maintained
40Transport Protocol Features
- Transaction Oriented
- A single APDU (request) is sent by user sender
- User receiver responds with a single APDU
(response) - Characteristics
- Asymmetrical model
- Simplex data transfer
- Short duration
- Low delay
- Few data TPDUs
- Message orientation
- Need for a no-duplicate service
41Transport Protocol Features
- CO Protocol Features
- Signaling exchange of control (state)
information - In-band (more suitable for short-lived
connections) - Out-of-band (desirable for high-speed
communication systems) - Unidirectional vs. Bidirectional
42Transport Protocol Features
- Connection Establishment (See Figure-3)
- Implicit connect
- Connection is established as soon as the first
TPDU is sent or received. - 2-way-handshake connect
- CR-TPDU (Connection Request)
- CC-TPDU (Connection Confirm)
- 3-way-handshake connect
- CR-TPDU (Connection Request)
- CC-TPDU (Connection Confirm)
- ACK-CC-TPDU (ACK for Connection Confirm)
43Transport Protocol Features
- Connection Termination (See Figure-4)
- Implicit disconnect
- Time-out
- Abortive disconnect
- Close connection abnormally due to an error
condition - 2-way-handshake disconnect
- DR-TPDU (Disconnect Request)
- DC-TPDU (Disconnect Confirm)
- 4(3)-way-handshake disconnect
- Two 2-way-handshakes one for each direction of
data flow - 3-way if the first DC-TPDU also functions as a
DR-TPDU for the reverse direction
44Error Control
- Guard against loss or damage of user data and
control information - For realistic high-speed networks with low error
rates, transport layer error control is more
efficient than link layer error control. - Two phases
- Error detection
- Error reporting and recovery
45Error Control
- Error Detection
- Identifies lost, misordered, duplicated and
corrupted TPDUs - Sequence numbers handles the first three problems
- Corrupted data is discovered by means of
- Length fields
- Error Detecting Codes (EDC)
- The header/trailer, the data, or the both
- Separate EDCs are recommended for multimedia
applications
46Error Control
- Error Reporting and Recovery
- Error reporting is a mechanism where receiver
explicitly informs the sender about errors that
have been detected. - Error recovery is a mechanism used by both sender
and receiver to recover from errors whether or
not they are explicitly reported. - Timers, sequence numbers and acknowledgements are
used.
47Error Control
- Error Reporting and Recovery
- A positive ACK (PACK)
- PAR (Positive ACK with Retransmission) or ARQ
(Automatic Repeat Request) - Upon receipt of an ACK, the sender updates its
state information, discards buffered TPDUs that
are acknowledged, and retransmits any TPDUs that
are not acknowledged. - In case of timeout, it may assume something has
gone wrong and retransmits unacknowledged
TPDU(s). - No error reporting mechanism
48Error Control
- Error Reporting and Recovery
- A negative ACK (NACK) aka Selective Reject
- Explicitly identifies TPDUs that have not been
received
49Error Control
- Piggybacking
- Artificially delay returning an ACK hoping the
receiver will soon submit its next message to be
sent as a part of the reverse direction data
flow. - When this occurs, the ACK is piggyback-ed as
header information on the reverse direction data
TPDU.
50Error Control
- Cumulative vs. Selective Acknowledgement
- Cumulative PACK
- Carries a sequence number indicating that all
TPDUs with lower sequence numbers have been
received. - A recent cumulative PACK incorporates the
information of the previously lost one. - Unnecessary retransmissions of correctly received
TPDUs. - Selective PACK
- Acknowledges exactly one TPDU
- Block PACK
- Variation of selective PACK where blocks of
individual TPDUs are selectively acknowledged.
51Error Control
- Retransmission Strategies
- When the sender does not receive a PACK within a
pre-determined timeout period, or when it
receives back-to-back cumulative PACKs that are
identical. - Selective Repeat (Conservative)
- Sender retransmits selectively only TPDUi and
wait for a PACK with sequence number larger than
previous PACKs. - Go-Back-N (More Aggressive)
- Sender retransmits TPDUi and all TPDUs already
sent after TPDUi - Decrease channel utilization by potentially
retransmitting correctly-received TPDUs.
52Flow Control
53Multiplexing/Demultiplexing
- See Figure 5(a)
- Several transport layer connections using a
single network layer association. - Efficient use of network layer resources.
54TCP (Transmission Control Protocol)