Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Name: Trusha Neogi Date: 3/6/22

Roll No: 191105082


Branch: TE Comp

EXPERIMENT 10

TITLE: TCP/IP Protocol and SMTP Protocol implementation in Java

AIM: To implement TCP/IP Protocol followed by SMTP Protocol in Java.

THEORY: TCP/IP stands for Transmission Control Protocol/Internet Protocol and is a


suite of communication protocols used to interconnect network devices on the internet.
TCP/IP is also used as a communications protocol in a private computer network
(an intranet or extranet).

SMTP is an application layer protocol. The client who wants to send the mail opens a
TCP connection to the SMTP server and then sends the mail across the connection. The
SMTP server is an always-on listening mode. As soon as it listens for a TCP connection
from any client, the SMTP process initiates a connection through port 25. After
successfully establishing a TCP connection the client process sends the mail instantly.

Steps for implementation of TCP/IP:


Establish a Socket Connection - To connect to another machine we need a socket
connection. A socket connection means the two machines have information about each
other’s network location (IP Address) and TCP port. The java.net.Socket class
represents a Socket. To open a socket:

Socket socket = new Socket(“127.0.0.1”, 5000)

The first argument – IP address of Server. (127.0.0.1 is the IP address of localhost,


where code will run on the single stand-alone machine).

The second argument – TCP Port. (Just a number representing which application to run
on a server. For example, HTTP runs on port 80. Port number can be from 0 to 65535)

Communication - To communicate over a socket connection, streams are used to both


input and output the data.

Closing the connection - The socket connection is closed explicitly once the message to
the server is sent.

Steps for implementation of SMTP:

1. Composition of Mail

Initially, the sender composes an e-mail message with the help of a Mail User Agent
(MUA) and then transmits the e-mail. MUA helps in sending and receiving mail. The
email message consists of two parts, namely the body and the header. The body
comprises the main portion of the message, while the header comprises the subject,
which is a one-line description of what the body holds and the sender and recipient
address information.

Trusha Neogi 191105082 Batch E


2. Submission of Mail

After the document’s structure is complete, the customer utilizes the Simple Mail
Transfer Protocol and sends the completed document to the server on TCP channel 25.

3. Delivery of Mail

E-mail addresses contain the recipient’s username and the domain name. For example,
in abc@gmail.com, “abc” is the username of the receiver and “gmail.com” is the
domain name. If the recipient”s domain name is different from the sender’s domain
name, then MSA will send the letter to Mail Transfer Agent (MTA). To transmit the
email, the MTA searches for the target domain. It looks in the Domain Name
System (DNS) to find the target domain. Once the record is found, MTA connects to
the server to transmit the message.

4. Receipt and Processing of Mail

After the server receives the message, it sends it to the Mail Delivery Agent (MDA),
which keeps the e-mail until the user retrieves it.

5. Access and Retrieval of Mail

The email stored in the MDA is retrieved by logging into the MUA with the help of a
username and password of the MUA.

IMPLEMENTATION OF TCP/IP IN JAVA:

OUTPUT:

IMPLEMENTATION OF SMTP IN JAVA:

OUTPUT:

CONCLUSION: The TCP/IP and SMTP protocols were successfully implemented using
Java.

Trusha Neogi 191105082 Batch E

You might also like