Saturday, 2 March 2013

Game Latency (Lag), Traceroute, Zenmap and Network Troubleshooting

Gamers and computer guys are similar in a few ways.  One way i would go so far as to say this is their desire for no lag, or latency.  A website designer hates when it takes so long to load a page and a gamer hates when his "lag" is over 300 in an intense FPS.  There are many other scenarios, but I am here to tell you some of the ways i have learned to troubleshoot things like network speed, lag, latency and the like.

Before we proceed I will tell of a few necessary fundamentals you need to understand the following concepts. 

What is lag?
There are two kinds of "lag". Lag normally refers to hardware lag on the user's side such as Frames per second in a game. (FPS) or a freeze of the screen, and the spinning wheel of death on mac, or a "Glitch"

The other kind of lag, Latency, or the more understandable term: "Response time." It is the response time between the computer you are are, and the computer or server you are connected to. This also a cause of great distress for people who are particular about their internet speed. This network latency lag is what we will be talking more about.

What is the Internet really made of?
To understand what i will be telling you next you must understand this; the Internet or more properly defined in these terms, Intranet, is a globally wide connection or web of interconnected computers. (Experts, correct me if im wrong, but I think this is generally understood as the Intranet.)
Not to bore you with theory and history of the internet, but its not quite that simple. Sure, we could run cables from one computer to the next, and then from that computer to the next and so on but that would make it more big and bulky then the Internet needs to be. What is between the computers is what we are interested in. Its something most of us don't pay that much attention to. And for most of us its unnecessary but for some of us that run into problems, we want to know why they are happening, and how to solve them. 

There are hundreds of kinds of devices that lie between you, another country and a website. Plainly put, these devices comprise mostly of Switches, Routers, Domain name Servers, Your internet service provider, and large telecommunications cables that go under the sea. Or, smaller ones that go to the office or house next door.

With the continued use of the Internet Protocol Version 4, which allows only 4,294,967,296
addresses because of its addressing protocol, we couldn't just use a bunch of cables, connect everything and give every device an IP of its own. There are too many devices! We did, but we have more devices than that. So what we did next was make use of the idea of subnetworks and Local Area Networks (LAN).

 Now subnetworks is getting into a pretty complicated matter, so i will simplify. You have a main network, that is the internet, then attached to that network are smaller networks, often defined by entities such your ISP or a corporation or a hosting company, then, attached to those networks is you home LAN, your LAN has both an internal and an external IP in most cases, your router or firewall makes this possible. Your LAN gives you your very own mini-internet and each of the computers on that mini-internet have an IP address.
There is more in between you and a website, but those are normally hundreds of connections, not networks.

Heres how we can see those connections.

Traceroute is a multi-platform command line network diagnostic tool. And its named is very explicably chosen. It does what is sounds like. It traces routes. It traces routes, known as hops or nodes between the computer you are running it on, and your target. You target can be an IP address or a url such as:
You put in the the target address, run the trace, and it gives you the address (and more information) of all the nodes in between. AND LAG TIME!!! If you know what the program ping does (comment if you don't) its basically that, but it pings every node and the shows you the total ping time between you and the target address.
It is used on *NIX systems for the most part, but is open sourced and written in a language supported by all operating systems.

I use a Mac, so if you want to follow along it is included on every mac natively:

  1. Open up a window and type the following:
  2. traceroute
Let it do its work, and when its finished you should see something like this.

Starting from the top you can see the command I entered, then the program starts to give its opinion of things. It tell us that has multiple IPs, but its chooses the nearest. Thats how google works with so many people to serve and only one simple domain name.

Then it shows you each of the nodes on the route to the google server its trying to reach.
We can see at the bottom that there are a total of 12 hops from us and the server.
The last of the 3 pings is what you need to worry about. (Not sure what the other millisecond readings are. O.o)

OK, so what is this doing for me? How can it help me?
Well, lets say you were looking for a server to join for a game such as Minecraft. And you have the IP of 2 servers you are looking at. You could take those, replace with the address of the server and run the program. Run it for both of the IP's and you can see which server will have the fastest response time. Generally the server that returns the fewest hops, will be best for you. (This does not measure CPU lag that is often a cause of lag in Minecraft servers actually, this is pure network.)

Is there any GUI version of this... traceroute? Its too many numbers! Im more visual!
Your in luck. Fortunately the guys over at have created a GUI program called "zenmap" for the incredibly powerful command line program nmap. Now nmap is something quite juicy and will require another post for me to go into detail, but i think that with this background i have given you, you will be able to discover nmap for yourself (As nmap is the default function of zenmap and the traceroute is a subroutine that is just accessing that program for you.)
Download the program then I will show you how to do traceroute's in it.

This is the screen you get when you open it by default. Pretty self explanatory.

I will input the IP of my favorite Minecraft server and choose "Quick traceroute" from the Profile drop-down. Feel free to experiment with the other types of scans! (Curtain laws may apply in certain jurisdictions. ) Ask question in the comments if you like.

After the scan, this is what is returned

MORE NUMBERS!! No, wait, thats not all.
Switch to the Topology tab.

Yeah man! Now thats what im talking about!

Now, without closing the program put in a new address and run the quick traceroute scan again.
Then look at the topology map now and surprise yourself.
Now you can map out the whole internet! No, not really. It would crash your computer and you probably wouldn't see anything displayed. (I tried over 21,000 nodes once! And it froze LOL)

Oh, one more thing i forgot. In the controls toolbar, change the option so you can see latency displayed.

There are tons of other things that amazed me by just clicking around in zenmap. Go for it.

Thank you for reading, please comment and feel free to ask questions if you like.

No comments:

Post a Comment