Lab 5/6/7 CS

UDP Programming in Java

Lab Objective:

  • To gain experience using Unix/Linux UDP socket programming using Java.
  • To use multicast UDP messaging
Reading/Reference: Lab overview:

Java is an important language, and syntacically VERY similar to C++. In this lab we will create a simple Java chat program to begin to learn Java, and networking in Java.

IP addressing includes multicast addresses, which all for a system to send a packet to multiple recipients. The multicast addresses are in the range through Below is an example of it's use.

Note: the JDK is not installed on most of the VMs on the lab computers. To install it, follow these instructions: LinuxJDKInstall

Sample code

1. A simple UDP sender and receiver

2. A Simple Threads Example

3. A UDP sender and receiver using a simple GUI interface

4. Sending and receiving Multicast Packets

UDP packets can be sent to any multicast address (on any port) in the through address range. The sendrer must send using a MulticastSocket() function to create the socket, and the receiver must create a socket with MulticastSocket (port), and then join the multicast group using the MulticastSocket(address) function.

5. A GUI interface Finnally, we want to use a nice GUI interface. The following reference gives a nice simple example of a GUI chat program.HOwever, this example, nice as it is, does not use UDP, does not support the use of broadcasts to find chat partners, and is a client/server type program, where as yours is a serverless system.

A Simple Chat Program With Client/Server (GUI Optional)

Using Java at the command line

To Compile: javac

To Run: Java file

Lab tasks:

The lab is worth 100 points total. Below I give you a set of requirements and options. You may do as many or few – this is a chance to get extra credit. However, no matter what you do, you will not get higher then a 100 if you do not have good clean code. Your score is dependant on the highest level of CS course you have taken.

Feature CS II Soft Dev Op Sys
Well Designed/Written Code 20 20 20
Well commented code 5 5 5
Synchronous two-way chat function (take turns typing) 30 20 10
Display username of partner. 15 10 10
Full GUI interface 10 10 10
Display "Typing" if other user typing 20 15 10
Character at a time transmission/reception 20 15 10
N-way chat 35 30 25
Asynchronous two-way chat function 40 30 25
Search for and list available partners 30 25 20
Multicast packets 5 5 5
Broadcast packets 10 10 10
MAXIMUM SCORE 240 195 155

Turn in

  1. A document listing the features you support
  2. Screen captures clearly (with headings) demonstrating each feature support above.
  3. All source code (including makefile)

Due Dates

  1. Lab 5: Oct 22 midnight: At least 30 points work from above.
  2. Lab 6: Oct 29 midnight: At least 30 points work from above.
  3. Lab 7: Nov 5 midnight: At least 40 points work from above.
Topic revision: r9 - 2015-11-17 - JimSkon
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback