Browsing Socket Tools
00:00 In the previous lesson, I explained to you that the world is a messy, messy place. In this lesson, I’ll point you at some tools that you might find useful when writing programs that use the network. For completion’s sake, I’ll start by talking about the three tools you’ve seen already.
00:14
First was Wireshark, a most excellent network monitoring tool. I barely scratched the surface. It’s a powerful tool with lots of good stuff inside. Second was curl
.
00:25
curl
supports so many protocols and the fact that it still has TELNET means that you can do a lot of low-level stuff. Back in the day when I was a mail server expert, I would frequently TELNET into the SMTP port and have conversations with the machine.
00:39
SMTP is actually a text-based protocol, so once you know the commands, you can go step-by-step with the server as if you were a mail client. Sorry, netstat
doesn’t have a funky logo, but that doesn’t mean it isn’t a useful tool.
00:51 It shows you what’s going on in your network interfaces.
00:56 Another handy tool is Ping. This sends a special kind of packet to a server and asks the server to reply back. This is useful to see if a server is alive and whether you can reach it.
01:08 If your browser is misbehaving and things won’t load, dropping down to a terminal and running Ping helps you see if it’s your network or the destination server.
01:17 This is a low-level thing that interacts directly with the TCP/IP stack. My preference is to ping an IP address rather than a host name because of those complications I spoke about in the previous lesson.
01:28 First, check if you’ve got a route to the server and that the server is up before you add the variable of whether or not DNS is working. Note that not all servers will respond to a ping and some firewalls actually block them.
01:40 This is because, well, some people aren’t so nice and there are ways of creating denial -of-service-attacks using this protocol. By default, Ping keeps pinging until you Control-C.
01:50
The -c
argument is short for count and allows you to specify how many times you want to ping something. Google has a public DNS server hosted at 8.8.8.8
.
02:01 This is a good thing to know. First, it’s easy to remember, so if you just want to check if your network is up, this is as good an address to use as any. Second, Google doesn’t go down all that often, which means if you can’t ping it, the problem is likely on your end.
02:16 And third, because it’s a DNS server, if whatever DNS server you’re using is having problems, you can point your router at this one instead, as you troubleshoot what’s going on.
02:27 Traceroute is a fancier version of Ping and uses the same kind of packets. The information it gives is which routers were traversed along the way. If you’re having network issues, this might be able to identify the place upstream from you where things are falling over.
02:42 The output here is from me doing a traceroute to that same Google DNS server. It takes nine hops to get from my house to Google. Hops two through five are my hosting provider, Tech Savvy.
02:54 If this call was failing there, I’d know it was my provider. If it was failing further along, I’d know it might be a backbone problem and that usually means a good chunk of the Eastern seaboard is down.
03:03 Thankfully, that doesn’t happen too often.
03:07
Similar to the netstat
tool is LSOF. This lists all open files on your system and since in Unix, almost everything is a file including sockets, it means you can see what sockets are on your system.
03:20 This is freely available and you can find versions for Windows as well, but it isn’t always installed by default, even in Linux, so you may have to go and grab a package to get it.
03:29
The -i
argument tells LSOF to match internet files, so that means IP version four and six stuff. The -n
argument is the same as netstat
.
03:39
It means to use IP addresses rather than doing those slow reverse DNS lookups. If you’re on Windows, the TCPView tool, which is part of the Sysinternals admin stuff, is a GUI tool that shows a lot of the same kinds of information as netstat
and LSOF.
03:58 And that’s it. In the last lesson, I’ll summarize the course and point you at a few more resources you might find interesting.
Become a Member to join the conversation.