7/29/2019 resumen-Cap5b
1/4
Multiplexing Using TCP port Numbers
TCP and UDP both use a concept called multiplexing
Jessie needs to know which application to give the data to, butall three packets are from
the same Ethernet and IP address.
Each of Hannahs TCP and UDP segments uses a different destination port
numberso that Jessie knows which application to give the data.
Multiplexing relies on a concept called a socket. A socket consists of three things:
An IP addressA transport protocolA port number
So, for a web server application on Jessie, the socket would be (10.1.1.2, TCP, port 80)
because, by default, web servers use the well-known port 80. When Hannahs web browserconnects to the web server, Hannah uses a socket as wellpossibly one like this: (10.1.1.1,
TCP, 1030). Why 1030? Well, Hannah just needs a port number that is unique on Hannah,so Hannah sees that port 1030 is available and uses it. In fact, hosts typically allocate
dynamic port numbers starting at 1024 because the ports below 1024 are reserved for well-
known applications, such as web services.
Because a socket on a single computer should be unique, a connection between two sockets
should identify a unique connection between two computers. This uniqueness means thatyou can use multiple applications at the same time, talking to applications running on thesame or different computers.
7/29/2019 resumen-Cap5b
2/4
Error recovery (Releability)To accomplish reliability, TCP numbers data bytes using the Sequence andAcknowledgment fields in the TCP header. TCP achieves reliability in both directions,
using the Sequence Number field of one direction combined with the Acknowledgment
field in the opposite direction.
the Acknowledgment field in the TCP header sent by the web client (4000) implies the nextbyte to be received; this is calledforward acknowledgment. The sequence number reflectsthe number of the first byte in the segment. In this case, each TCP segment is 1000 bytes
long; the Sequence and Acknowledgment fields count the number of bytes.
Figure 6-6 depicts the same scenario, but the second TCP segment was lost or is in error.The web clients reply has an ACK field equal to 2000, implying that the web client is
expecting byte number 2000 next. The TCP function at the web server then could recoverlost data by resending the second TCP segment. The TCP protocol allows for resending
just that segment and then waiting, hoping that the web client will reply with an
acknowledgment that equals 4000.
7/29/2019 resumen-Cap5b
3/4
Flow control using WindowingThis Window field implies the maximum number of unacknowledged bytes that are
allowed to be outstanding at any instant in time. The window starts small and then grows
until errors occur. The size of the window changes over time, so it is sometimes called adynamic window. Additionally, because the actual sequence and acknowledgment numbers
grow over time, the window is sometimes called a sliding window, with the numberssliding (moving) upward. When the window is full, the sender does not send, which
controls the flow of data
The receiver uses the Window field to tell the sender how much data it can send before it
must stop and wait for the next acknowledgment. As with other TCP features, windowingis symmetrical. Both sides send and receive, and, in each case, the receiver grants a
window to the sender using the Window field.
Windowing does not require that the sender stop sending in all cases. If an
acknowledgment is received before the window is exhausted, a new window begins, and
the sender continues sending data until the current window is exhausted. (The termPositiveAcknowledgment and Retransmission [PAR] is sometimes used to describe the error
recovery and windowing processes that TCP uses.)
Connection Establishment and Termination
This three-way connection establishment flow must end before data transfer can begin. The
connection exists between the two sockets, although the TCP header has no single socketfield. Of the three parts of a socket, the IP addresses are implied based on the source and
destination IP addresses in the IP header. TCP is implied because a TCP header is in use, as
specified by the protocol field value in the IP header. Therefore, the only parts of thesocket that need to be encoded in the TCP header are the port numbers.
TCP signals connection establishment using 2 bits inside the flag fields of the TCP header.
Called the SYN and ACK flags, these bits have a particularly interesting meaning. SYNmeans Synchronize the sequence numbers, which is one necessary component in
initialization for TCP. The ACK field means The Acknowledgment field is valid in this header. Until the sequence numbers are initialized, the Acknowledgment field cannot be
very useful. Also notice that in the initial TCP segment in Figure 6-8, no acknowledgment
7/29/2019 resumen-Cap5b
4/4
number is shown; this is because that number is not valid yet. Because the ACK field must
be present in all the ensuing segments, the ACK bit continues to be set until the connectionis terminated.TCP initializes the Sequence Number and Acknowledgment Number fields to any number
that fits into the 4-byte fields; the actual values shown in Figure 6-8 are simply sample
values. The initialization flows are each considered to have a single byte of data, as
reflected in the Acknowledgment Number fields in the example.
Figure 6-9 shows TCP connection termination. This four-way termination sequence is
straightforward and uses an additional flag, called the FIN bit. (FIN is short for finished,as you might guess.) One interesting note: Before the device on the right sends the thirdTCP segment in the sequence, it notifies the application that the connection is coming
down. It then waits on an acknowledgment from the application before sending the third
segment in the figure. Just in case the application takes some time to reply, the PC on the
right sends the second flow in the figure, acknowledging that the other PC wants to takedown the connection. Otherwise, the PC on the left might resend the first segment
repeatedly.
Connection-oriented protocol: A protocol that requires an exchange of messagesbefore data transfer begins or that has a required preestablished correlation between
two endpoints
Connectionless protocol: A protocol that does not require an exchange of messagesand that does not require a preestablished correlation between two endpoints
Data Segmentation and ordered data transfer
Each different type of data-link protocol typically has a limit on the maximum transmission
unit(MTU) that can be sent inside a data link layer frame. In other words, the MTU is thesize of the largest Layer 3 packet that can sit inside a frames data field. For many data-link
protocols, Ethernet included, the MTU is 1500 bytes.
TCP handles the fact that an application might give it millions of bytes to send by
segmenting the data into smaller pieces, called segments. Because an IP packet can often be
no more than 1500 bytes because of the MTU restrictions, and because IP and TCP headers
are 20 bytes each, TCP typically segments large data into 1460-byte chunks.
The TCP receiver performs reassembly when it receives the segments. To reassemble the
data, TCP must recover lost segments, as discussed previously. However, the TCP receiver
must also reorder segments that arrive out of sequence.
the TCP receiver also must perform ordered data transferby reassembling the data into theoriginal order.
If segments arrive with the sequence numbers 1000, 3000, and 2000, each with 1000 bytesof data, the receiver can reorder them, and no retransmissions are required.
UDPUser datagram protocolUDP is connectionless and provides no reliability, no windowing, no reordering of thereceived data, and no segmentation of large chunks of data into the right size for
transmission.However, UDP provides some functions of TCP, such as data transfer and multiplexing
using port numbers, and it does so with fewer bytes of overhead and less processingrequired than TCP.Applications that use UDP are tolerant of the lost data, or they have some application
mechanism to recover lost data. For example, VoIP uses UDP. DNS requests y Network
File System (NFS) use UDP.
Top Related