Assignment GroupB7

advertisement
Assignment Group-B_7
Problem Definition:
Create TCP/IP packet using standard TCP/IP include files and send it to the server using C++.
7.1 Prerequisite:
Knowledge about IP and TCP.
7.2 Learning Objectives:
Understand the concept of IP & TCP.
7.3 Theory
7.3.1 Introduction
Transport layer offers end-to-end connection between two processes on remote hosts. It is
responsible for process to process delivery of message. Transport layer takes data from upper
layer and then breaks it into smaller size segments and sends to lower layer for delivery. This
layer provides source to destination means not only from one computer to another computer but
also from one process to another process running on particular port.
Figure 7.3.1: End-to-end Communication
This Layer provides logical communication between processes running on different
computers. This layer protocols are implemented in the end systems but not in network routers.
All transport layer protocols provides an applications like multiplexing/demultiplexing, including
reliable data transfer, bandwidth management and delay management.
7.3.2 Transport layer Responsibilities/duties and Services
Figure 7.3.2 shows the transport layer duties i.e. packetizing, connection control,
addressing and providing reliability.
Figure 7.3.2: Transport Layer Duties
1. Process-to-process delivery:
The transport layer is responsible for process-to-process delivery of the packets from one
process to another, as we know packet is a part of a message.
Figure 7.3.3 Types of Data Deliveries






Processes on
two hosts communicate with each other by sending and receiving packets to
each other.
For sending and receiving into the network is possible through its socket.

A socket is an interface between the application layer and the transport layer within a host,

used to build network application over the internet. Whenever we need to send something
to the destination require an address. As we know data link layer require an MAC address,

Network layer require IP address same way in transport layer works on an address it is
called port number. It is use to choose specific process among the multiple processes
running on host. The port number is a 16-bit integer in between the 0 to 65,535. The
IANA(Internet Assigned Number Authority) is an organization handle all the issues
related to port number. It has divided all port numbers in three classes are given below,
Figure 7.3.4 Well known port
1. Well-known ports: The port numbers are between 0 to 1023 assigned and controlled
by IANA. All well-known ports come under this category. Example of well-known
port is port 20 and 21 used for FTP.
2. Registered ports: These port numbers are register. The ranging from 1024 to 49,151,
these ports are not assigned and controlled by IANA. But they can be registered with
IANA to avoid port duplication.
3. Dynamic ports: The remaining port called dynamic ports. The ranging from 49,152
to 65,535. These ports are not assigned or controlled by IANA. These ports also
called ephemeral ports.
2. Multiplexing and Demultiplexing
The multiplexing and demultiplexing mechanism is shown in Figure 7.3.5. The multiplexer
and Demultiplexer works in peer. The multiplexer is requires at one side and the demutiplexer
require at other side.
Figure 7.3.5: Multiplexing and demultiplexing

Multiplexing: 
Multiplexing is a process always performed at the sending node. At the sender site, there
may be several processes that need to send packets. But there is only TCP protocol used at a
time. So, the situation is a many-to-one relationship that requires multiplexing. The TCP accepts
messages from different processes, differentiated them by their port numbers. Then add headers,
once header added the transport layer sends the packet to the network layer. The process of
encapsulating data messages from different applications sockets with the header information and
pass the segments to the network layer. The next task is gathering data from different sockets,
encapsulating each data with header information (later it will used for demultiplexing) to create
segments and sending the segments to the network layer is called multiplexing.
DeMultiplexing: 

