unit4

31
UNIT-4 IP Datagrams and Forwarding Connectionless service – Virtual Packets – IP Datagram – Forwarding – IP Address and Routing Table Entry – Mask Field and Datagram Forwarding – IP Datagram Header Format. IP Encapsulation and Fragmentation – Datagram Transmission and Frames, Encapsulation, Transmission across an Internet, MTU, Datagram size and Encapsulation – Reassembly – Fragment Loss. TCP – Reliable Transport service – Need for Reliable Transport – TCP- Services provided – End to end service, Packet loss and Retransmission, Retransmission Times, Buffers, Flow control and Windows, Three-Way Handshake, Congestion control, TCP Segment Format.

Upload: mishal-dsouza

Post on 19-Nov-2015

16 views

Category:

Documents


0 download

DESCRIPTION

Computer Networking

TRANSCRIPT

UNIT-4

IP Datagrams and Forwarding Connectionless service Virtual Packets IP Datagram Forwarding IP Address and Routing Table Entry Mask Field and Datagram Forwarding IP Datagram Header Format.IP Encapsulation and Fragmentation Datagram Transmission and Frames, Encapsulation, Transmission across an Internet, MTU, Datagram size and Encapsulation Reassembly Fragment Loss.

TCP Reliable Transport service Need for Reliable Transport TCP- Services provided End to end service, Packet loss and Retransmission, Retransmission Times, Buffers, Flow control and Windows, Three-Way Handshake, Congestion control, TCP Segment Format.

IP Datagrams and Forwarding

Connectionless services : Initially the designers must decide the type of the service. Two types of connection service provided are: (1) Connection-Oriented service. (2) Connectionless service. Connectionless services do not require a session connection between the Sender and the Receiver. In this type of service, the Application programs are unaware of the underlying physical hardware. The sender simply starts simply sending packets(called Datagrams) to the destination. There is no acknowledgement confirmation from the receiver. So the Connectionless service always provides the Unreliable communication. A Connectionless service provides minimal services. In contrast, connectionless service is modeled after the postal system. Each message (letter) carries the full destination address, and each one is routed through the system independent of all the others. Normally, when two messages are sent to the same destination, the first one sent will be the first one to arrive. However, it is possible that the first one sent can be delayed so that the second one arrives first.

Virtual Packets : To overcome the heterogeneity, internet protocol software defines an internet packet format that is independent of the underlying hardware. The result is universal, Virtual packet that can be transferred across the underlying hardware. As the term virtual implies, protocol software creates and handles internet packets-the underlying hardware does not understand or recognize the internet packet format. As the term universal implies, each host or router in an internet contains protocol software that understands internet packets. TCP/IP protocols use the name IP datagram to refer to an internet packet. An IP datagram has the same general format as a hardware frame; the datagram begins with a header following by a data area.

The Header contains information that controls where and how the datagram is to be sent. The amount of data carried in a datagram is fixed. The sender chooses an amount of data that is appropriate to a particular packet. The size of a datagram is determined by the application that sends data. Example: An application that transmits keystrokes across a network can place each keystroke in a separate datagram, while an application that transfers large files can send large datagrams.

IP Datagram forwarding : Datagrams traverse an internet by following a path from their initial source through routers to the final destination. Each router along the path receives the datagram, extracts the destination address from the header, and uses the destination address to determine a next hop to which datagram should be sent. The router then forwards the datagram to the next hop, either the final destination or another router. To make the selection of a next hop efficient, each IP router keeps the information in a routing table. A routing table must be initialized, when the router boots, and must be updated if the topology changes/hardware fails. Conceptually, a routing table contains a set of entries that each specify a destination and the next hop used to reach that destination. Example:

DestinationNext hop

Net 1R1

Net 2deliver direct

Net 3deliver direct

Net 4R3

In the above diagram, router R2 directly connects the networks: Net 1 and Net 2. Therefore, R2 can directly deliver a datagram to any destination attached to those networks. When a datagram is destined for Net 4, R2 sends the datagram to router R3.

IP address and Routing Table Entry : In practice, IP routing table consists of 3 fields. First, the destination field in each entry contains the network prefix of the destination network. Second, an additional field in each entry contains an address mask that specifies which bits of the destination correspond to the network prefix. Third, an IP address is used when the next hop fields denotes a router.

