Sunday, January 20, 2013

Data Initiation, Encapsulation and Navigation through TCP/IP protocol stack

by Neil Lynch

This article describes a two segment network interfaced with a router. It shows how data is initiated and encapsulated as it navigates through the 4-layers of the TCP/IP protocol stack from Application to Network, utilizing the ARP cache to find the gateway’s address, so the MAC frames can be delivered, filtered, and pulled-off allowing the packet to be sent to the destination (Host) MAC and IP addresses. Once a connection is established a Host to Host, connection-oriented (3-way handshake) would begin, using the TCP protocol at the Transport Layers for reliability.

The TCP/IP host composes its data at the Application Layer. Ex. [Data]

The data is then passed to the Transport Layer protocol of which there are two (TCP and UDP), the connection-oriented protocol is chosen in this exercise, for it reliability as opposed to the unreliable (UDP) connection-less protocol.

The data is encapsulated in the Transport layer’s header. This segment manages data size and flow control.

Ex. [Transport Layer header [Data]]

The Data and Transport Layer header are passed to the Network Layer, the next step down in the TCP/IP protocol stack where the packet now includes the IP header, the Transport layer header and Data.

Ex. [Source IP address [Destination IP address [Transport layer header [Data]]]]

At the next step in the protocol stack, the OSI Data Link layer, containing the source MAC address and the destination (gateway or router’s) MAC address are added to the frame; … the sending computer attained the router’s MAC address by looking in the ARP cache or by sending an ARP request.

Ex. [source MAC address [destination (router *E1) MAC address [Source IP address [Destination IP address [Transport layer header [Data]]]]

The encapsulated frame is sent to the remote segment via the default gateway (the router or network interface connecting the local segment … to the other networks). When the router receives the frame, it pulls off the network interface information (OSI Data Link layer header) which contains the router’s MAC address because it’s no longer necessary, now that the router is in possession of the packet. It then analyzes the packet at the Network layer.

Ex. [Source IP address [Destination IP address [Transport layer header [Data]]]]

                         MAC address is removed from frame, leaving (packet)

The router then checks its routing table against the destination IP address to locate the appropriate network interface through which to forward the packet.

If the router is directly connected to the network for which the packet is destined, it will re-address the frame at the Network Interface layer with the MAC address of the destination host; it gets this MAC address from its ARP cache or an ARP request on the destination’s subnet.

Ex. [source (router *E0) MAC address [destination MAC address [Source IP address [Destination IP address [Transport layer header [Data]]]]

             Frame re-addressed by Router after receiving MAC address from ARP(cache or request)

Once the router has the correct MAC to IP mapping, it repackages the Network Interface (OSI Data Link layer 2) using the MAC addresses of the destination host.  After repackaging, the frame is sent to the destination host via the lower level of the (TCP/IP) protocol stack. The MAC addresses of the frame are then decapsulated at the Data Link layer and the packet then moves up to the Network Layer, where the IP addresses are decapsulated. At the next layer up … the Transport layer, the segment is decapsulated, the Data is then received by Application Layer and ultimately by Host B.

 Now that a route (connection) is established, the three-way handshake can begin, ultimately allowing data to be transferred between hosts.

TCP requires a three-way handshake, once communication is established between Host A and Host B; that’s a connection request from Host A to Host B,  and then an acknowledgement from Host B to Host -A.

·       Ex. Host A -----------------connection request-------------> Host B

·             Host A <--------- ------acknowledgement----------------Host B

·                               Once achieved, data is transmitted.

·              Host A ---------------------data---------------------------->Host B









*E1, E0 router connecting two segments --------> (E1/E0) ----------->,

Host A to E1 and  E0 to Host B

No comments:

Post a Comment