Skip to content
Snippets Groups Projects
Commit 3593f647 authored by brutzman's avatar brutzman
Browse files

Merge origin/master

parents 1f65101e a50bee47
No related branches found
No related tags found
No related merge requests found
Showing
with 254 additions and 115 deletions
No.,Time,Source,Destination,Protocol,Length,Info
1,0,172.20.154.253,239.255.255.250,IGMPv2,46,Membership Report group 239.255.255.250
2,4.494902,172.20.154.253,224.0.0.252,IGMPv2,46,Membership Report group 224.0.0.252
3,8.494797,172.20.154.253,224.0.0.251,IGMPv2,46,Membership Report group 224.0.0.251
4,13.99937,172.20.154.253,224.0.0.251,IGMPv2,46,Membership Report group 224.0.0.251
5,15.994927,172.20.154.253,224.0.0.252,IGMPv2,46,Membership Report group 224.0.0.252
6,25.531061,::1,::1,TCP,86,51554 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
7,25.531136,::1,::1,TCP,86,"2317 > 51554 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
8,25.531175,::1,::1,TCP,74,51554 > 2317 [ACK] Seq=1 Ack=1 Win=2618880 Len=0
9,25.532262,::1,::1,TCP,87,"2317 > 51554 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=13"
10,25.532282,::1,::1,TCP,74,51554 > 2317 [ACK] Seq=1 Ack=14 Win=2618880 Len=0
11,25.532322,::1,::1,TCP,76,"2317 > 51554 [PSH, ACK] Seq=14 Ack=1 Win=2618880 Len=2"
12,25.532331,::1,::1,TCP,74,51554 > 2317 [ACK] Seq=1 Ack=16 Win=2618880 Len=0
13,25.533723,::1,::1,TCP,86,51555 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
14,25.533789,::1,::1,TCP,74,"2317 > 51554 [FIN, ACK] Seq=16 Ack=1 Win=2618880 Len=0"
15,25.533794,::1,::1,TCP,86,"2317 > 51555 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
16,25.533856,::1,::1,TCP,74,51554 > 2317 [ACK] Seq=1 Ack=17 Win=2618880 Len=0
17,25.533863,::1,::1,TCP,74,51555 > 2317 [ACK] Seq=1 Ack=1 Win=327168 Len=0
18,25.53414,::1,::1,TCP,88,"2317 > 51555 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=14"
19,25.534158,::1,::1,TCP,74,51555 > 2317 [ACK] Seq=1 Ack=15 Win=327168 Len=0
20,25.534184,::1,::1,TCP,76,"2317 > 51555 [PSH, ACK] Seq=15 Ack=1 Win=2618880 Len=2"
21,25.534194,::1,::1,TCP,74,51555 > 2317 [ACK] Seq=1 Ack=17 Win=327168 Len=0
22,25.534318,::1,::1,TCP,74,"2317 > 51555 [FIN, ACK] Seq=17 Ack=1 Win=2618880 Len=0"
23,25.534336,::1,::1,TCP,74,51555 > 2317 [ACK] Seq=1 Ack=18 Win=327168 Len=0
24,25.534912,::1,::1,TCP,86,51556 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
25,25.534994,::1,::1,TCP,86,"2317 > 51556 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
26,25.535033,::1,::1,TCP,74,51556 > 2317 [ACK] Seq=1 Ack=1 Win=2618880 Len=0
27,25.535278,::1,::1,TCP,93,"2317 > 51556 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=19"
28,25.535304,::1,::1,TCP,74,51556 > 2317 [ACK] Seq=1 Ack=20 Win=2618880 Len=0
29,25.535344,::1,::1,TCP,76,"2317 > 51556 [PSH, ACK] Seq=20 Ack=1 Win=2618880 Len=2"
30,25.535357,::1,::1,TCP,74,51556 > 2317 [ACK] Seq=1 Ack=22 Win=2618880 Len=0
31,25.535502,::1,::1,TCP,74,"2317 > 51556 [FIN, ACK] Seq=22 Ack=1 Win=2618880 Len=0"
32,25.535517,::1,::1,TCP,74,51556 > 2317 [ACK] Seq=1 Ack=23 Win=2618880 Len=0
33,25.536018,::1,::1,TCP,86,51557 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
34,25.53607,::1,::1,TCP,86,"2317 > 51557 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
35,25.536106,::1,::1,TCP,74,51557 > 2317 [ACK] Seq=1 Ack=1 Win=327168 Len=0
36,25.536311,::1,::1,TCP,81,"2317 > 51557 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=7"
37,25.536333,::1,::1,TCP,74,51557 > 2317 [ACK] Seq=1 Ack=8 Win=327168 Len=0
38,25.536374,::1,::1,TCP,76,"2317 > 51557 [PSH, ACK] Seq=8 Ack=1 Win=2618880 Len=2"
39,25.536389,::1,::1,TCP,74,51557 > 2317 [ACK] Seq=1 Ack=10 Win=327168 Len=0
40,25.536546,::1,::1,TCP,74,"2317 > 51557 [FIN, ACK] Seq=10 Ack=1 Win=2618880 Len=0"
41,25.536563,::1,::1,TCP,74,51557 > 2317 [ACK] Seq=1 Ack=11 Win=327168 Len=0
42,25.540671,::1,::1,TCP,74,"51557 > 2317 [RST, ACK] Seq=1 Ack=11 Win=0 Len=0"
43,25.540928,::1,::1,TCP,74,"51554 > 2317 [RST, ACK] Seq=1 Ack=17 Win=0 Len=0"
44,25.54098,::1,::1,TCP,74,"51555 > 2317 [RST, ACK] Seq=1 Ack=18 Win=0 Len=0"
45,25.541016,::1,::1,TCP,74,"51556 > 2317 [RST, ACK] Seq=1 Ack=23 Win=0 Len=0"
56,38.295834,::1,::1,TCP,86,51563 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
57,38.295874,::1,::1,TCP,86,"2317 > 51563 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
58,38.29594,::1,::1,TCP,74,51563 > 2317 [ACK] Seq=1 Ack=1 Win=2618880 Len=0
59,38.296716,::1,::1,TCP,87,"2317 > 51563 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=13"
60,38.296732,::1,::1,TCP,74,51563 > 2317 [ACK] Seq=1 Ack=14 Win=2618880 Len=0
61,38.296788,::1,::1,TCP,76,"2317 > 51563 [PSH, ACK] Seq=14 Ack=1 Win=2618880 Len=2"
62,38.296799,::1,::1,TCP,74,51563 > 2317 [ACK] Seq=1 Ack=16 Win=2618880 Len=0
63,38.297568,::1,::1,TCP,86,51564 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
64,38.297623,::1,::1,TCP,86,"2317 > 51564 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
65,38.297667,::1,::1,TCP,74,"2317 > 51563 [FIN, ACK] Seq=16 Ack=1 Win=2618880 Len=0"
66,38.297672,::1,::1,TCP,74,51564 > 2317 [ACK] Seq=1 Ack=1 Win=2618880 Len=0
67,38.297712,::1,::1,TCP,74,51563 > 2317 [ACK] Seq=1 Ack=17 Win=2618880 Len=0
68,38.297926,::1,::1,TCP,88,"2317 > 51564 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=14"
69,38.297942,::1,::1,TCP,74,51564 > 2317 [ACK] Seq=1 Ack=15 Win=2618880 Len=0
70,38.297967,::1,::1,TCP,76,"2317 > 51564 [PSH, ACK] Seq=15 Ack=1 Win=2618880 Len=2"
71,38.297976,::1,::1,TCP,74,51564 > 2317 [ACK] Seq=1 Ack=17 Win=2618880 Len=0
72,38.298085,::1,::1,TCP,74,"2317 > 51564 [FIN, ACK] Seq=17 Ack=1 Win=2618880 Len=0"
73,38.2981,::1,::1,TCP,74,51564 > 2317 [ACK] Seq=1 Ack=18 Win=2618880 Len=0
74,38.298642,::1,::1,TCP,86,51565 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
75,38.298697,::1,::1,TCP,86,"2317 > 51565 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
76,38.298719,::1,::1,TCP,74,51565 > 2317 [ACK] Seq=1 Ack=1 Win=327168 Len=0
77,38.29896,::1,::1,TCP,93,"2317 > 51565 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=19"
78,38.298978,::1,::1,TCP,74,51565 > 2317 [ACK] Seq=1 Ack=20 Win=327168 Len=0
79,38.299006,::1,::1,TCP,76,"2317 > 51565 [PSH, ACK] Seq=20 Ack=1 Win=2618880 Len=2"
80,38.299015,::1,::1,TCP,74,51565 > 2317 [ACK] Seq=1 Ack=22 Win=327168 Len=0
81,38.299293,::1,::1,TCP,74,"2317 > 51565 [FIN, ACK] Seq=22 Ack=1 Win=2618880 Len=0"
82,38.299313,::1,::1,TCP,74,51565 > 2317 [ACK] Seq=1 Ack=23 Win=327168 Len=0
83,38.299545,::1,::1,TCP,86,51566 > 2317 [SYN] Seq=0 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1
84,38.299594,::1,::1,TCP,86,"2317 > 51566 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=65475 WS=256 SACK_PERM=1"
85,38.299633,::1,::1,TCP,74,51566 > 2317 [ACK] Seq=1 Ack=1 Win=2618880 Len=0
86,38.299887,::1,::1,TCP,81,"2317 > 51566 [PSH, ACK] Seq=1 Ack=1 Win=2618880 Len=7"
87,38.29991,::1,::1,TCP,74,51566 > 2317 [ACK] Seq=1 Ack=8 Win=2618880 Len=0
88,38.299946,::1,::1,TCP,76,"2317 > 51566 [PSH, ACK] Seq=8 Ack=1 Win=2618880 Len=2"
89,38.29996,::1,::1,TCP,74,51566 > 2317 [ACK] Seq=1 Ack=10 Win=2618880 Len=0
90,38.300102,::1,::1,TCP,74,"2317 > 51566 [FIN, ACK] Seq=10 Ack=1 Win=2618880 Len=0"
91,38.300119,::1,::1,TCP,74,51566 > 2317 [ACK] Seq=1 Ack=11 Win=2618880 Len=0
92,38.30487,::1,::1,TCP,74,"51563 > 2317 [RST, ACK] Seq=1 Ack=17 Win=0 Len=0"
93,38.304926,::1,::1,TCP,74,"51564 > 2317 [RST, ACK] Seq=1 Ack=18 Win=0 Len=0"
94,38.304957,::1,::1,TCP,74,"51565 > 2317 [RST, ACK] Seq=1 Ack=23 Win=0 Len=0"
95,38.304989,::1,::1,TCP,74,"51566 > 2317 [RST, ACK] Seq=1 Ack=11 Win=0 Len=0"
......@@ -3,8 +3,9 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MV3500Cohort2019JulySeptember.homework2;
package MV3500Cohort2019JulySeptember.homework2.McCann;
import MV3500Cohort2019JulySeptember.homework2.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
......
File added
......@@ -3,8 +3,9 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package MV3500Cohort2019JulySeptember.homework2;
package MV3500Cohort2019JulySeptember.homework2.McCann;
import MV3500Cohort2019JulySeptember.homework2.*;
import java.io.*;
import java.net.*;
import java.util.Scanner;
......@@ -35,13 +36,14 @@ public class McCannServer {
while (true) {
// block until connected to a client
try (Socket clientConnection = serverSocket.accept()) {
try (Socket clientConnection = serverSocket.accept()) {
// Now hook everything up (i.e. set up the streams), Java style:
os = clientConnection.getOutputStream();
ps = new PrintStream(os);
Scanner keyboard = new Scanner(System.in);
ps.println("What is your name?"); // this gets sent back to client!
//tried to add an input but couldn't get it to work
//String message = keyboard.nextLine();
// ps.println(message);
......
......@@ -4,19 +4,15 @@ import java.io.*;
import java.net.*;
/**
* Before, we always used telnet (netcat) to connect to the server. Here we are
* now writing our own program to do the connection.
* This is a client program that establishes a socket connection to a dispatch
* server, then it sends a simple math equation to be solved.
*
* As you will see, when we run this after we start the server we will see the
* same string telnet printed, sent by the server. The output at the server will
* show different socket pairs for each time the loop iterates.
*
* @author mcgredo
* @author Schutt
*/
public class SchuttClient {
// IPv6 String constant for localhost address, similarly IPv4 127.0.0.1
public final static String LOCALHOST = "0:0:0:0:0:0:0:1";
public static void main(String[] args) {
......@@ -28,17 +24,24 @@ public class SchuttClient {
OutputStream os;
PrintStream ps;
String serverMessage;
String[] equations = new String[4];
equations[0] = "1 + 1";
equations[1] = "2 + 2";
equations[2] = "2 * 2";
equations[3] = "3 * 3";
int index = 1;
try {
while (true) {
System.out.println("SchuttClient creating socket...");
for(String eq : equations) {
System.out.println("SchuttClient creating socket #" + index + "...");
// 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?
socket = new Socket("localhost", 2317); // locohost?
// Now hook everything up (i.e. set up the streams), Java style:
// ** Added an output stream to the client so it can send a message to the server
......@@ -55,9 +58,13 @@ public class SchuttClient {
System.out.println("==================================================");
System.out.println("Now we're talking!");
System.out.println("The message the server sent was: '" + serverMessage + "'");
ps.println("Who's there?"); // Sends a message to the server
// socket gets closed, either automatically/silently by this code (or possibly by the server)
ps.println(eq);
serverMessage = br.readLine();
System.out.println(serverMessage);
System.out.println("===================================================");
index++;
} // end while(true)
} catch (IOException e) {
System.err.println("Problem with SchuttServerClient networking:"); // describe what is happening
......@@ -70,7 +77,7 @@ public class SchuttClient {
} finally {
// program exit: tell somebody about that
System.out.println("\nclient exit");
}
}
}
assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttClient.png

662 KiB

package MV3500Cohort2019JulySeptember.homework2.Schutt;
import java.io.*;
import java.net.*;
/**
* Very slightly more complex than example1, further modifying example2. The
* only thing this does differently is introduce a loop into the response, so
* you don't have to restart the program after one response. Also, it prints out
* the socket pair the server sees. Run the program via telnet several times and
* compare the socket pairs.
*
* telnet (nc) localhost 2317
*
* If you're sophisticated you can contact the instructor's computer while
* running this program.
*
* telnet (nc) [ipNumberOfServerLaptop] 2317
*
* and have the instructor display the socket pairs received.
*
* @author mcgredo
*/
public class SchuttServer {
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("SchuttServer has started..."); // it helps debugging to put this on console first
ServerSocket serverSocket = new ServerSocket(2317);
OutputStream os;
PrintStream ps;
InputStream is;
InputStreamReader isr;
BufferedReader br;
String clientResponse;
InetAddress localAddress, remoteAddress;
int localPort, remotePort;
// 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 clientConnection = serverSocket.accept()) {
// Now hook everything up (i.e. set up the streams), Java style:
// Added an input stream to gather the message sent from the client
os = clientConnection.getOutputStream();
is = clientConnection.getInputStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
ps = new PrintStream(os);
ps.println("Knock Knock!"); // this gets sent back to client!
// Assigns the client message to a string
clientResponse = br.readLine();
// Print some information locally about the Socket connection.
// This includes the port and IP numbers on both sides (the socket pair).
localAddress = clientConnection.getLocalAddress();
remoteAddress = clientConnection.getInetAddress();
localPort = clientConnection.getLocalPort();
remotePort = clientConnection.getPort();
// 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("SchuttServer socket pair: (( " + localAddress.toString() + ", " + localPort + " ), ( "
+ remoteAddress.toString() + ", " + remotePort + " ))");
// Prints the message sent from the client
System.out.println("++++++++++++++++++++++++++++++++++++");
System.out.println("Client Response: " + clientResponse);
System.out.println("====================================");
// 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 SchuttServer 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!");
}
}
}
}
assignments/src/MV3500Cohort2019JulySeptember/homework2/Schutt/SchuttServer.png

818 KiB

package MV3500Cohort2019JulySeptember.homework2.Schutt;
import java.io.IOException;
import java.net.*;
/**
* Very slightly more complex than example1, further modifying example2. The
* only thing this does differently is introduce a loop into the response, so
* you don't have to restart the program after one response. Also, it prints out
* the socket pair the server sees. Run the program via telnet several times and
* compare the socket pairs.
*
* telnet (nc) localhost 2317
*
* If you're sophisticated you can contact the instructor's computer while
* running this program.
*
* telnet (nc) [ipNumberOfServerLaptop] 2317
*
* and have the instructor display the socket pairs received.
*
* @author Schutt
*/
public class SchuttServerDispatcher {
public static void main(String[] args) // execution starts here
{
try{
ServerSocket serverSocket = new ServerSocket(2317);
int connectionCount = 0;
System.out.println("SchuttServerDispatcher ready to accept socket connections...");
while(true){
Socket clientConnection = serverSocket.accept();
connectionCount++;
System.out.println("========================================================");
System.out.println("SchuttServerDispatcher.handlerThread invocation for connection #" + connectionCount + "...");
SchuttThreadHandler handlerThread = new SchuttThreadHandler(clientConnection);
handlerThread.start();
System.out.println("SchuttServerDispatcher.handlerThread is launched, awaiting next connection...");
}
} catch (IOException e){
System.out.println("Problem with SchuttServerDispatcher networking:");
System.out.println("Error: " + e);
if(e instanceof java.net.BindException){
System.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
System.out.println("=============================================================");
}
}
package MV3500Cohort2019JulySeptember.homework2.Schutt;
import java.io.*;
import java.net.*;
/**
* A program that handles all logic associated with one socket connection by
* running in a thread of its own. This is the server portion as well, so we
* artificially invent what happens if the server can't respond to a connection
* for several seconds. Warning: do not run this class! It is created
* automatically by TcpExample4DispatchServer.
*
* @author Schutt
*/
public class SchuttThreadHandler extends Thread {
/**
* The socket connection to a client
*/
Socket socket;
int num1;
int num2;
int output;
/**
* The thread constructor creates the socket from a ServerSocket, and passes
* one to the thread responsible for handling the connection.
*
* @param socket The socket connection handled by this thread
*/
public SchuttThreadHandler(Socket socket) {
this.socket = socket;
}
/**
* Handles one connection. We add an artificial slowness to handling the
* connection with a sleep(). This means the client won't see a server
* connection response for ten seconds (default).
*/
// @overriding run() method in Java Thread class is deliberate
@Override
public void run() {
try {
System.out.println("SchuttThreadHandler starting to handle a thread...");
// get the connection output stream, then wait a period of time.
OutputStream os = socket.getOutputStream();
PrintStream ps = new PrintStream(os);
InputStream is = socket.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
ps.println("Please send your equation!");
String clientInput = br.readLine();
System.out.println("The Client's equation is: " + clientInput);
if(clientInput.contains("+")){
num1 = (int)clientInput.charAt(0);
num2 = (int)clientInput.charAt(4);
System.out.println(num1 + " " + num2);
output = num1 + num2;
}
if(clientInput.contains("*")){
num1 = (int)clientInput.charAt(0);
num2 = (int)clientInput.charAt(4);
output = num1 * num2;
}
System.out.println("The Client's answer is: " + output);
ps.println("The answer to your equation is: " + output);
ps.flush();
socket.close();
} catch (IOException e) // either a networking or a threading problem
{
System.out.println("Problem with TcpExample4HandlerThread networking:"); // describe what is happening
System.out.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.out.println("*** Be sure to stop any other running instances of programs using this port!");
}
}
}
}
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