DestinationMaskNext hop

30.0.0.0255.0.0.040.0.0.7

40.0.0.0255.0.0.0deliver dierct

50.8.0.0255.255.0.0deliver dierct

60.6.10.0255.255.255.050.8.0.9

Mask Field and Datagram forwarding : The process of using a routing table to select a next hop for a given datagram is called routing or forwarding. The mask field in a routing table entry is used to extract the network part of an addressing during lookup. Imagine that a routing software is given a datagram to forward. Also assume that the datagram contains a destination IP address D. The routing software must find an entry in the routing table that specifies a next hop for D. To do so, the software examines each entry in the table by using the mask in the entry to extract a prefix of address D and comparing the result to the destination field of the entry. If the two are equal, the datagram will be forwarded to the Next hop in the entry. A bit mask makes prefix extraction efficient. Software computes the Boolean AND of the mask and the datagram destination address D.If((Mask[i] & D)==Destination[i]) forward to nextHop[i];

IP Datagram Header Format

VERS : Version - 4-bit protocol version(ipv4 or ipv6). H.LEN : Header Length - Number of 32 bit entities in the header. SERVICE TYPE : Minimum delay or maximum throughput. TOTAL LENGTH : Total number of octets in the header and data. IDENTIFICATION : : After fragmentation each fragment is given a number). FLAGS : Indicates datagram is a fragment. FRAGMENT OFFSET : How to order the fragments. TIME TO LIVE : Positive integer from 1 to 255. Counter decrements from the value when the datagram begins to send. When counter reaches 0, datagram is discarded and error message will be sent to the source. HEADER CHECKSUM : bits of the header are not changed in transmit. Sender computes 1s complement sum of all 16 bit entities in the header excluding header checksum field. Receiver computes the same 16 bit including header checksum. Checksum is correct if result is zero. SOURCE IP ADDRESS : Logical address of the Source. DESTINATION IP ADDRESS : Logical address of the Destination PADDING : That contains zero bits to make header multiple of 32 bits.

Data Transmission and Frames, Encapsulation : When a host or router handles a datagram, IP software first select the next hop to which the datagram should be sent, N, and then transmits the datagram across a physical network to N. Network hardware does not understand the datagram format or the Internet addressing. Instead, each hardware technology defines a frame format and a physical addressing scheme; the hardware only accepts and delivers packets that adhere to the specified frame format and use the specified hardware address. Encapsulation is a technique used to transmit a datagram across a physical network that does not understand the datagram format. When an IP datagram is encapsulated in a frame, the entire datagram is placed in the data area of a frame. The network treats a frame that contains a datagram exactly like any other frame. In fact, the hardware does not examine/change the contents of the frame data area. When datagram is placed in a frame, the sender assigns the frame type field, the value that is reserved for IP. When the frame arrives with the special value in its type field, the receiver knows that the data area contains an IP datagram. A frame that carries an IP datagram must have a destination address as usual. Therefore, in addition to placing a datagram in the data area of a frame, encapsulation requires the sender to supply the physical address of the next computer to which the datagram should be sent.

An IP datagram is encapsulated in a Frame

Transmission across an Internet Encapsulation applies to one transmission at a time. After the sender selects a next hop, the sender encapsulates the datagram in a frame and transmits the result across the physical network to the next hop. When the frame reaches the next hop, the receiving software removes the IP datagram and discards the frame. If the datagram has to be forwarded across another network, a new frame is created. Each network can use a different hardware technology than the others, meaning that the frame formats can differ. In the diagram given below, hosts and routers store a datagram in memory with no additional header. When the datagram passes across a physical network, the datagram is encapsulated in a frame suitable for the network. The size of the frame header that appears before the datagram depends on the network technology. When a datagram arrives in a network frame, the receiver extracts the datagram from the frame data area and discards the frame header.

An IP datagram as it appears at each step during a trip across an internet.

MTU, Datagram size and encapsulation : Each hardware technology specifies the maximum amount of data that a frame can carry. The limit is known as maximum transmission unit (MTU). There is no exception to the MTU limit. The network hardware is not designed to accept or transfer frames that carry more data than the MTU allows. The datagram must be smaller or equal to the network MTU or it cannot be encapsulated for transmission. An IP router uses a technique known as fragmentation to solve the problem of heterogeneous MTUs. When a datagram is larger than the MTU of the network over which it must be sent, the router divides the datagram into smaller pieces called fragments, and sends each fragment independently. Fragment has same format as other datagrams.

