Upload
millicent-collins
View
217
Download
0
Tags:
Embed Size (px)
Citation preview
Advanced Network Advanced Network ProgrammingProgramming
Chapter 1Chapter 1
Introduction
to
Transport Layer and TCP
October, 2001 A. Özgit - Advanced Network Programming 2
Networking (OSI) Reference Networking (OSI) Reference ModelModel
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)
October, 2001 A. Özgit - Advanced Network Programming 3
NetworkingNetworking
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
October, 2001 A. Özgit - Advanced Network Programming 4
Transport Layer (Layer-4)Transport 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.
October, 2001 A. Özgit - Advanced Network Programming 5
Transport Layer (Layer-4)Transport 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 IBM’s SNA, and Digital’s (Compaq) DECnet. Connection to proprietary protocol suites.
Ongoing research tcp-impl WG of IETF (www.ietf.org) end2end WG of IRTF (www.irtf.org)
October, 2001 A. Özgit - Advanced Network Programming 6
Transport Layer (Layer-4)Transport 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
October, 2001 A. Özgit - Advanced Network Programming 7
Role of TCPRole 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.
October, 2001 A. Özgit - Advanced Network Programming 8
Role of TCPRole of TCP
Web browser (client) Access TCP’s service thru function calls that
comprise that Transport Layer’s 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()
October, 2001 A. Özgit - Advanced Network Programming 9
TerminologyTerminology
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.
October, 2001 A. Özgit - Advanced Network Programming 10
TerminologyTerminology
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.
October, 2001 A. Özgit - Advanced Network Programming 11
TerminologyTerminology
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
October, 2001 A. Özgit - Advanced Network Programming 12
Terminology Terminology
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)
TCP’s TPDU TCP segment Packet IP datagram (NPDU) or TCP segment
(informally)
IP’s PDU Datagram Datagram IP’s NPDU or UDP’s TPDU
(informally)
October, 2001 A. Özgit - Advanced Network Programming 13
Example TCP Connection (1)Example 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”
October, 2001 A. Özgit - Advanced Network Programming 14
Example TCP Connection (2)Example 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
October, 2001 A. Özgit - Advanced Network Programming 15
Example TCP Connection (3)Example 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
October, 2001 A. Özgit - Advanced Network Programming 16
Example TCP Connection (4)Example 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
October, 2001 A. Özgit - Advanced Network Programming 17
Example TCP Connection (5)Example 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.
October, 2001 A. Özgit - Advanced Network Programming 18
Example TCP Connection (6)Example 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.
October, 2001 A. Özgit - Advanced Network Programming 19
Example TCP Connection (7)Example 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.
October, 2001 A. Özgit - Advanced Network Programming 20
Example TCP Connection (8)Example 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.
October, 2001 A. Özgit - Advanced Network Programming 21
Transport ServiceTransport 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).
October, 2001 A. Özgit - Advanced Network Programming 22
CO-message vs. CO-byte vs. CO-message vs. CO-byte vs. CLCL
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.
October, 2001 A. Özgit - Advanced Network Programming 23
ReliabilityReliability
A service is reliable if and only if it satisfies all of the following: No-loss No-duplicates Ordered Data Integrity
October, 2001 A. Özgit - Advanced Network Programming 24
No-loss vs. Uncontrolled-loss No-loss vs. Uncontrolled-loss vs. Controlled-lossvs. 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
October, 2001 A. Özgit - Advanced Network Programming 25
No-duplicates vs. Maybe-No-duplicates vs. Maybe-duplicatesduplicates
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
October, 2001 A. Özgit - Advanced Network Programming 26
Ordered vs. Unordered vs. Ordered vs. Unordered vs. Partially-orderedPartially-ordered
Ordered service Preserves user sender’s 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.
October, 2001 A. Özgit - Advanced Network Programming 27
Data-integrity vs. No-data-Data-integrity vs. No-data-integrity vs. Partial-data-integrity vs. Partial-data-
integrityintegrity 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
October, 2001 A. Özgit - Advanced Network Programming 28
Remarks on Reliability and CO Remarks on Reliability and CO vs. CLvs. 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?
October, 2001 A. Özgit - Advanced Network Programming 29
Remarks on Reliability and CO Remarks on Reliability and CO vs. CLvs. 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 ?
October, 2001 A. Özgit - Advanced Network Programming 30
Remarks on Reliability and CO Remarks on Reliability and CO vs. CLvs. CL
Whereas: UDP service is CL and UDP service is unreliable,
CL service Unreliable Service ?
October, 2001 A. Özgit - Advanced Network Programming 31
Blocking vs. Non-blockingBlocking 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 sender’s OK.
October, 2001 A. Özgit - Advanced Network Programming 32
Multicast vs. UnicastMulticast 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.
October, 2001 A. Özgit - Advanced Network Programming 33
Priority vs. No-priorityPriority 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.
October, 2001 A. Özgit - Advanced Network Programming 34
Security vs. No-securitySecurity 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 sender’s and user receiver’s identity.
Access control checks a user’s permission status, allowing the use of different resources.
Confidentiality guarantees that only the intended user receiver(s) can decode and understand the user sender’s data.
Integrity detects any modification, insertion, deletion, or replay of transport sender’s data.
e.g., TP4
No-security service Does not provide any of the above security
functions.
October, 2001 A. Özgit - Advanced Network Programming 35
Status-reportingStatus-reporting vs. vs. Non-status-Non-status-reportingreporting
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.
October, 2001 A. Özgit - Advanced Network Programming 36
QQooS S vs. vs. No-QNo-QooSS
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.
October, 2001 A. Özgit - Advanced Network Programming 37
QQooS S Parameters (ISO)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
October, 2001 A. Özgit - Advanced Network Programming 38
QQooS S Parameters (ISO)Parameters (ISO)
Protection
Priority
Resilience
The ATM environment supports only two QoS parameters: (sustained) target, acceptable, and minimum
throughput Transit delay
October, 2001 A. Özgit - Advanced Network Programming 39
Transport Protocol FeaturesTransport 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
October, 2001 A. Özgit - Advanced Network Programming 40
Transport Protocol FeaturesTransport 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
October, 2001 A. Özgit - Advanced Network Programming 41
Transport Protocol FeaturesTransport 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
October, 2001 A. Özgit - Advanced Network Programming 42
Transport Protocol FeaturesTransport 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)
October, 2001 A. Özgit - Advanced Network Programming 43
Transport Protocol FeaturesTransport 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
October, 2001 A. Özgit - Advanced Network Programming 44
Error ControlError 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
October, 2001 A. Özgit - Advanced Network Programming 45
Error ControlError 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
October, 2001 A. Özgit - Advanced Network Programming 46
Error ControlError 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.
October, 2001 A. Özgit - Advanced Network Programming 47
Error ControlError 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
October, 2001 A. Özgit - Advanced Network Programming 48
Error ControlError Control
Error Reporting and Recovery A negative ACK (NACK) aka Selective Reject
Explicitly identifies TPDUs that have not been received
October, 2001 A. Özgit - Advanced Network Programming 49
Error ControlError 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.
October, 2001 A. Özgit - Advanced Network Programming 50
Error ControlError 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.
October, 2001 A. Özgit - Advanced Network Programming 51
Error ControlError 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.
October, 2001 A. Özgit - Advanced Network Programming 52
Flow ControlFlow Control
October, 2001 A. Özgit - Advanced Network Programming 53
Multiplexing/DemultiplexingMultiplexing/Demultiplexing
See Figure 5(a)
Several transport layer connections using a single network layer association.
Efficient use of network layer resources.
October, 2001 A. Özgit - Advanced Network Programming 54
TCP TCP (Transmission Control (Transmission Control Protocol)Protocol)
Connection-oriented (CO)