Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

UDP Pinger Lab

ztriger
ztriger 


see attachment as well as optional exercises Attachments Tags
Clarifications

Answers

Programming Assignment 3: UDP Pinger Lab

felo
felo 



Kindly find attached solutions tot he assignment Attachments
Assignment 3.zip (7 K) Download
Preview
{ System.err.println("In sending ping request to "+hostSig+": "+e); } byte[] receiveData = new byte[1024]; DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); try { socket.receive(receivePacket); ping = System.nanoTime()-sendTime; System.out.println(receiveData.length+" bytes from "+hostSig+": ping_seq="+seq+" time="+ping+"ns"); } catch (SocketTimeoutException e) { System.out.println("Timeout from "+hostSig); } catch (IOException e) { System.err.prin

Preview
= new DatagramPacket(buf, buf.length, clientHost, clientPort); socket.send(reply); System.out.println(" Reply sent."); } } /* * Print ping data to the standard output stream. */ private static void printData(DatagramPacket request) throws Exception { // Obtain references to the packet's array of bytes. byte[] buf = request.getData(); // Wrap the bytes in

Preview
e) { e.printStackTrace(); System.exit(-1); } finally { sk2.close(); sk3.close(); System.out.println("Receiver: sk2 closed!"); System.out.println("Receiver: sk3 closed!"); } } catch (SocketException e1) { e1.printStackTrace(); } }// END constructor // generate Ack packet public byte[] generatePacket(int ackNum){ byte[] ackNumBytes = ByteBuffer.allocate(4).putInt(ackNum).array(); // calculate checksum CRC32 checksum = new CRC32(); checksum.update(ackNumBytes); // construct

Preview
in_data.length); try { // while there are still packets yet to be received by receiver while (!isTransferComplete) { sk_in.receive(in_pkt); int ackNum = decodePacket(in_data); System.out.println("Sender: Received Ack " + ackNum); // if ack is not corrupted if (ackNum != -1){ // if duplicate ack if (base == ackNum +

Screenshots
Purchase Answer