MTUA bit in the FLAGS field in the header indicates whether a datagram is a fragment or a complete datagram. Fragment offset field in the header of a fragment specifies where in the original datagram the fragment belongs. To fragment a datagram, a router uses the network MTU and the datagram header size to calculate the maximum amount of data that can be sent in each fragment and the number of fragments that will be needed. The router then creates the fragments. It begins by starting each fragment with a copy of the original header, and then modifies individual header fields.

Reassembly and Fragment loss : The process of creating the copy of the original datagram from fragments is called Reassembly. Because each fragments begins with a copy of the original datagram header, all fragments have the same destination address as the original datagram from which they are derived. Furthermore, the fragment that carries the final piece of data has an additional bit sent in the header. Thus, a receiver performing reassembly can tell whether all fragments have arrives successfully. IP does not guarantee datagram delivery. If an underlying network drops packets, an encapsulated datagram or fragment can be lost. When all fragments from a datagram arrive, the datagram can be reassembled. However, a problem arises when one or more fragments from a datagram arrive, and some fragments are delayed or lost. A receiver can not hold fragments arbitrarily long time because fragments occupy space in the receivers memory. When the first fragment arrives from a given datagram, the receiver starts a timer. If all fragments of a datagram arrive before the timer expires, the receiver cancels the timer and reassembles the datagram. If the timer expires before all fragments arrive, the receiver discards those fragments that have arrived. Although the datagram cannot be reassembled, the receiver must save the fragments in case missing fragments are only delayed.

TCPTCP-Transmission Control Protocol : TCP is a connection-oriented protocol. It does not mean it has a physical connection between sender and receiver. TCP provides the function to allow a connection virtually exists also called virtual circuit or connection. TCP offers a reliable byte-stream delivery service .

Functions provides by TCP are : Dividing a chunk of data into segments. Reassembly segments into the original chunk. Provide further the functions such as reordering and data resend.

TCP-Services : Services provided by TCP applications are : a. Connection-orientation : TCP provides connection-oriented service in which an application must first request a connection to a destination, and then use the connection to transfer data.b. Point-to-Point communication : Each TCP connection has exactly two endpoints. TCP always provides the end-to-end communication. c. Complete Reliability : TCP guarantees that the data sent across a connection will be delivered exactly as sent, with no data missing or out of order.d. Full Duplex communication : A TCP connection allows data to flow in either direction, and allows either application program to send data at any time. TCP can buffer outgoing and incoming data in both directions, making it possible for an application to send data and then to continue computation while the data is being transferred.e. Stream Interface : TCP provides a stream interface in which an application sends a continuous sequence of octets across a connection. That is, TCP does not guarantee that data will be delivered to the receiving application in the same size pieces that it was transferred by the sending applications.f. Reliable Connection Start-Up : TCP requires that when two applications create a connection, both must agree to the new connection; duplicate packets used in previous connections will not appear to be valid responses or otherwise interface with the new connection.g. Graceful Connection Shutdown : An application program can open a connection, send arbitrary amounts of data, and then request that the connection be shutdown. TCP guarantees to deliver all the data reliably before closing the application.

End to End services and datagrams : TCP is called end-to-end protocol because it provides a connection directly from an application on one computer to another application on a remote computer. The applications can request that TCP form a connection, send and receive data and close the connection. The connections provided by TCP are called Virtual connections because they are achieved in software. Indeed, the underlying internet system does not provide hardware/software support for connections. Instead, the TCP software modules on two machines message exchanges to achieve the illusion of a connection. TCP uses IP to carry messages. Each TCP message is encapsulated in an IP datagram and sent across the internet. When the datagram arrives on the destination host, IP passes the contents to TCP.

Packet Loss and Retransmission : Retransmission is a technique used to handle parts of the problem. When TCP sends data, the sender compensates for packet loss by implementing a retransmission scheme. Both sides of a communication participates. When TCP receives data, it sends an acknowledgment back to the sender. Whenever it sends data, TCP starts a timer. If the timer expires before an acknowledgment arrives, the sender retransmits the data. This scheme handles communication across an arbitary internet and allows multiple application programs to communicate concurrently. TCP faces a more difficult challenge than distinguishing between local and remote destinations : bursts of datagrams can cause congestion, which causes transmission delays along a given path to change rapidly. Adaptive retransmission : Earlier a fixed value for retransmission delay was chosen by designers. Then they chose delay to be adaptive , considering current delay on each connection. TCP estimates round-trip delay for each connection which measures the time to get response. The average calculated by applying statistical function to sequences of round trip estimates.

