PROGRAM USING UDP SOCKET

AIM:

To write a client-server application to execute the remote application using User Datagram Protocol

ALGORITHM: CLIENT

1. Include necessary package in java

2. Create a Datagram Socket and connect to the client port number 2000

3. Retrieve the IP address of the local host using InetAddress Class.

4. Construct a Datagram Packet with the remote application name to be invoked by the server.

5. Send the Packet to the server.

4. End the Communication and close the socket

5. Stop the program.

ALGORITHM: SERVER

1. Include necessary package in java

2. Create a Datagram Socket and connect to the client port number 1000

3. Construct a Datagram Packet to receive the message from the client side

4. Receive the packet from the client

5. Retrieve the remote application name from the datagram packet.

6. Create a new runtime environment and execute the application

5. Stop the program.

CLIENT-SERVER APPLICATION FOR CHAT

AIM:

To write a client-server application for chatting using Transmission Control Protocol

ALGORITHM: CLIENT

1. Start the program

2. To create a socket in client to server.

3. Create the instance for the Reader and Writer object to retrieve and post data’s to the socket

4. Retrieve the input from the client terminal and write it to the server port.

5. The client communicate the server to send the end of the message

6. Stop the program.

ALGORITHM: SERVER

1. Start the program

2. To create a socket in server to client

3. Create the instance for the Reader and Writer object to retrieve and post data’s to the socket

4. The Server listens to the connection request from the client

5. The server accept the connection from the client terminal

6. Communicate the initiation message to the client terminal to start the communication.

7. The server communicate the client to send the end of the message

8. Stop the program.

Stop and Wait Protocol

Sender:

1. Start the program.

2. Create a Socket for server and listen to the client request.

3. Create a datainputstream instance to retrieve input from the user

4. Accept the client request and initiate the communication

5. Read input stream from the user and construct the message in the form of packet

6. Transmit the first packet to the client and wait for receiver to acknowledge.

7. Once the receiver acknowledge the first packet transmit the second packet and continue until the last

8. Stop the program

Receiver

1. Start the program.

2. Create a Socket for client and initiate the request to server.

3. Create a datainputstream instance to retrieve input from the user

4. Receive the packet from the sender.

5. Send an acknowledgement for the successful recipient of each individual packets

6. Stop the program

Sliding window Protocol

Sender:

1. Start the program.

2. Create a Socket for server and listen to the client request.

3. Create a datainputstream instance to retrieve input from the user

4. Accept the client request and initiate the communication

5. Read input stream from the user and construct the message in the form of packet

6. Transmit the sequences of packet to the client until the count reaches the window size.

7. Once it reaches window size wait for the receiver to acknowledge the receiver

8. After receiving acknowledge from the receiver advance the window size forward the.

9. Continue the process until the message gets exhausted.

10. Stop the program

Receiver

1. Start the program.

2. Create a Socket for client and initiate the request to server.

3. Create a datainputstream instance to retrieve input from the user

4. Receive the packet from the sender.

5. Send an acknowledgement for the successful recipient of each individual packets and wait for a cumulative count and acknowledge once for all.

6. Stop the program

Implementation of Shortest Path Algorithm

ALGORITHM:

1. Read the no. of nodes n

2. Read the cost matrix for the path from each node to another node.

3. Initialize SOURCE to 1 and include 1

4. Compute D of a node which is the distance from source to that correspondingnode.

5. Repeat step 6 to step 8 for n-l nodes.

6. Choose the node that has not been included whose distance is minimumand include that node.

7. For every other node not included compare the distance directly from thesource with the distance to reach the node using the newly included node

8. Take the minimum value as the new distance.

9. Print all the nodes with shortest path cost from source node