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

Merge origin/master

parents 017a9517 622ac874
No related branches found
No related tags found
No related merge requests found
Showing
with 368 additions and 25 deletions
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MV3500Cohort2018JulySeptember.homework3.Ayres_Homework3;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.UnknownHostException;
/**
*
* @author kjayr
*/
public class AyresMulticastReceiver {
public static final String MULTICAST_ADDRESS = "239.1.2.15";
public static final int DESTINATION_PORT = 1717;
/** How many routers can be crossed */
public static final int TTL = 10;
public static void main(String[] args)
{
try
{
// This is a java/IPv6 problem. You should also add it to the
// arguments used to start the app, eg -Djava.net.preferIPv4Stack=true
// set in the "run" section of preferences. Also, typically
// netbeans must be restarted after these settings.
// https://stackoverflow.com/questions/18747134/getting-cant-assign-requested-address-java-net-socketexception-using-ehcache
System.setProperty("java.net.preferIPv4Stack", "true");
MulticastSocket multicastSocket = new MulticastSocket(DESTINATION_PORT);
multicastSocket.setTimeToLive(TTL);
InetAddress multicastAddress = InetAddress.getByName(MULTICAST_ADDRESS);
System.out.println(multicastAddress);
// Join group useful on receiving side
multicastSocket.joinGroup(multicastAddress);
// You can join multiple groups here
int count = 0;
int firstNumber = 11;
int secondNumber = 67;
int thirdNumber = 108;
int forkliftsAvail = 100;
int forkliftsServ = 0;
while(true)
{
byte[] packetArray = new byte[1500];
DatagramPacket packet = new DatagramPacket(packetArray, packetArray.length);
multicastSocket.receive(packet);
count++;
firstNumber+=1.5;
secondNumber+=3.5;
thirdNumber+=5.0;
if(count > 1){
forkliftsAvail-=1;
forkliftsServ+=1;
}
ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData());
DataInputStream dis = new DataInputStream(bais);
//float firstNumber = dis.readInt();
//float secondNumber = dis.readInt();
//float thirdNumber = dis.readInt();
System.out.println("Marine Corps Logistics Base Albany: Wilson Warehouse");
System.out.println("Order received: " + count + " NSN ID: " + firstNumber + " Xrow: " + secondNumber + " Yshelf: "+ thirdNumber +
" Forklifts Availble: " + forkliftsAvail + " Forklifts in Service: " +forkliftsServ);
System.out.println("______________________________________________________");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MV3500Cohort2018JulySeptember.homework3.Ayres_Homework3;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
/**
*
* @author kjayr
*/
public class AyresMulticastSender {
public static final String MULTICAST_ADDRESS = "239.1.2.15";
public static final int DESTINATION_PORT = 1717;
/** How many routers can be crossed */
public static final int TTL = 10;
public static void main(String[] args)
{
try
{
//int ID = 27;
//int xrow = 5;
//int yshelf = 7;
System.setProperty("java.net.preferIPv4Stack", "true");
MulticastSocket multicastSocket = new MulticastSocket(1718);
multicastSocket.setTimeToLive(TTL);
InetAddress multicastAddress = InetAddress.getByName(MULTICAST_ADDRESS);
System.out.println(multicastAddress);
// Join group useful on receiving side
multicastSocket.joinGroup(multicastAddress);
// You can join multiple groups here
// Put together a message with binary content. "ByteArrayOutputStream"
// is a java.io utility that lets us put together an array of binary
// data, which we put into the UDP packet.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
//dos.writeInt(ID);
//dos.writeInt(xrow);
//dos.writeInt(yshelf);
byte[] buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, multicastAddress, DESTINATION_PORT);
for(int idx = 0; idx < 100; idx++)
{
multicastSocket.send(packet);
Thread.sleep(1000); // Send 100, one per second
System.out.println("Sent multicast packet " + idx + " of 100");
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MV3500Cohort2018JulySeptember.homework3.Furr_Frisco_Homework3;
import MV3500Cohort2018JulySeptember.homework3.Furr_Frisco_Homework3.*;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
/**
*
* @author danielcain with credit to CDR Angelopolis
*/
public class FurrFriscoHw3Receiver {
public static final String MULTICAST_ADDRESS = "239.1.2.15";
public static final int DESTINATION_PORT = 1717;
/** How many routers can be crossed */
public static final int TTL = 10;
public static void main(String[] args)
{
try
{
System.setProperty("java.net.preferIPv4Stack", "true");
MulticastSocket multicastSocket = new MulticastSocket(DESTINATION_PORT);
multicastSocket.setTimeToLive(TTL);
InetAddress multicastAddress = InetAddress.getByName(MULTICAST_ADDRESS);
System.out.println(multicastAddress);
// Join group useful on receiving side
multicastSocket.joinGroup(multicastAddress);
// You can join multiple groups here
while(true)
{
byte[] packetArray = new byte[1500];
DatagramPacket packet = new DatagramPacket(packetArray, packetArray.length);
multicastSocket.receive(packet);
ByteArrayInputStream bais = new ByteArrayInputStream(packet.getData());
DataInputStream dis = new DataInputStream(bais);
char type = dis.readChar();
//
if (type == '1') {
int lngth = dis.readInt();
String informationLine = "Abbott says: ";
for(int i=0; i<lngth; i++) {
informationLine += dis.readChar();
}
System.out.println(informationLine);
}
if (type == '2') {
int lngth = dis.readInt();
String informationLine = "Costello says: ";
for(int i=0; i<lngth; i++) {
informationLine += dis.readChar();
}
System.out.println(informationLine);
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
}
package MV3500Cohort2018JulySeptember.homework3.Furr_Frisco_Homework3;
import MV3500Cohort2018JulySeptember.homework3.Furr_Frisco_Homework3.*;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.util.ArrayList;
import java.util.Random;
/**
*
* @author danielcain with credit to CDR Angelopolis
*/
public class FurrFriscoHw3Sender {
public static final String MULTICAST_ADDRESS = "239.1.2.15";
public static final int DESTINATION_PORT = 1717;
/**
* How many routers can be crossed
*/
public static final int TTL = 10;
public static void main(String[] args) {
try {
System.setProperty("java.net.preferIPv4Stack", "true");
MulticastSocket multicastSocket = new MulticastSocket(1718);
multicastSocket.setTimeToLive(TTL);
InetAddress multicastAddress = InetAddress.getByName(MULTICAST_ADDRESS);
System.out.println(multicastAddress);
// Join group useful on receiving side
System.out.println(multicastAddress);
// Join group useful on receiving side
multicastSocket.joinGroup(multicastAddress);
// You can join multiple groups here
// Put together a message with binary content. "ByteArrayOutputStream"
// is a java.io utility that lets us put together an array of binary
// data, which we put into the UDP packet.
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(byteOut);
int numb = 1;
int count = 0;
int count1 = 0;
ArrayList<String> abb = new ArrayList<String>();
abb.add("I'm telling you. Who's on first, What's on second, I Don't Know is on third--");
abb.add("Yes");
abb.add("Yes");
abb.add("Who");
abb.add("Who");
abb.add("Who is on first");
abb.add("I'm not asking you--I'm telling you. Who is on first.");
abb.add("That's the man's name.");
abb.add("Yes!");
ArrayList<String> cos = new ArrayList<String>();
cos.add("You know the fellows' names?");
cos.add("Well, then who's playing first?");
cos.add("I mean the fellow's name on first base");
cos.add("The fellow playin' first base");
cos.add("The guy on first base");
cos.add("Well, what are you askin' me for?");
cos.add("I'm asking you--who's on first?");
cos.add("That's who's name?");
for (int idx = 1; idx < 18; idx++) {
if (numb <= 1) {
numb += 1;
dos.writeChars("1");
dos.writeInt(abb.get(count).length() );
String x = abb.get(count);
dos.writeChars(x);
count += 1;
} else {
numb -= 1;
dos.writeChars("2");
dos.writeInt(cos.get(count1).length() );
String x = cos.get(count1);
dos.writeChars(x);
count1 += 1;
}
byte[] buffer = byteOut.toByteArray();
// Put together a packet to send
// muticast group we are sending to--not a single host
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, multicastAddress, DESTINATION_PORT);
// How fast does this go? Does UDP try to slow it down, or does
// this cause network problems? (hint: yes for an unlimited send
// rate, unlike TCP). How do you know on the receiving side
// that you haven't received a duplicate UDP packet, out of
// order packet, or dropped packet?
multicastSocket.send(packet);
byteOut.reset();
Thread.sleep(1000); // Send 100, one per second
System.out.println("Sent multicast packet " + idx + " of 17");
}
} catch (Exception e) {
System.out.println(e);
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/multicastExample1/MulticastSenderExample/src/multicastsenderexample/MulticastSenderExample.java</file>
</group>
</open-files>
</project-private>
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/multicastExample1/MulticastSenderExample/src/multicastsenderexample/MulticastSenderExample.java</file>
</group>
</open-files>
</project-private>
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/TcpExample5/WebExample/src/webexample/WebExample.java</file>
</group>
</open-files>
</project-private>
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/Users/mcgredo/projects/gitlab/NetworkedGraphicsMV3500/projects/TcpExample5/WebExample/src/webexample/WebExample.java</file>
</group>
</open-files>
</project-private>
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
</open-files>
</project-private>
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/>
</open-files>
</project-private>
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