Difference between FTP and SMTP
File Transfer Protocol (FTP):
File Transfer Protocol (FTP) is a standard protocol for transmitting files from one computer to another using simple commands. It is a simple client-server application which requires establishing two TCP connections:
1. Control Connection (Port 21)
2. Data Connection (Port 20)
Client and Server Processes:
User Interface: User who wants to transfer data interacts with the system with the user interface block and tries to set up a connection with the FTP server. If it is successful then two connections are simultaneously established:
1. Control Process
2. Data Transfer Process
Control Process: The control process maintains the control connection between the server and the client. The control connection is maintained during the entire interactive FTP session. It uses port number 21 for maintaining the connection. Through this connection, the user types a command and expects to get a response within a reasonable amount of time. As it is an interactive session the service provided by IP is minimized delay. Because command and response both are very short lines of code, the control connection uses the ASCII character set for exchanging the control data.
Data Transfer Process: The Data Transfer Process maintains the data connection between the server and the client. It uses a well-known TCP port 20 for maintaining this connection. One major difference between a data connection and with control connection is that this connection is opened and closed for each data transfer. So, if in a single session five data are transferred then this connection is opened and closed five times. As a huge amount of data may be transferred through this connection the service provided by IP has maximized throughput. Before transferring the file the client must define three parameters:
1. File Type
2. Data Structure
3. Transmission Mode
FTP can transfer one of the following file types:
ASCII file: It is the default file format. It is used for transferring text files. Each character transferred is ASCII coded. The sender transforms the character from its representation to ASCII and the receiver transforms the characters from ASCII to its representation.
EBCDIC file: If one or both ends agree then the file may be transferred using EBCDIC encoding.
Image file: It is the default file format for transferring binary files, such as an image or compiled programs etc. The file is transferred as a stream of bits without any special character encoding.
FTP can transfer file using one of the following Data Structure:
1. File Structure: This structure has no structure. The file is considered a stream of bytes. This is the default data structure.
2. Record Structure: This data structure is used if the file is considered a combination of records (as in DBMS).
3. Page Structure: This structure is used if the file is divided into several pages, each page has a page number, header and other pages-related properties. These pages can be accessed sequentially or randomly.
FTP can transfer file in one of the following modes:
1. Stream Mode: It is the default mode of data transfer. The data are delivered from FTP to TCP. TCP is responsible for chopping the data into segments of suitable length. In the case of the file structure, no end-of-file character is required at the end of the file. It is used only for closing connections. In the case of record structure, the end-of-record is appended after each record and the end-of-file is appended after the end-of-file.
2. Block Mode: Data are delivered from FTP to TCP in a set of blocks. In this case, each block is preceded by a 3-byte header. The first byte represents the block descriptor and the rest two bytes represent the size of a block.
3. Compressed Mode: For large size files compression mode is used. Normally run-length compression technique is used for data compression.
Simple Mail Transfer Protocol (SMTP):
Simple Mail Transfer Protocol (SMTP) is an ASCII based protocol. It establishes a TCP connection to port number 25 of the destination machine. Here the sending machine is known as the client and the receiving machine is known as the server.
After establishing a TCP connection, the client waits for the message to come from the server. On accepting the connection, the server sends a line of text giving its identity and telling whether it is ready to receive the mail. If it is not ready then the client releases the connection and tries again later. If the server expresses its willingness to receive the e-mail then the client sends who is the sender and who is the receiver of the e-mail.
FTP vs SMTP:
|1. FTP stands for File Transfer Protocol||1. SMTP stands for Simple Mail Transfer Protocol|
|2. It is used for the transfer of files||2. It is used for electronic mail (e-mail)|
|3. FTP is defined in RFC 959||3. SMTP is defined in RFC 821 and RFC 822|
|4. It uses FTP server to send/receive file from the remote computer.||4. It uses e-mail server to deliver the e-mail to the user's mail box.|
|5. The Default FTP Port is 21||5. The Default SMTP Port is 25|
|6. FTP can be used in the command line.||6. SMTP can't be used in the command line.|