Retransmission Times : Consider a case of packet loss on two connections that have different round-trip delays. As the diagram shows, TCP sets the transmission to be slightly longer than the mean round-trip delay. If the delay is large, TCP uses a large transmission timeout; if the delay is small, TCP uses a small timeout. The goal is to wait long enough to determine that a packet was lost, without waiting longer than necessary.

Timeout and retransmission on two connections that that have different round-trip delays. TCP optimizes throughput by using a round-trip estimate to compute a retransmission timer.

Buffers, Flow control and Windows : TCP uses a window mechanism tool to control the flow of data. When a connection is established, each end of the connection allocates a buffer to hold incoming data, and sends the size of the buffer to the other end. As data arrives, the receiver sends acknowledgements, which also specify the remaining buffer size. The amount of buffer size available at any time is called the Window, and a notification that specifies the size is called a Window Advertisement. If the receiving application can read data as quickly as it arrives, a receiver will send a positive window advertisement along with each acknowledgement. However, if the sending side operates faster than a receiving side, incoming data will eventually fill the receivers buffer, causing the receiver to advertise a zero window. A sender that receives a zero window advertisement must stop sending until the receiver again advertises a positive window.

Three-Way handshake : To guarantee that connections are established or terminated reliably, TCP uses a Three-Way -Handshake in which three messages are exchanged. Scientists have proved that a three way exchange is necessary and sufficient to ensure unambiguous agreement despite packet loss, duplication and delay. TCP uses the term Synchronization segment(SYN segment) to describe messages in a three-way-handshake used to create a connection, and the term Finish segment(FIN segment) to describe messages in a three-way-handshake used to close a connection. Like other messages, TCP transmits lost SYN or FIN segments. Furthermore, the handshake guarantees that TCP will not open or close a connection until both ends have interacted. Part of the three-way-handshake used to create a connection requires each end to generate a random 32-bit sequence number. If an application attempts to establish a new TCP connection after a computer reboots, TCP chooses a new random sequence, and then establish a new TCP connection without interference from duplicate or delayed packets.

Congestion Control : One of the most interesting aspects of TCP is a mechanism for Congestion control. In most modern internets, packet loss is more likely to be caused by congestion than a hardware failure. Interestingly, transport protocols that retransmit can exacerbate the problem of congestion by injecting additional copies of a message. If congestion triggers excessive retransmission, the entire system can reach a state of congestion collapse, analogous to a traffic jam on a highway. To avoid the problem, TCP always uses packet loss as a measure of congestion, and responds by reducing the rate at which it retransmits data. Whenever a message is lost, TCP begins congestion control. Instead of retransmitting enough data to fill the receivers buffer, TCP begins by sending a single message containing data. If the acknowledgement arrives without additional loss, TCP doubles the amount of data being sent, and sends two additional messages. If acknowledgement arrive for those two, TCP sends four more and so on. The exponential increase continues until TCP is sending half of the receivers advertisement window, at which time TCP slows down the rate of increase. TCPs congestion control scheme responds well to increased traffic in an internet. By backing of quickly, TCP is able to alleviate congestion.

TCP Segment Format : TCP uses a single format for all messages, including messages that carry data, acknowledgements, and messages that are part of three-way handshake used to create or terminate a connection. TCP uses the term segment to refer to a message.

A TCP connection contains two streams of data, one flowing in each direction. If the application at each end are sending data simultaneously, TCP can send a single segment that carries the acknowledgement for incoming data, a window advertisement that specifies the amount of additional buffer space available for incoming data and incoming data. Thus, some of the fields in the segment refer to the data stream travelling in the forward direction, while other fields refer to the data stream travelling in the reverse direction. Source port identifies the application sending data. Destination port - identifies the application recieving data. Sequence number- sequence number of outgoing message number of first octet. ACKN Number- sequence number expected next. Window buffer available. Checksum- for header and data.