Since I've mentioned Wireshark several times in this course already, I've decided to create a bonus
lesson to show you what the
communication between our server and our client looks like in Wireshark.
I'm going to run the first program we made - simple_tcp, and there's only one change we need to make, and
it's going to be on the client side. Instead of connecting to the loopback address,
We're going to connect to the network address of this host. To see what that address is,
I'm going to use comment prompt. I'm gonna say "ipconfig" - and here we have the address.
It's 10.0.2.15. Let's type that in.
Save the code and then open Wireshark.
I'm going to choose this adapter, and then I'm going to go back to Eclipse, run the server, and then run
the client.
When we open Wireshark, we can see our results. And I'm going to stop the capture. In the first few packets
we can see the typical TCP connection being established.
So this is called the "three way handshake".
We have a SYN packet, and then SYN acknowledgement, and then another acknowledgement.
The first packet that is actually a part of our protocol is this packet, and we can recognize it because
it has this push flag turned on. When we look at what's in the packet,
we can see this "Welcome!" message that we can recognize.
And then when we look at the length of that message, it says 10 bytes.
Let me show you what that 10 bytes actually is.
It's actually "Welcome!" and then new line - or it's like this.
One - two - three - four - five - six - seven - eight - nine - ten.
So that's the ten bytes we're transmitting in this particular packet.
Now regarding the push flag, when you go to the TCP part of the packet, we're going to look at the flags.
And it tells us right away which flags are on.
So it's the acknowledgement flag and the push flag.
All the other packets don't have the push flag, they are anyway just SYN, acknowledgement and FIN packets,
which are a regular part of any TCP connection.
Let's find our reply from the client.
It's "Thanks!"
And that's the entire communication.
So the session was opened, we sent "Welcome!" and then we sent "Thanks!" back and then we closed the socket,
which initiated the termination of the TCP connection.