Skip to content
Snippets Groups Projects
Commit e92c2e13 authored by Brutzman, Don's avatar Brutzman, Don
Browse files

Merge origin/master

parents 1bc3802c d2f85e0a
No related branches found
No related tags found
No related merge requests found
Showing
with 252 additions and 34 deletions
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
* [Homework 1 README](homework1/README.md) * [Homework 1 README](homework1/README.md)
* [Homework 2 README](homework2/README.md) * [Homework 2 README](homework2/README.md)
* [Homework 3 README](homework3/README.md) * [Homework 3 README](homework3/README.md)
* [Homework 4 README](homework4/README.md) * [Homework 4 README](homework4/README.md) (cancelled)
* [Projects README](projects/README.md)
Please see the [README.md](../../../README.md) in the parent Please see the [README.md](../../../README.md) in the parent
[assignments](../../../../assignments) directory for detailed instructions. [assignments](../../../../assignments) directory for detailed instructions.
\ No newline at end of file
package MV3500Cohort2021JulySeptember.homework2.Domonique;
import java.io.*;
import java.net.*;
/**
* Hey why not say what this thing does...
* @author Dom Hittner
*/
public class HittnerDTcpExample3Client {
/** IPv6 String constant for localhost address, similarly IPv4 127.0.0.1
* @see <a href="https://en.wikipedia.org/wiki/localhost">https://en.wikipedia.org/wiki/localhost</a>
* @see <a href="https://en.wikipedia.org/wiki/IPv6_address">https://en.wikipedia.org/wiki/IPv6_address</a>
*/
public final static String LOCALHOST = "0:0:0:0:0:0:0:1";
/**
* Program invocation, execution starts here
* @param args command-line arguments
* @throws java.lang.InterruptedException user can cancel execution
*/
public static void main(String[] args) throws InterruptedException {
// Local variables/fields
Socket socket = null;
InputStream is;
Reader isr;
BufferedReader br;
String serverMessage;
int clientLoopCount = 0;
try {
while (true)
{
clientLoopCount++; // increment at beginning of loop for reliability
System.out.println(HittnerDTcpExample3Client.class.getName() + " creating socket...");
// We request an IP to connect to ("localhost") and
// port number at that IP (2317). This establishes
// a connection to that IP in the form of a Socket
// object; the server uses a ServerSocket to wait for
// connections.
socket = new Socket(LOCALHOST, 2317); // locohost?
// Now hook everything up (i.e. set up the streams), Java style:
is = socket.getInputStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
// Read a single line written by the server. We'd
// do things a bit differently if there were many lines to be read
// from the server instead of one only.
serverMessage = br.readLine();
System.out.println("==================================================");
// System.out.print ("Client loop " + clientLoopCount + ": ");
System.out.println("I am hungry");
System.out.println("The message the server sent was: '" + serverMessage + "'");
// socket gets closed, either automatically/silently by this code (or possibly by the server)
Thread.sleep(500l); // slow things down, for example 500l (long) = 500 msec (1/2 second)
} // end while(true) // infinite loops are dangerous, be sure to kill this process!
}
catch (IOException e)
{
System.err.println("Problem with " + HittnerDTcpExample3Client.class.getName() + " networking:"); // describe what is happening
System.err.println("Error: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) {
System.err.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
finally // occurs after any other activity when shutting down
{
try {
if (socket != null)
socket.close();
} catch (IOException e) {}
// program exit: tell somebody about that happening. Likely cause: server drops connection.
System.out.println();
System.out.println(HittnerDTcpExample3Client.class.getName() + " exit");
}
}
}
\ No newline at end of file
package MV3500Cohort2021JulySeptember.homework2.Domonique;
import java.io.*;
import java.net.*;
/**
*
* @author Dom Hittner
*/
public class HittnerDTcpExampleServer {
/**
* Program invocation, execution starts here
* If already compiled, can run using console in directory ../../build/classes/ by invoking \
* java -classpath . TcpExamples.TcpExample3Server
* @param args command-line arguments
*/
public static void main(String[] args) {
try {
// ServerSocket waits for a connection from a client.
// Notice that it is outside the loop; ServerSocket
// needs to be made only once.
System.out.println(HittnerDTcpExampleServer.class.getName() + " has started..."); // it helps debugging to put this on console first
ServerSocket serverSocket = new ServerSocket(2317);
OutputStream os;
PrintStream ps;
InetAddress localAddress, remoteAddress;
int localPort, remotePort;
int serverLoopCount = 0;
// Server is up and waiting (i.e. "blocked" or paused)
// Loop, infinitely, waiting for client connections.
// Stop the program somewhere else.
while (true) {
// block until connected to a client
try (Socket clientConnectionSocket = serverSocket.accept())
{
serverLoopCount++; // increment at beginning of loop for reliability
// Now hook everything up (i.e. set up the streams), Java style:
os = clientConnectionSocket.getOutputStream();
ps = new PrintStream(os);
ps.println("okay " + serverLoopCount + " let's go to Starbucks"); // this gets sent back to client!
// Print some information locally about the Socket connection.
// This includes the port and IP numbers on both sides (the socket pair).
localAddress = clientConnectionSocket.getLocalAddress();
remoteAddress = clientConnectionSocket.getInetAddress();
localPort = clientConnectionSocket.getLocalPort();
remotePort = clientConnectionSocket.getPort();
System.out.print ("Server loop " + serverLoopCount + ": ");
// My socket pair connection looks like this, to localhost:
// Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54876 ))
// Socket pair: (( /0:0:0:0:0:0:0:1, 2317 ), ( /0:0:0:0:0:0:0:1, 54881 ))
// Why is the first IP/port the same, while the second set has different ports?
System.out.println(HittnerDTcpExampleServer.class.getName() + " socket pair showing host name, address, port:");
System.out.println(" (( " +
localAddress.getHostName() + "=" + localAddress.getHostAddress() + ", " + localPort + " ), ( " +
remoteAddress.getHostName() + "=" + remoteAddress.getHostAddress() + ", " + remotePort + " ))");
if ( localAddress.getHostName().equals( localAddress.getHostAddress()) ||
remoteAddress.getHostName().equals(remoteAddress.getHostAddress()))
System.out.println(" note HostName matches address if host has no DNS name");
// Notice the use of flush() and try w/ resources. Without
// the try w/ resources the Socket object may stay open for
// a while after the client has stopped needing this
// connection. try w/ resources explicitly ends the connection.
ps.flush();
// like it or not, you're outta here!
}
}
} catch (IOException e) {
System.err.println("Problem with " + HittnerDTcpExampleServer.class.getName() + " networking: " + e);
// Provide more helpful information to user if exception occurs due to running twice at one time
if (e instanceof java.net.BindException) {
System.err.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
}
}
...@@ -15,7 +15,12 @@ import java.net.Socket; ...@@ -15,7 +15,12 @@ import java.net.Socket;
* and open the template in the editor. * and open the template in the editor.
*/ */
/** /**
* *This is assignment 2 were I modified TCP example 3
* If server message is = "this is good bye message from Franks server" the client terminates
* Changed the local host 2318
* Changed the sleep to 1 second
* Received a message from the server "How are you doing"
* Client sends a message to the server " I'm doing well"
* @author justi * @author justi
*/ */
public class FrankClient { public class FrankClient {
...@@ -26,7 +31,7 @@ public class FrankClient { ...@@ -26,7 +31,7 @@ public class FrankClient {
/** /**
* Program invocation, execution starts here * Program invocation, execution starts here
* * If client receives m
* @param args command-line arguments * @param args command-line arguments
* @throws java.lang.InterruptedException user cancels execution * @throws java.lang.InterruptedException user cancels execution
*/ */
......
...@@ -4,16 +4,19 @@ import java.io.*; ...@@ -4,16 +4,19 @@ import java.io.*;
import java.net.*; import java.net.*;
/**
*This is assignment 2 were I modified TCP example 3
* I set sever loop count 10 and terminates after 10 loops
* sends a message to the client ""this is good bye message from Franks server"
* Sent a message to client "How are you doing"
* Receives a message from the client "I'm doing well"!
* @author justi
*/
public class FrankServer { public class FrankServer {
/**
* Program invocation, execution starts here If already compiled, can run
* using console in directory ../../build/classes/ by invoking \ java
* -classpath .TcpExamples.TcpExample3Server
*
* @param args command-line arguments
* @throws java.lang.InterruptedException user cancels execution
*/
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
try { try {
...@@ -48,7 +51,7 @@ public class FrankServer { ...@@ -48,7 +51,7 @@ public class FrankServer {
if (serverLoopCount <= 10) { // checking if the loop count <= 10 if (serverLoopCount <= 10) { // checking if the loop count <= 10
ps.println("How are you doing?"); // this gets sent back to client! ps.println("How are you doing?"); // this gets sent back to client!
} else { } else {
ps.println("this is good bye message from Franks server"); // termination after 20 messages ps.println("this is good bye message from Franks server"); // termination after 10 messages
break; // Stop server break; // Stop server
} }
// Print some information locally about the Socket connection. // Print some information locally about the Socket connection.
......
package MV3500Cohort2021JulySeptember.homework2; package MV3500Cohort2021JulySeptember.homework2.HittnerNick;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
......
package MV3500Cohort2021JulySeptember.homework2; package MV3500Cohort2021JulySeptember.homework2.HittnerNick;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
......
package MV3500Cohort2021JulySeptember.homework3.Leckie;
/**
*
* @author User
*/
public class PushTest {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
}
## Homework 3: Recording OpenDIS Network Streams ## Homework 3: Example Simulation Recording OpenDIS Network Streams
### Prior Assignment, August 2019 ### Assignment
In 2019, students worked together on a single project to check wireless multicast connectivity recently deployed on NPS campus.
See their experimental results in the [NPS Multicast Connectivity Report](../../MV3500Cohort2019JulySeptember/homework3).
### (draft) Assignment * Adapt the functionality for [OpenDIS ExampleSimulationProgram](../../../../examples/src/OpenDis7Examples/ExampleSimulationProgram.java), modifying provided code
* Result streams are recorded/saved/replayed using Wireshark or X3D-Edit.
* Adapt the functionality for OpenDIS PDU Track Sender, modifying provided code This assignment presents a Problem Prototyping opportunity.
* Result streams are recorded/saved/replayed using X3D-Edit or Wireshark. While some minimal functionality is expected, the general outline of
a networking problem and proposed solution holds great interest.
Think of it as a warmup preparation for your final project.
*Freeplay opportunity!* Pick one of the provided course example programs This is also a freeplay opportunity.
(single or multiple source files) and adapt it to demonstrate a new You have the option to pick one or more of the provided course example programs
client-server handshake protocol of interest. and adapt the source to demonstrate a new client-server handshake protocol of interest.
Be sure to provide a rationale that justifies why the networking choices you made Be sure to provide a rationale that justifies why the networking choices you made
(TCP/UDP, unicast/multicast, etc.) are the best for the problem you are addressing. (TCP/UDP, unicast/multicast, etc.) are the best for the problem you are addressing.
This assignment is also a Problem Prototyping opportunity.
While some minimal functionality is expected, the general outline of
a networking problem and proposed solution holds great interest.
Think of it as a warmup preparation for your final project.
Refer to [homework2 README](../homework2/README.md) and [assignments README](../../../README.md) Refer to [homework2 README](../homework2/README.md) and [assignments README](../../../README.md)
for further details on what specific deliverables are expected in each homework assignment. for further details on what specific deliverables are expected in each homework assignment.
Team efforts are allowed, though if you choose a team approach be sure to justify why. Team efforts are encouraged, though if you choose a team approach be sure to justify why.
This is a good warmup prior to final projects. Have fun with Java networking! This is a good warmup prior to final projects. Have fun with Java networking!
### Prior Assignment, August 2019
In 2019, students worked together on a single project to check wireless multicast connectivity recently deployed on NPS campus.
See their experimental results in the [NPS Multicast Connectivity Report](../../MV3500Cohort2019JulySeptember/homework3).
## Final Course Projects 2021JulySeptember
Create a dedicated subdirectory for each individual or team project.
Example: `SmithJones`
See the [course syllabus](../../../../MV3500NetworkedGraphicsSyllabus2021JulySeptember.pdf) for details on how to document your project.
Typical final project deliverables:
* `README.MyProject.md` providing a basic description of goals, running the project, files, etc.
* Source code, screen shots, console text log, and any other assets
* Powerpoint presentation, video capture (if you want)
These deliverables have excellent value going forward, hopefully benefiting your thesis efforts as well. Questions welcome, keep going!
# DIS Protocol Examples using Open-DIS-Java Library v7 # DIS Protocol Examples using Open-DIS-Java Library v7
All examples tested, TODO PduReaderPlayer operation still needs debugging. All examples tested, running and documented satisfactorily.
Course examples using the [Open-DIS-Java](https://github.com/open-dis/open-dis-java) library are presented in this package. Course examples using the [Open-DIS-Java](https://github.com/open-dis/open-dis-java) library are presented in this package.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment