Transport Control Protocol - PowerPoint PPT Presentation

About This Presentation
Title:

Transport Control Protocol

Description:

Transport Control Protocol TCP Connection-Oriented Service Connection-oriented service has a handshake period During this time, a logical connection is made with the ... – PowerPoint PPT presentation

Number of Views:97
Avg rating:3.0/5.0
Slides: 33
Provided by: ran88
Category:

less

Transcript and Presenter's Notes

Title: Transport Control Protocol


1
Transport Control Protocol
  • TCP

2
Connection-Oriented Service
  • Connection-oriented service has a handshake
    period
  • During this time, a logical connection is made
    with the destination node
  • The connection is logical, since all packets
    are forwarded individually, just like with UDP
  • Typically, connection-oriented service provides
    reliability, meaning
  • Acknowledgements are used to ensure packets
    arrive
  • Checksums/CRCs are used to ensure data integrity

3
Transport Control Protocol (TCP)
  • Like X.25, TCP provides connection-oriented
    delivery at a high level layer
  • X.25 provides it at the Transport OSI layer
  • TCP provides it at the Transport IP layer
  • Providing connection-oriented delivery at a high
    level allows TCP to be applied to any network
  • Thus the ability to use TCP/IP over Ethernet,
    Token Ring, etc.
  • However, providing connection-orientation at a
    high level means that the network is not
    necessarily optimized for connection-oriented
    delivery
  • For example, Ethernet is optimized for
    connectionless delivery

4
TCP
  • The essence of TCP is to provide an apparently
    continuous stream of data
  • Thus, above the transport layer
  • Data is not fragmented (into packets)
  • Data is in order
  • Lost packets do not occur
  • Thus, the transport layer (and layers below it)
    must handle
  • Segmentation and reassembly (SAR)
  • Acknowledgements

5
Segmentation vs. Fragmentation
  • Segmentation is basically the same as
    fragmentation, with a few differences
  • Fragmentation (IP layer)
  • only occurs when transmitting a packet whose
    size is larger than the MTU of the destination
    network
  • Any router (connecting two different network
    types) could theoretically fragment packets
  • Fragmentation can almost be considered an
    emergency practice (what to do when something
    goes wrong)
  • Segmentation (TCP layer)
  • Occurs for all data streams, to divide the data
    into packets (above TCP layer data is continuous)
  • Only the source host will segment packets
  • Segmentation is a normal part of TCPs job

6
TCP
  • TCP is a reliable protocol
  • All data sent through TCP is automatically
    divided into packets
  • Each of these packets is ensured to be sent by
    requiring the destination acknowledge the packets
    when they are received
  • The destination, knowing it will eventually
    receive all messages, only has to reorder those
    messages into an apparently continuous stream of
    data flow

7
TCP Stream Delivery Protocol
  • TCP abstracts data communication to appear as an
    apparent stream of flowing data
  • The source sends data as a stream into the
    network
  • The destination node receives data from the
    network in an identical form
  • The data arrives in the same order as it was sent
  • All data sent, arrives (in its proper position)
  • This is known as stream orientation, a format
    where the data is oriented in such a way as to
    appear as a direct stream from source to
    destination
  • In reality, however, the data is sent as packets
    (using IP datagrams, for example)

8
TCP Stream Delivery Protocol
  • TCP is normally achieved by using buffering
  • Data is collected from the stream (and stored
    into memory), until a certain amount has been
    obtained
  • This data is packaged into one or more network
    packets (e.g. IP datagrams) and sent to the
    destination using connectionless delivery
  • The destination should send an acknowledgement
    back to the source
  • If this acknowledgement fails to arrive after a
    specified length of time, the source will
    retransmit the packet
  • The destination node buffers the incoming packets
    into memory, where they can be read (byte by byte)

9
TCP Stream Delivery Protocol
  • The TCP/IP service layers do not contain a
    Presentation layer
  • For this reason, both UDP and TCP require that
    the applications recognize their own data formats
  • For example, using TCP to connect and send an
    E-Mail message can be achieved using the existing
    data format (or language) known as SMTP (Simple
    Mail Transfer Protocol)
  • Using TCP to connect and request WWW pages can be
    achieved using HTTP (HyperText Transfer Protocol)
  • These protocols are implemented (generated and
    recognized) inside the applications themselves

10
TCP Stream Delivery Protocol
  • Since TCP is actually implemented using packets
    (e.g. IP datagrams), it was possible for TCP to
    ensure bi-directional communication across its
    connections
  • Transfer across TCP streams is full duplex

11
Connection Establishment
  • TCP uses a three-way handshake to establish a
    connection
  • This means 3 messages are exchanged before a
    connection exists
  • The first message (SYN), sent by the machine
    issuing the active open request (A), is a
    request for connection to the destination (B)
  • The second message (SYN/ACK), both an
    acknowledgement of the first message as well as a
    request for connection to A, is sent by B
  • The third message (ACK) is an acknowledgement to
    B (from A) for the second message

12
TCP Handshake
SYN
Connection Establishment (Handshake)
SYN/ACK
ACK
Transmission of data
13
TCP Reliability
  • TCP provides reliability by requiring recipient
    nodes to send acknowledgments
  • Acknowledgements are sometimes called ACKs
  • When a packet is received by the destination, an
    ACK is sent back to the source
  • When the source receives the ACK, it sends the
    next packet
  • And so on, and so on,

