Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MUST BE JAVA. thank you Programming Assignment : UDP Ping Client/Server program (modified form the book) Ping is a network utility tool that is used

image text in transcribedimage text in transcribed

MUST BE JAVA. thank you

Programming Assignment : UDP Ping Client/Server program (modified form the book) Ping is a network utility tool that is used to test reachability to a particular host on a TCP/IP network. It works by sending a packet to a specified host and waiting for a reply. Ping can be used for troubleshooting to test connectivity and determine response time between two IP host machines. The standard Ping program uses ICMP (Internet Control Message Protocol). However, in this project you will create a pair of Ping Client/Server program built on UDP. Your ping program is to send 10 ping messages to the target server over UDP. For each message your client is to determine and print RTT when the corresponding ping message is returned. Since UDP is an unreliable protocol a packet sent by the client or server may be lost. For this reason, the client cannot wait indefinitely for a reply to a ping message. You should have the client wait up to one second for a reply from the server; if no reply is received, the client should assume that the packet was lost and print a message accordingly. Server code: The Ping server code is given below. /** + PingServer.java */ class PingServer public static void main(String args() throws Exception { DatagramSocket serverSocket = new DatagramSocket(2014); //server will run on port #2014 byte[] receiveData = new byte[1024]; l/Processing loop while(true) { //create a random number generator for use in packet loss simulation Random random = new Random(); //create a datagram packet to hold incoming UDP packet DatagramPacket receivePacket = new DatagramPacket(receive Data, receiveData.length); // get the client message serverSocket.receive(receivePacket); String sentence = new String(receivePacket.getData(,0, receivePacket.getLength(); InetAddress IP Address = receivePacket.getAddress();//get client's IP int port = receivePacket.getPort0; //get client's port # 1/print out the clients's IP address. port number and the message System.out.println("client's port # = " + port); System.out.println("client's IP =" +IP Address); System.out.println("client's message = " +sentence); Il capitalize the message from the client String capitalizedSentence = sentence.toUpperCase(); l/simulate the packet loss int rand -random.nextInt(10);//a random number in the range of 0 to 10 // if rand is less than 4 we consider the packet lost and do not reply if (rand

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions