Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Project: Socket Programming - UDP

Objectives:

- Learn socket programming in Java: UDP

-  Cement your understanding of reliable transfer protocols

Develop a reliable transfer protocol over UDP. Focus on a Stop- and-Wait protocol.

Overview

This framework provides:

-  a template for the reliable transfer protocol implementation.

-  a testing framework, with a graphical user interface.

How to use the testing framework later in the project description.

The main goal of this project is to implement a Stop-and-wait reliable transfer protocol based on the provided template.

-  MyDataPacket,
-  MyAckPacket,
-  MyServerSocket and  
-  MySocket

The former two classes are used to handle data and ack packets, respectively. They are fully implemented. Implement the latter two classes, i.e., MyServerSocket and MySocket. These classes have the following interface:

class MySocket
{
    public MySocket(InetAddress IPAddress, int portNumber)
 
    public OutputStream getOutputStream()
}
 
class MyServerSocket
{
    public MyServerSocket(int port)
 
    public InputStream getInputStream()
}

These classes are quite similar to the TCP sockets available in Java: Socket and ServerSocket. Therefore, we make a few simplifications:

-  No connection-level multiplexing. We assume that only one client at a time connects to a MyServerSocket open at a given port. Therefore, MyServerSocket has no accept method.

Furthermore, we are not going to implement any mechanisms for opening or closing of connections.

-  Unidirectional transfer. Our sockets implement transfer of data in one direction only. To send data, MySocket must be used. To receive data, MyServerSocket is used.

Consequently, there is no getInputStream in MySocket and no getOutputSteam in MyServerSocket

A benefit of the above interface is that we can use it with all the familiar stream classes available in Java, such as DataOutputStream or BufferedReader. An example program that would use our sockets can look as follows:

// Sender (Client)
    ...
    MySocket socket = new

MySocket(InetAddress.getHostByName("somhostname.edu"), 12345);

    DataOutputStream out = new DataOutputStream(socket.getOutputStream());

    out.writeBytes("Hello world!");
    ... 

// Receiver (Server)
    ...

    MyServerSocket serverSocket = new MyServerSocket(12345);

    BufferedReader in = new BufferedReader(new

InputStreamReader(serverSocket.getInputStream()));

    String sentence = in.readLine();

    System.out.println("Received: " + sentence);
    ...

Java, Programming

  • Category:- Java
  • Reference No.:- M9716262
  • Price:- $30

Priced at Now at $30, Verified Solution

Have any Question?


Related Questions in Java

Assignment - method in our madnessthe emphasis for this

Assignment - "Method in our Madness" The emphasis for this assignment is methods with parameters. In preparation for this assignment, create a folder called Assign_3 for the DrJava projects for the assignment. A Cityscap ...

Part a specification - robot simulationpart a

PART A Specification - Robot Simulation PART A Requirements To complete this assignment you will use the supplied eclipse project Robot P1/. It is already set up to execute a simple arm movement loop which you will build ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As