14
TCP Reliability
S
D
Network
M
M
M
M
M
M
M
A
A
A
A
A
A
A
M
M
M
M
M
M
M
A
A
15
TCP Reliability
  • If a packet is sent, and no ACK is received
    within a certain time, the message will be
    retransmitted
  • This time is called the timeout
  • It is possible that the original packet was
    received, but the ACK was somehow lost
  • TCP networks treat both situations identically
  • The destination will receive the packet again,
    ignore it (it already has the data), and
    acknowledge it again
  • Hopefully this time, the acknowledgement will be
    received

16
TCP Reliability
S
D
Network
M
M
M
M
M
M
M
5
6
7
8
9
10
17
TCP Reliability
  • If each node waited for acknowledgements without
    transmitting data, it would involve wasteful
    delays between packets in a series
  • TCP uses a scheme called the sliding window
    technique to solve this problem

18
Sliding Window Technique
  • The sliding window technique allows a
    transmitting node to transmit more than one
    packet without waiting for an ACK
  • Nodes cannot transmit more than S packets beyond
    the first unacknowledged packet
  • S is known as the window size
  • Thus, transmitting nodes have a window of up to
    S packets, all of which have already been sent
  • Some of these packets may be acknowledged
  • At least the first packet is unacknowledged (but
    sent)
  • When an ACK is received for the first packet in
    the window, another packet can be sent
  • The window index can be increased by one

19
Sliding Window Technique
  • Lets see an example without a sliding window
  • Packet size 4, Data abcd efgh ijkl mnop

SYN
SYN/ACK
ACK
1 abcd
Connection established
Passage of Time
ACK 1
2 efgh
ACK 2
3 ijkl
ACK 3
etc
4 mnop
20
Sliding Window Technique
  • Lets see the same example with a sliding window
  • Packet size 4, Window size 3, Data abcd efgh
    ijkl mnop

SYN
SYN/ACK
ACK
1 abcd
Connection established
2 efgh
3 ijkl
Passage of Time
ACK 1
ACK 2
ACK 3
4 mnop
ACK 4
21
Piggybacked ACKs
  • Often two node communicate back and forth
  • When an acknowledgement is to be sent from A to
    B, as well as a data packet, the ACK can be added
    to the packet and sent to B as one packet
  • Essentially, only the sequencing number is
    required to indicate that a message has been
    received
  • Sequencing numbers are discussed later
  • Rather than send a small packet (ACK) followed by
    a larger packet (data), the node sends a single
    larger packet (data with piggybacked
    acknowledgement)

22
TCP Layers
Application
Transport Control Protocol (TCP)
Internet Protocol (IP)
Network Interface Hardware
23
TCP/UDP Layers
Application
TCP
UDP
Internet Protocol (IP)
Network Interface Hardware
24
TCP Header Information
  • As stated previously, TCP is built on top of IP
    datagrams
  • These datagrams must arrive correctly
  • Therefore, TCP streams are often created using
    the same information as would be used in the IP
    datagram header
  • Address (network and machine portion)
  • Header checksum
  • etc,

25
Ports
  • Multiple TCP streams can be active on any machine
  • Therefore, ports should be used to represent
    which stream is which
  • These ports are the same ones used for UDP
  • This makes sense, considering both use IP
    datagrams for their implementation

26
Sockets
  • Sockets, to programmers, represent connections to
    the network
  • In some sense, a socket are associated with a
    network port on the machine
  • A machine (and even a single program) may have
    several open sockets at any time

27
Sockets
  • In UDP, sockets can be shared
  • Datagrams from different destinations can be
    received on the same socket
  • Datagrams can be sent to multiple destinations
    through the same socket
  • In TCP, sockets can not be shared
  • TCP sockets (or stream sockets) represent an
    active connection with the other side
  • Both source and destination must have an active
    socket open for communication to occur

28
Stream Sockets
  • With stream sockets, one side must initiate the
    connection
  • The side that will accept a connection requests a
    passive open with its operating system
  • This indicates that the OS should accept incoming
    connection requests
  • A port is associated with the passive open, and
    can be used by the initiating node when
    requesting the connection
  • The side that initiates a connection requests an
    active open
  • The initiating node requests a connection with a
    given machine (specified by its address) at a
    particular port
  • If the machine has a passive open registered at
    that port, the connection will be accepted,
    otherwise it will not

29
Stream Sockets
  • The socket that represents a passive open
  • Is called a server socket
  • Represents the willingness to accept connections
  • The socket that represents an active open
  • Is called a client socket
  • Represents the act of actually connecting to a
    server socket

30
Data Corruption
  • TCP uses a 16 octet checksum to ensure that data
    has not been corrupted
  • If data is changed in any way, the checksum
    computed using the data at the destination will
    be different than the checksum computed on the
    source side (and transmitted along with the data)
  • If checksums do not match
  • Data is corrupt
  • The checksum is corrupt
  • Both situations are treated identically in TCP,
    data is retransmitted

31
Retransmission
  • Similar to re-collision avoidance backoff,
    unacknowledged packets are sent after increasing
    timeouts
  • This prevents packets from being indefinitely
    lost because the timeout value is too short for
    extremely high network usage situations
  • Unless a message is undeliverable, in any amount
    of time, the message will eventually reach its
    destination and be acknowledged

32
Connection Use
  • Once a connection has been made, sequence numbers
    are used to represent packets that make up the
    data stream
  • Sequence numbers indicate the position of the
    data in the packet in the data stream
Write a Comment
User Comments (0)
About PowerShow.com