You are on page 1of 43

9 ‐ TCP/IP Applications

Thursday, May 4, 2017 1:12 PM

1. TCP and UDP
Two computers ‐ one is a server and one is a client:

The whole reason we do TCP/IP is because we want to move data between computers!

A server is running some kind of server software (i.e. web server, gaming software, etc.).
The client is running some kind of client software (i.e. web client, game client, etc.).

Usually what takes place is a client makes a request and server serves. But that data has got to be right 
(videos, photos, games, etc.). There are two different protocols for this: one where the data really needs 
to be right, and one where you can throw the data at the other machine and basically hope for the best. 

TCP (Transmission Control Protocol) is the one where you need it absolutely right.

UDP (User Datagram Protocol) is the one where you basically just throw the data at the other machine.

Complete Ethernet Frame:

Network+ Page 1
If you strip away the Ethernet part (on the end) you're left with an IP packet:

If you take away the IP part, you are left with a TCP Segment:

Data | ACK | Sequence # | Port From | Port To

In regards to ACK (which is actually very complicated):

TCP is a connection‐oriented protocol so it's going to create a connection between 2 computers and 

Network+ Page 2
makes sure the data gets to the other server right and complete. It's a 3 way handshake process where 
the client and the server talk to each other and make sure the data gets there in good order.

Server and Client:

Web Server is listening on Port 80

Web client knows to send everything out on port 80 because that's what web clients do by default.

It all begins with a SYN. The Client sends a SYN over to the Server.

The server then says, "ah! Somebody wants to talk to me"
The SYN does a whole bunch of things to make sure this will work exactly right (i.e. increment the 
sequence #).
The server responds back to the client with a SYN ACK

The client gets the SYN ACK and finishes up with an ACK.

Network+ Page 3
So the client sends the server ACK and we now have a legit TCP connection. The data gets moved along. 
Then we have to close the connection/session. There are two ways to do this:
1. Nicely…the client says it got what it needed, thank you, goodbye.
2. Abruptly…if one of them gets turned off, hits a timeout, etc. then they just get disconnected 
basically.

Once the client is done, he sends a FIN statement over to the server.

Once the server sees that, it responds with a FIN ACK.

The client sees the FIN ACK and closes the connection with an ACK statement:

Once that gets to the server, it's over.

TCP is connection oriented and it's all these ACKS and FIN and FIN ACKS that allow it to take place.

UDP Datagram: you still have port to and port from, but you have 2 pieces that are different ‐ the Length
of the data and the Checksum to verify that data.

Network+ Page 4
UDP is connectionless. The server fires the data over to the client. It's fast, not much overhead. There 
are a lot of applications that need speed more than safety. For example, DHCP. DHCP uses a series of 
back and forth between a DHCP server and a DHCP client. 

When it comes to hauling traffic on the internet, you have 2 choices: TCP or UDP. Connection‐oriented 
or Connectionless.

2. ICMP and IGMP
TCP and UDP are the big heavy lifters when it comes to about all the data we haul on the internet. 
However, sometimes you don't want to send data ‐ you just want a computer to verify its status or 
something simplistic like that. In these types of situations, there are 2 protocols: 

1. Internet Control Message Protocol (ICMP): works at the IP layer of the TCP model (not the 
Transport layer). There are no port numbers ‐ ICMP has nothing to do with port numbers at all. 
There really isn't any data either. Best example of ICMP is ping. It just wants a response. With ping 
you are just saying "Hello! Are you there?" and it wants a response of "I'm here" or "I'm not here". 
Another example is ARP as we're resolving MAC addresses to IP addresses. It just wants something 
to say "Yup, that's my MAC address. Here's my IP". 

Network+ Page 5
2. Internet Group Management Protocol (IGMP): does multicast. Group Address is the multicast 
address. Source address is the address of the 

An IGMP packet: Source Address | Group Address | Checksum | Type

Multicast addresses starts with "224.xxx.xxx.xxx" and in essence you are giving your computer a 
second IP address to listen on. For example, let's say 3 computers on this network want to watch a 
certain video. They are running special video software to be able to watch it. The video server 
sends out the video on a multicast address, which the router knows to send to the 3 computers 
that want to watch the video.

Network+ Page 6
Remember: ICMP and IGMP work at Layer 3 (Network) of the OSI Model.

3. Introduction to Wireshark
In this episode, Mike introduces the concept of packet sniffing using the free third‐party packet‐
sniffer Wireshark.

From <https://hub.totalsem.com/content/2257#path=2257,2433,2436> 

Network+ Page 7
Wireshark is a protocol analyzer. It looks at every frame coming in and out of the system and allows you 
to look at them and make decisions about what's going on in your system. 

What it looks like:

The idea is that we are going to capture data and then look at that data. 

To do a capture, click on Capture > Interface (i.e. which ethernet card?) > Start

Open a web browser to get some traffic going on the network and then hit Stop when you want to stop 
capturing traffic:

Network+ Page 8
There are 3 main pieces to Wireshark:

1. Top piece shows every individual frame coming in and out of your system (green and blue)
2. Middle piece shows details about whatever frame you have highlighted (grey)
3. Lower piece shows details in raw, binary format (white)

Capture the entire DHCP transaction:
Ipconfig/release ‐‐ so he has no IP address on this system
He starts Wireshark and gets the capture going
Ipconfig/renew to get his IP address back

Use the filter tool!

Network+ Page 9
To look at DHCP info in Wireshark you have to use the alternative term, bootp

It has now filtered out everything but his DHCP stuff:

DHCP is a four step process. Here it is in wireshark:
1. DHCP Discover ‐ Mike's computer is trying to get an IP address (his source address is currently all )
s 0.0.0.0). It sends it out to a broadcast.
2. DHCP Offer ‐ Mike's computer gets a response back from a DHCP server (his router).  

