Tuesday 14 July 2009

Internet Connection vs Me II

It kept annoying me. I started to do some more research. While I was disconnected, I can mostly ping the default gateway. But not to the other side of the router. Completely out of the blue, I got the idea that there might be another 192.168.1.1 (default gateway's ip address) sitting in the network. I even scanned the network using Angry IP scanner aka ipscan-3.0-beta4. But no interesting information. So, I browsed the Internet and found out interesting things about arp command. ARP stands for Address Resolution Protocol. In every PC's network protocol stack, ARP maintains a cache of IP address-to-media access control address mappings for future use.

When I viewed the IP to MAC address list in my PC, one MAC address is belonged to the ip address of the default gateway. At that time, I was enjoying the Internet. It's been a while and the problem came up. Then I checked the arp cache, and there was another MAC address associated with 192.168.1.1. I was not able to connect to websites at all. According to the previous experience, I repaired the connection until I got the connection back. When the connection was restored, the MAC address again became the first one.

I continued playing with the commands, arp -a and arp -d. It was confirmed that the second MAC address was the main source of the problem. Anyway that connection is shared among the tenants of the building and I have no idea which crazy bastard has that IP address. So, I have to tackle it from my part. I waited another day making sure that the first MAC address owns. And I put a static arp record at the startup linking the first MAC address to the IP address, 192.168.1.1 (The command is arp -s 192.168.1.1 xx-xx-xx-xx-xx-xx). And since then, the problem never come back.

The reason that let me connect sometimes and that barred is because of the ARP lifetime. This following explanation is from MS Technet about ARP cache.

The ARP cache

To minimize the number of broadcasts, ARP maintains a cache of IP address-to-media access control address mappings for future use. The ARP cache can contain both dynamic and static entries. Dynamic entries are added and removed automatically over time. Static entries remain in the cache until the computer is restarted.

Each dynamic ARP cache entry has a potential lifetime of 10 minutes. New entries added to the cache are timestamped. If an entry is not reused within 2 minutes of being added, it expires and is removed from the ARP cache. If an entry is used, it receives two more minutes of lifetime. If an entry keeps getting used, it receives an additional two minutes of lifetime up to a maximum lifetime of 10 minutes.

For more explanation on how arp works, please refer to the following link.
Address Resolution Protocol

No comments:

Post a Comment