|
Host-to-Host Layer
This layer shields the upper layers from the process of sending data. Also
provides an end-to-end connection between two devices during communication by
performing sequencing, acknowledgments, checksums, and flow control.
Applications using services at this layer can use two different protocols: TCP
and UDP.
Protocols at the Host-to-Host Layer are:
TCP (Transmission Control Protocol)
TCP provides a connection-oriented, reliable services to the applications
that use its services.
Main Functions of TCP
- Segments application layer data
stream--
- TCP accepts data from applications and segments it into a desirable size for
transmission between itself and the remote devices. The segment size is
determined while TCP is negotiating the connection between the two devices.
Either device can dictate the segment size.
- Provides acknowledgment times--
- TCP maintains timers to identify when packets have taken too long to get to
their destination. When an acknowledgment is not received for a packet and the
timer expires, TCP will resend the packet to the destination.
- Enables sequence number checking--
- TCP/IP uses sequence numbers to ensure that all packets sent by an
application on one device are read in the correct order by an application on
another device. The packets might not be received at the transport layer in the
correct order, but TCP sequences them in their original order before passing
them to the application layer.
- Provides buffer management--
- Any time two devices are communicating, the possibility exists that one
device can send data faster than the other can accept it. If this happens, the
receiving device puts the extra packets into a buffer to be read at the first
chance it gets. When this data overflow persists, however, the buffer is
eventually filled and packets begin to drop. TCP performs some preventive
maintenance called flow control to avoid the problem.
- Initiates connections with 3-way
handshake--
- TCP uses the concept of the three-way handshake to initiate a connection
between two devices. A TCP connection begins with a device sending a request to
synchronize sequence numbers (a SYN packet) and initiate a connection. The other
device receives the message and responds with a SYN message and the sequence
number increased by one. The first device responds by sending an acknowledgment
message (an ACK) to the second device, indicating that the device received the
sequence number it expected.
- Performs error and duplication
checking--
- TCP uses a checksum to identify packets that have changed during transport.
If a device receives a packet with a bad checksum, it drops the packet and does
not send an acknowledgment for the packet. So the sending device will resend the
packet. Any time TCP receives a duplicate packet it will drop the duplicate.
- Performs acknowledgment windowing--
- Any time a TCP device sends data to another device, it must wait for the
acknowledgment that this data was received, To increase the bandwidth
utilization, TCP can change the window size. Whatever the window size is
negotiated to be, acknowledgments will only be sent after that many packets have
been received at the receiving device. TCP sets the window size dynamically
during a connection, allowing either device involved in the communication to
slow down the sending data rate based on the other devices capacity. This
process is known as sliding window because of TCP's ability to change the
window size dynamically.
TCP Overview
Before data is sent, the transmitting host contacts the receiving host to set
up a connection known as a virtual circuit. This makes TCP
connection-oriented. During the handshake the two hosts agree upon the
amount of information to be sent before an acknowledgment is needed (Windowing).
TCP takes the large blocks of data from the upper layers and breaks them up into
segments that it numbers and sequences. TCP will the pass the segments to the
network layer, which will route them through the Internetwork. The receiving TCP
can put the segments back into order. After packets are sent, TCP waits for an
acknowledgment from the receiving end of the virtual circuit. If no
acknowledgment is received then the sending host will retransmit the segment.
| TCP Header Information |
Source Port Number
16 bits
(Number of calling port) |
Destination Port
Number
16 bits
(Number of called port) |
Sequence Number
32 bits
(Number to ensure proper sequence of data.) |
Acknowledgment Number
32-bits
(Identifies next segment expected) |
Header Length
4 bits
(Number of 32 bit words in header) |
Reserved
6 bits
(Always 0) |
Code bits
6 bits
(Identifies type of segment, setup/termination of session) |
Window size
16 bits
(Number of octets the device is willing to accept) |
TCP Checksum
16 bits
(Used to ensure data integrity) |
Urgent Pointer
16 bits
(Indicates end of urgent data) |
Options
0 or 32 bits
(Identifies maximum segment size) |
Data
|
UDP (User Datagram Protocol)
UDP transports information that doesn't require reliable delivery; therefore
it can have less overhead than TCP as no sequencing or acknowledgments are used.
NFS and SNMP use UDP for their sessions, the applications have their own methods
to ensure reliability. UDP receives blocks of information from the upper layers,
which it breaks into segments. It gives each segment a number, sends it, and
then forgets about it. No acknowledgments, no virtual circuits,
connectionless protocol.
| UDP Header Format |
Source Port Number
16 bits
(Number of calling port) |
Destination Port Number
16 bits
(Number of called port) |
UDP Length
16 bits
(Length of UDP in bytes) |
UDP Checksum
16 bits
(Used to ensure data integrity) |
Data
|
Differences between TCP and UDP
|
Differences Between TCP and UDP |
| TCP |
UDP |
| Sequenced |
Unsequenced |
| Reliable -sequence numbers, acknowledgments, and 3-way handshake |
Unreliable -best effort only |
| Connection Oriented |
Connectionless |
| Virtual Circuits |
Low Overhead |
| Checksum for Error Checking |
Checksum for Error Checking |
| Uses buffer management to avoid overflow, uses sliding window to maximize
bandwidth efficiency |
No flow control |
| Assigns datagram size dynamically for efficiency |
Every datagram segment is the same size |
TCP and UDP Port Numbers
TCP and UDP use port numbers to communicate with the upper layers. Port
numbers keep track of different sessions across the network. The source port
will be above 1024 (unprivileged). 1023 and below (privileged) are known as well
known ports and are assigned to common protocols. TCP and upper layer don't use
hardware (MAC) and logical (IP) addresses to see the host's address; instead
they use port numbers.
|
|