Network+ Page 10
It is offering an IP address of 202.13.212.102
3. DHCP Request ‐ I'll take it! (says Mike's computer)
4. ACK ‐ the router responds, ok man I'm putting you on the list.

Wireshark is the best protocol analyzer out there.

4. Introduction to netstat
In this episode, Mike demonstrates uses for the powerful netstat command.

From <https://hub.totalsem.com/content/2257#path=2257,2433,2437> 

Who is my computer connecting to at any given moment? ‐That's what netstat does

Allows you to see what connections are established between your computer and other computers at 
any given moment.

To get to netstat: go to a command prompt, type netstat

Network+ Page 11
(what he actually typed first was cd/ then cls to clear things)

Results:

These are active connections we have right now. Each one is a separate connection.
• Local Address = pretty much always your own IP address. The part after : is your source port 
number (Ethemeral port). 
• Foreign Address = who are we connected to. Name and then the protocol (i.e. https
• State = 

Netstat ‐n

Network+ Page 12
Presents the results numerically. "Don't put nice words and stuff in there, just give me the raw 
numbers."
In his example, it shows IP addresses of the connections and that they are connected on port 443.

Port 443 is HTTPS (encrypted web traffic)

He now ran netstat ‐b as an Administrator ‐ this shows us who is making these connections.

Netstat ‐bn

Network+ Page 13
Netstat ‐bno (or just netstat ‐o) gives you the process id for every connection

Every program on your computer has a Process ID. So you can open task manager and go to details and 
find the Process ID (PID)
PID 1328 is iexplorer.exe in his example:

Netstat ‐a means show me all active ports, even the ones I don't have connections on right now

Most of the results of this that have [::] has to do with IPv6 stuff.

This example that has the Local Address 0.0.0.0:80 means that his computer is listening on Port 80. 
Which it is because he is running a web server.

Netstat ‐r shows the local routing table (it actually has nothing to do with netstat!)

Network+ Page 14
This is identical to typing in the command route print

Process Explorer and TCP View are two fantastic programs that Mike recommends. 

The important thing to know for the exam: Netstat keeps track of all the connections we have, and also 
lets us know of our listening ports. Whenever you run netstat, run it with the ‐n option so you can see 
what the port numbers are. Anytime you see a connection and don't know what the port numbers are, 
look it up! 

Netstat switches:
netstat ‐n 
netstat ‐b 
netstat ‐o 

Network+ Page 15
netstat ‐a 
netstat ‐r

5. Web Servers
In this episode, Mike takes a look at the computers that host the numberless pictures of cats that make 
up the Internet.

From <https://hub.totalsem.com/content/2257#path=2257,2433,2438> 

HTTP = Hypertext Transfer Protocol. The basis of the worldwide web. Listens on port 80.

One of these PCs is a web server and one is a web client:

A server is just software. I can run a web server on just about any equipment, it doesn't really matter. 

Primary web server software:

Network+ Page 16
1. Microsoft IIS
2. Apache (open source)

Most server programs don't actually have an interface. To see a server program, go to Task Manager > 
Processes > Service Host: Internet Information Service (2)

To make any configuration changes, you run the management software.

Here's the manager for his web server:

You can setup Authentication so that people have to login with a username and password.

Once it is setup, up and running, you tend to just let it be. There isn't much else to do.

Is there a web server running on this computer?
Network+ expects you to be able to find out if there is a web server running on a particular system. The 
best way to figure this out is to run a netstat ‐a and see if it's listening on port 80. You probably have a 
web server running on that computer if it is.

Network+ Page 17
Network+ is more interested in the client side

Most of the questions on web clients concentrate on Microsoft's Internet Explorer

Chrome, Firefox, Safari are all web clients as well.

Know that the path for almost anything in IE is Tools > Internet Options

He has wireshark running on his server. Let's access the webpage from the client and see what happens.

He filtered by http
Originating computer was 202.13.212.102
IP address for his computer is 202.13.212.104
This is where the conversation begins (it's a GET command which is getting the webpage):

The Host information is important because one web server could be hosting lots of different websites. 
Host shows which website it wants. Each website only has 1 IP address. So this example shows how 
Mike typed in 202.13.212.104

Network+ Page 18
This stuff shows how it's getting jpgs and ping and graphic files in

We're watching the entire page being sent, and eventually we get a response saying the page has been 
sent. These are "OKs" for each one of the images that are coming in:

In Wireshark you can right click on any of these and choose Follow TCP stream

When you do this you get all the HTML commands as they're being moved back and forth, put in one big 
packet.

Network+ Page 19
This is what your computer is actually reading to put together a webpage.

We used our client to make a request on port 80 to our server, and we got to watch that request come 
in and watch the server send the webpage to the client.

The problem with HTTP is that you can see everything in the clear. It is all out there.

HTTPS is needed for a secure connection, i.e. when banking. It adds a layer of security ‐ it encrypts the 
TCP stream we just looked at ‐ so that nosy people can't read it.

Let's go through the process again, but with HTTPS.

Network+ Page 20
Server is setup to use HTTPS
On the client he will type in https://[IP address]

Here's what Wireshark pulls up now:

HTTPS uses 2 different protocols:
1. SSL (old way)
2. TLS (new way)

The initial handshake, highlighted above, shows how they are setting up encryption to make HTTPS 
work. You can see that they're talking to eachother and are beginning to send data.

The data shows up as encrypted:

And when you try to follow the TCP stream you get an ugly (encrypted) mess:

Network+ Page 21
That is encrypted data and that is the beauty of HTTPS!

HTTP uses port 80.
HTTPS uses port 443.

6. FTP
In this episode, Mike discusses the venerable file transfer protocol.

From <https://hub.totalsem.com/content/2257#path=2257,2433,2439> 

Network+ Page 22
FTP = File Transfer Protocol. Predates the WWW. It is the real common way we use to transfer files, 
especially large files.

FTP Server and FTP Client

FTP does not come built into Windows (or other Operating Systems).

We need to setup the FTP server so it can begin receiving requests from clients.

When someone connects to FTP they're going to have to be in a directory, some folder on your 
computer.  We call that the Home Directory. With Filezilla, we set a particular directory (in this example, 
the desktop on his computer) and then set which permissions you want the person who logs in to have. 
To be able to upload you need to give them Write permissions. And if you want them to be able to 
create their own directories (which you usually do if they have the ability to upload)

FTP is a great place for doing file downloads. In order to do this you need to create an anonymous 
account. Anonymous accounts enable public access to FTP servers. Add > anonymous

Next, if someone logs in anonymously where do I want them to go? Go to Shared folders > Add…
Mike is pointing them to his Desktop:

Network+ Page 23
Now they can come to his desktop with permissions to Read, List, and look at subdirectories:

If you want to download a bunch of files, this is a very common thing to do. It is how you setup an 
anonymous account. Anonymous doesn't have a password.

Here's what the FTP server looks like, ready to take a response:

Network+ Page 24
WS_FTP LE is a great FTP client

FTP Clients send out requests on port 21 but FTP servers send out responses on port 20… this is a great 
example of where we would need to go into our router and setup port triggering on port 20.

Ipswitch WS_FTP LE = popular FTP client

My computer on the Left, Another computer on the Right

First thing to do is connect. Put in the Address, UserID, Password

The moment it connects, it brings you into the home directory on the server.

Network+ Page 25
Pretty much any web browser makes a pretty good ftp client as well. Just open a browser, type in 
ftp://[ip address]:

What you're looking at is your web browser has just gear shifted itself into being an FTP client. It's not as 
good as an FTP client ‐ uploading is kinda painful. BUT it's a really good way for quick and dirty 
downloads. For example: ftp://ftp.microsoft.com

Third way to do it: Windows comes with a built in FTP client ‐ it's a command prompt.

Network+ Page 26
Open cmd prompt > cls > ftp > open 202.13.212.104 > enter userID > enter password > enter ? To see 
what commands are available > type dir and it will show you all of your connections > you can now use 
commands like GET and PUT

FTP commands:
GET downloads
PUT uploads

There are a lot of ways to make FTP work from the client side but for the server side you're going to 
need an FTP server.

FTP client on the left, FTP server on the right

Let's watch an FTP capture take place over Wireshark:

Mike logged in and grabbed one file. Here's what it looks like (filteredby FTP)

Network+ Page 27
Can see the connection take place
Sent a LIST command to see what this server has to offer:

It changed directories:

We see that it transferred a file called World of Tanks.
He followed the TCP stream and we can see that the username and password are wide open and 
anybody can read them! FTP is not an encrypted protocol… FTP has no security. SFTP is secure and uses 
encryption like SSL and TLS.

Network+ Page 28
Trivial FTP (TFTP) does not have the robustness that FTP has. It uses UDP port 69.

You need a TFTP server and a TFTP client to be able to see it in action. It's pretty much identical to FTP 
but it's a lot more lightweight. 

FTP runs on port 21. Servers will respond on port 20.

7. E‐mail Servers and Clients
In this must‐see episode for all aspiring spammers out there, Mike explains the various protocols used in 
sending and receiving e‐mail.

From <https://hub.totalsem.com/content/2257#path=2257,2433,2440> 

Sending and Receiving E‐mail

Sending:
Uses Simple Mail Transfer Protocol (SMTP) over TCP port 25

Receiving:
You have 2 choices..
1. Post Office Protocol (POP) v3 ‐‐ uses TCP port 110

2. Internet Message Access Protocol (IMAP) v4 ‐‐ uses TCP port 143

Server:

Network+ Page 29
When setting up email on the server you'll be setting up the SMTP part and then you decide whether 
you'll be IMAP or POP3. 

Clients:
Then your clients will need to be configured. The clients need to know if the server is IMAP or POP3 so 
it can be configured properly. 

It is extremely common to have one piece of software that acts as both an SMTP server as well as either 
a POP3 or IMAP server.

When you're setting up a server keep this in mind: it is very popular to have one piece of software that 
acts as both an SMTP server as well as either a POP3 or IMAP server.

He created a domain called timmy.local (ours is ccmcn.com)

Next he added accounts to his domain

This is an SMTP server and it's also a POP3 server. There's no settings for it because that's all it does.

So the email server is up and running:

Network+ Page 30
Now let's take a look at the client and what we have to do to get it setup:

He's going to use Mozilla Thunderbird:

This is a self‐standing email client. Not web mail. The Network+ wants you to understand this older way 
of doing things when it comes to email.
Whenever you setup an email you will need to setup your SMTP side and your POP or IMAP side. 

Outgoing Server (SMTP):
Port 25

Network+ Page 31
He typed in the Server IP address. 

We're doing this an old school way for the Network+…Port 25 is not as secure as port 587. But we are 
using Port 25.

"SMTP protocol: smtps (port 465) v. msa (port 587)Ports 465 and 587 are intended for email client 


to email server communication ‐ sending email. SSL encryption is started automatically before any SMTP 
level communication. It is almost like standard SMTP port."

From <https://www.google.com/search?q=port+587&oq=port+587&aqs=chrome..69i57.1790j0j1
&sourceid=chrome&ie=UTF‐8> 

Incoming Server Settings:
• POP Mail Server
• Port 110

Network+ Page 32
What is the difference between POP3 and IMAP4?
• POP is very old school. Anything you have up on your server is simply copied down. Individual 
emails are copied down to your computer. On your client you can set up folders and organize your 
email, but it's just done on your client.
• IMAP is a lot like web based email where you can setup folders online and those folders are 
always there no matter where you login. So with IMAP, copies of your folder are left online unless 
you want to explicitly take them out. You can create folders that will be matched on your client. 
IMAP is more popular than POP. It's up to whoever sets up your email server which one you will 
use.

Example in Wireshark of client sending and email and the server is receiving an SMTP packet from the 
client. The server will go ahead and send it on from there. He filtered by SMTP. This shows the SMTP 
packets as they are being sent.

Server: 202.13.212.104
Client: 202.13.212.102
It goes through an authorization:

Network+ Page 33
It sends a challenge authentication:

Now it's sending the email itself:

If you follow the TCP stream you can see the email being sent over:

From dave@timmy.local
To mike@timmy.local

The email says "This is the 2nd test email"

He didn't capture the login process, but using this protocol it is totally in the clear.

Know your port numbers!:
• SMTP port 25
• POP port 110
• IMAP port 143

Network+ Page 34
8. Telnet and SSH
In this episode, Mike looks at the remote connection protocol called telnet, as well as methods for 
encrypting telnet connections via SSH.

From <https://hub.totalsem.com/content/2257#path=2257,2433,2441> 

Telnet is a remote command prompt to a far away computer. 

It allows you get to another user's command prompt via the tool telnet. Not a graphical interface like 
RDP.

There is not a telnet server built into Windows. He is going to use a telnet server called Free SSHd. Then 
we will use a telnet client called Putty on the other machine.

Telnet server side:

Network+ Page 35
Telnet needs user accounts. Create these first.

Can tell it to listen in on all your network cards or just one.

Telnet runs on TCP port 23:

Network+ Page 36
Windows comes with telnet clients but the big kahuna is PuTTY.

PuttY can be used as a tool to connect to a Telnet server:

Network+ Page 37
After he types in the IP address and "Open" it pulls this up:

Once he types in the username and password, he is connected:

Now we are looking at the command prompt of a remote computer!!!

Network+ Page 38
Telnet was the original remote connectivity tool. You don't transfer files with telnet, it's nothing 
graphical. But you can do a lot from another computer's command prompt! 

The one downside to telnet is it's in the clear! (not encrypted)

Let's take a look at telnet over Wireshark:

If you follow the TCP stream after Mike ("dave") opened a telnet connection from the client side, you 
can see the username and password. The username is repeated (it should just be "dave" not 
"ddaavvee") because telnet emulates a terminal…and this is normal for that.

We still use Telnet a lot but it's usually when we setup a direct connection to a switch or a router. We 
don't like to use Telnet over the internet itself because everything's in the clear and it's risky. What we 
do instead is use SSH. 

SSH is an encrypted version of Telnet

To appreciate SSH, let's look at the Telnet/SSH server.

Network+ Page 39
Mike turned off the Telnet server and started the SSH server:

SSH stands for Secure Shell. It looks just like Telnet but is secure. It runs on port 22.

Network+ Page 40
Let's fire up PuTTY on the client and use SSH.

Network+ Page 41
When this happens , the server sends the client a key that will encrypt everything. It's asking if you trust 
it. Hit Yes.

rlogon used TCP port 513 and did not even have a username and password (so Telnet is one step above 
this since it requires credentials).

People use telnet for logging into their routers.

Network+ Page 42
Network+ Page 43

You might also like