TCP/IP Stack:
The TCP/IP suite is a combination of two individual protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP). The TCP/IP is divided in to layers, each of which performs specific functions in the data communication process. This topic describes how the layers of TCP/IP are organized into a stack.
An OSi reference model provides a common reference for maintaining consistency within all types of network protocols and services. A reference model is not intended to be an implementation specification or to provide a sufficient level of detail to precisely define the services of the network architecture. The primary purpose of a reference model is to aid in clearer understanding of the functions and process involved.
The TCP/IP suite was developed at approximately the same time as the OSI model. Like the OSI model, the TCP/IP suite is a means of organizing components in an order that reflects their functions in relation to one another. It defines four categories of functions that must occur for communications to be successful. The components, or layers, of the TCP/IP stack are as follows:
- Network access layer: This layer covers the same processes as the two lower OSI layers:
Physical layer: The physical layer defines the electrical, mechanical, procedural, and functional specifications for activating, maintaining, and deactivating the physical link between end systems. Characteristics such as voltage levels, timing of voltage changes, physical data rates, maximum transimmission distances, physical connectors, and other similar attributes are defined by physical layer specifications.
Data link layer: The data link layer defines how data is formatted for transmission and how access to the network is controlled.
- Internet layer: This layer provides routing of data from the source to the destination by defining the packet and the addressing scheme, moving data between the data link and transport layers, routing packets of data to remote hosts, and performing fragmentation and reassembly of data packets.
- Transport layer: The transport layer is the core of he TCP/IP architecture. It provides communication services directly to the application processes that are running on network hosts.
- Application layer: The application layer provides applications for file transfer, network troubleshooting, and Internet activites. It also supports network application programming interfaces (APIs) that allow programs that have been created for a particular operating system to access the network.
Transport layer is a important layer it uses two major protocols:
- Transmission Control Protocol(TCP).
- user Datagram Protocol(UDP).
It takes large blocks of information from application and breaks them in to segments. It numbers and sequences each segment so that the destination's TCP stack can put the segments back into the order the application intended. After these segments are sent, TCP waits for an acknowledgment of the receiving end's TCp virtual circuit session, retransmitting those that aren't acknowledged.
Before a transmitting host starts to send segments down the model, the sender's TCP stack contacts the destination's TCP stack to establish a connection. now what we created is called virtual circuit. This type of communication is called connection - oriented. during this initial handshake, the two TCP layers also agree on the amount of information that's going to be sent before the recipient's TCP sends back an acknowledgment. With everything agreed upon in advance, the path is paved for reliable communication to take place.
TCP Segment Format:
The upper layer just send a data stream to the protocols in the Transport layers, TCP segments a data stream and prepares it for the Internet layer. When internet layer receives the data stream, it routes the segments as packets through an internetwork. The segments are handed to the receiving host's Transport layer protocol, which rebuilds the data stream to hand to the upper-layer application or protocols.
The TCP header is 20 bytes long, or upto 24 bytes with options. You need to understand what each field in the TCP segment is:
Source Port Port number of the application on the host sending the data.
Destination Port Port number of the application requested on the destination host.
Sequence number A number used by TCP that puts the data back in the correct order or re-transmits missing or damaged data, a process called sequencing.
Acknowledgment number The TCP octet that is expected next.
Header length the number of 32-bit words in the TCP header. This indicates were the data begins. The TCP header is an integral number of 32bits in length.
Reserved always set to zero.
Code bits/flags Control functions used to set up and terminate a session.
Window The window size the sender is willing to accept, in octets.
Checksum The cyclic redundancy check (CRC), because TCP doesn't trust the lower layers and checks everything. The CRC checks the header and data fields.
Urgent A valid field only if the Urgent pointer in the code bits is set. If so, this value indicates the offset from the current sequence number, in octets, where the segment of non-urgent data begins.
Options May be 0 or a multiple of 32 bits, if any. What this means is that no options have to be present(option size 0). However, if any options are used that do not cause the option field to total a multiple of 32 bits, padding of 0s must be used to make sure the data begins on a 32-bit boundary.
Data Handed down to the TCP protocol at the Treansport layer, which includes the upper-layer headers.
Example
TCP- transport control protocol
Source Port: 5973
Destination Port: 23
Sequence number: 145632547
Ack number: 124563789
offset: 5
Reserved: 000
Code: %11000
Window 613204
Check sum: 0x61b6
Urgent Pointer: 0
No TCP options
TCP data area : 76 4c 16 35 15 11 58 a2 56 91 2b
Frame check sequence: 0x0d00f00
User Datagram Protocol(TCP):
If you were compare UDP with TCP, the former is basically the scaled-down economy model that's sometimes referred to as a thin protocol. Much bandwidth on a network. Udp is not reliable delivery because it does not have acknowledgment packet.
There are some situations in which it would definitely be wise for developers to opt for UDP rather than TCP. One circumstance is when reliability is already handled at the process Application layer. Network File System(NFS) handles its own reliability issues, making the use of TCP both impractical and redundant. But ultimately, it's up to application developer to decide whether to use UDP or TCP, not the user who wants to transfer data faster.
UDP does not sequence the segments and does not care in which order the segments arrive at the destination. UDP sends the segments off and forgets about them. UDP uses when data transfer data fast because it does have acknowledgment so no need to wait for it.
UDP Segment Format:
UDP's markedly low overhead as compared to TCP's. UDP doesn't use windowing or provide for acknowledge in the UDP header
Source Port Port number of the application on the host sending the data.
Destination Port Port number of the application requested on the destination host.
Length Length of UDP header and UDP data.
Checksum Checksum of both the UDP header and UDP data field.
Data Upper layer data. UDP, like TCP, doesn't trust the lower layers and runs its own Cyclic redundancy check(CRC). Remember that the frame check sequence(FCS) is the field that houses the CRC, which is why you can see the FCS information.
Example:
User Datagram Protocol
Source Port: 1085
Destination Port: 5136
Length: 41
Checksum: 0x7a3c
UDP data area:
00 01 sa 96 00 12 58 00 00 00 14 23 2222
Frame check sequence:0x00000011.
