Skip to content
Snippets Groups Projects
Commit 50519633 authored by thomascecil's avatar thomascecil
Browse files

HW 2 commit.

parent 6c0d80a7
No related branches found
No related tags found
No related merge requests found
...@@ -29,7 +29,7 @@ public class MulticastUdpReceiverCecil ...@@ -29,7 +29,7 @@ public class MulticastUdpReceiverCecil
/** /**
* Time to live: how many router-decrement levels can be crossed * Time to live: how many router-decrement levels can be crossed
*/ */
private static final int TTL = 10; private static final int TTL = 4;
private static final boolean INFINITE_READ_LOOP = true; private static final boolean INFINITE_READ_LOOP = true;
private static NetworkInterface ni; private static NetworkInterface ni;
...@@ -66,7 +66,7 @@ public class MulticastUdpReceiverCecil ...@@ -66,7 +66,7 @@ public class MulticastUdpReceiverCecil
// You can join multiple groups here // You can join multiple groups here
System.out.println("Multicast address/port: " + multicastAddress.getHostAddress() + "/" + DESTINATION_PORT); System.out.println("Multicast address/port: " + multicastAddress.getHostAddress() + "/" + DESTINATION_PORT);
System.out.println("Multicast packets received log:"); System.out.println("Come Mr Tally man, tally me bananas:");
int index, count = 0; // initialize int index, count = 0; // initialize
float firstFloat, secondFloat; float firstFloat, secondFloat;
...@@ -98,9 +98,9 @@ public class MulticastUdpReceiverCecil ...@@ -98,9 +98,9 @@ public class MulticastUdpReceiverCecil
System.out.print(" "); // prettier output formatting System.out.print(" "); // prettier output formatting
} }
System.out.print(count + ". \"" + firstCharacters + "\" "); // wrap string in quote marks System.out.print(count + ". \"" + firstCharacters + "\" "); // wrap string in quote marks
System.out.println("index=" + index + ", firstFloat=" + firstFloat + " secondFloat=" + secondFloat); System.out.println("index=" + index + ", firstFloat=" + firstFloat + " secondFloat=" + secondFloat + " bunch.");
System.out.println("MulticastReceiver loop complete."); System.out.println("Daylight come and me want to go home.");
firstCharacters.setLength(0); firstCharacters.setLength(0);
} }
} catch (IOException e) { } catch (IOException e) {
......
...@@ -35,11 +35,11 @@ public class MulticastUdpSenderCecil ...@@ -35,11 +35,11 @@ public class MulticastUdpSenderCecil
public static final int TTL = 10; public static final int TTL = 10;
/** How many packets to send prior to termination */ /** How many packets to send prior to termination */
public static final int LOOPSIZE = 20; // or maybe 20000 public static final int LOOPSIZE = 8; // or maybe 20000
/** Receiving this message causes termination /** Receiving this message causes termination
* @see <a href="https://en.wikipedia.org/wiki/Sentinel_value">https://en.wikipedia.org/wiki/Sentinel_value</a> */ * @see <a href="https://en.wikipedia.org/wiki/Sentinel_value">https://en.wikipedia.org/wiki/Sentinel_value</a> */
public static final String QUIT_SENTINEL = "QUIT QUIT QUIT!"; public static final String QUIT_SENTINEL = "Daylight come and me want to go home.";
private static NetworkInterface ni; private static NetworkInterface ni;
/** /**
...@@ -83,7 +83,7 @@ public class MulticastUdpSenderCecil ...@@ -83,7 +83,7 @@ public class MulticastUdpSenderCecil
byte[] buffer = baos.toByteArray(); byte[] buffer = baos.toByteArray();
DatagramPacket packet = new DatagramPacket(buffer, buffer.length, group/*, DESTINATION_PORT*/); DatagramPacket packet = new DatagramPacket(buffer, buffer.length, group/*, DESTINATION_PORT*/);
for (int index = 0; index < LOOPSIZE; index++) for (int index = 5; index < LOOPSIZE; index++)
{ {
// Put together an updated packet to send // Put together an updated packet to send
if (index < LOOPSIZE - 1) if (index < LOOPSIZE - 1)
...@@ -100,7 +100,7 @@ public class MulticastUdpSenderCecil ...@@ -100,7 +100,7 @@ public class MulticastUdpSenderCecil
buffer = baos.toByteArray(); buffer = baos.toByteArray();
packet.setData(buffer); packet.setData(buffer);
multicastSocket.send(packet); multicastSocket.send(packet);
System.out.println("Sent multicast packet " + (index + 1) + " of " + LOOPSIZE); System.out.println((index + 1) + " foot");
baos.reset(); baos.reset();
// How fast does this go? Does UDP try to slow it down, or does // How fast does this go? Does UDP try to slow it down, or does
...@@ -110,7 +110,7 @@ public class MulticastUdpSenderCecil ...@@ -110,7 +110,7 @@ public class MulticastUdpSenderCecil
// order packet, or dropped packet? Necessary considerations. // order packet, or dropped packet? Necessary considerations.
Thread.sleep(1000); // Send 100, one per second Thread.sleep(1000); // Send 100, one per second
} }
System.out.println("MulticastSender complete."); System.out.println("bunch.");
} }
catch(IOException | InterruptedException e) catch(IOException | InterruptedException e)
{ {
......
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