Demultiplexing is a process always performed at the receiving node. At the receiving end 
the transport layer examines these fields to identify the receiving (at socket), then directs the
segment to that socket. This task used to delivering the data in a transport layer segment to the
correct socket is called demultiplexing. At the receiver site, the situation is like one-to-many for
handling this requires demultiplexing. The transport layer receives datagrams from the network
layer. After finding out the errors and dropping of the header of packets, the transport layer has
to delivers each message to the appropriate process based on the port number.
3. Connection-Oriented Service
In Connection-oriented service, a session connection is to be established before any data send
between sender and receiver. This method is often called a reliable network service. It can guarantee
that data will be delivered. Connection-oriented services create imaginary paths between end
systems, as shown in Figure 3.4. TCP and SCTP are the connection-oriented protocols
Figure 7.3.6: Connection-Oriented Service
In the Figure 7.3.6 shows end-to-end communication. It has created a virtual path which
is represented by VP1.
4. Connectionless service
In connectionless service, does not require a session connection between sender and
receiver before data transmission. The sender simply starts sending packets (called datagrams) to
the destination. This service is an unreliable as compare to the connection-oriented method. UDP
is a connectionless protocol used in transport layer.
7.3.3 TCP Connection
TCP is a connection-oriented protocol that’s why it always establishes a virtual path
between the source and destination. For this connection-oriented transmission requires three
phases such as connection establishment, data transfer and connection termination.
1. TCP Connection Establishment
Two TCP machines are able to send data each other simultaneously only when they got
connected. This mode is called full-duplex mode. This implies that each party must initialize
communication and get approval from the other party before any data are transferred. The connection
establishment in TCP is called three-way handshaking. In Figure 7.3.7 shows the client server
application, client wants to make a connection with server, using TCP as the transport layer
protocol. The process starts with the server and readies to accept a connection that is called
passive open. The client has to make request first, that’s why it is called active open. To show
the process, uses time lines: one for client and other for server.
Figure 7.3.7: Connection Establishment using three-way handshaking
There are three steps in this phase are as follows.
1. The client sends the first segment i.e. SYN segment, in which only the SYN flag is set.
This segment is consisting of sequence numbers. It requires one sequence number; once
data transfer starts the sequence number is incremented by 1. SYN segment can’t carry
data, but it as containing 1 imaginary byte.
2. When the server sends reply the second segment it consist of a SYN and ACK segment
(2 flag bits set: SYN and ACK). This segment has two purposes. It is a SYN segment for
communication in the other direction and serves as the acknowledgment for the SYN
segment. SYN requires only one sequence number.
3. The client sends the last means third segment; this is just an ACK segment. It
acknowledges the receipt of the second segment with the ACK flag and acknowledgment
number field. It doesn’t consume any sequence number. Once the connection established
data transfer can take place. The client and server can able to send data and
acknowledgments signals. In Figure 7.3.8 shows that, after connection is established the
client sends 2000 bytes of data in two segments. The server has sent 2000 bytes in one
segment. After that, the sending one more segment. Here, we can see first three segments
carry both data and acknowledgment but the last segment not require any other
information, only an acknowledgment require because after that no more data to be sent.
Figure 7.3.8: Data Transfer
3. Connection Termination
Client or Server anyone can close the connection. Most implementations today allow threeway handshaking for connection termination. Three-Way Handshaking as shown in Figure 7.3.9.
Figure 7.3.9: Connection termination using three-way handshaking
1. Afte receiving a close command from the client process, the client TCP may send a FIN
segment in which the FIN flag is set. It is just a control segment as shown in Figure 7.3.9.
Because of control, it consumes only one sequence number.
2. After receiving the FIN segment from client TCP, the server informs its process and
sends the second segment, a FIN +ACK segment, to confirm the receipt of the FIN
segment from the client and at the same time to announce the closing of the connection in
the other direction. If it does not carry data, it consumes only one sequence number.
3. Final state at client, TCP sends the last ACK segment to confirm the receipt of the FIN
segment from the TCP server. This segment cannot carry data and consumes no sequence
numbers.
1.9 Assignment Questions:
1. Explain functionality of TCP. Explain flow control in detail
2. What is 3-way handshake in TCP? Explain why it is required?
3. Explain multiplexing and demultiplexing in transport layer?
Conclusion:
Hence we studied that how to Create TCP/IP packet using standard TCP/IP include files and
send it to the server using C++.
Download