class UDPClient {
publicstaticvoidmain(String args[]) throws Exception
{
//create input stream
BufferedReader inFromUser =
new BufferedReader(new InputStreamReader(System.in));
//create client socket
DatagramSocket clientSocket = new DatagramSocket();
//get the host IP address using DNS
InetAddress IPAddress = InetAddress.getByName(null);
byte[] sendData = newbyte[1024];
String ack="";
String sentence = inFromUser.readLine();
int n=sentence.length();
int loss=0;
//get the time when the client sends requestlong startTime=System.nanoTime();
//create datagram with date-to-send, length, IP address, port//segment the data into several packets.//each packet contain one byte.for(int i=0;i<n;i++){
//each datagram includes a sequence number i
String send=i+" "+ sentence.substring(i,i+1);
sendData = send.getBytes();