Recently, I had to do some work with a java Server program, that ran on my laptop. It acts like a very simplified server, so gets requests for files, finds it on the hard drive, and sends the response. I wanted to measure the server’s performance, so I used http_load, a program that sends out up to 62,000 simultaneous requests to an address, gets the response and gives you useful stats like mean bytes/connection, fetches/sec, throughput, mean delay, etc…
My set up, was having the server running on my laptop, then making the request from any location on the interweb. This is where I ran into my problem, I am a Bell Sympatico ADSL subscriber, and connected to the internet via a Speedstream 6520 modem. The Speedstream acts like a router, so there’s an external IP seen to the world (the one we want), and an internal IP assigned to my laptop. The problem with this setup, is that if I feed http_load my external IP, all the requests wouldn’t be arriving on my laptop. It took me quite a bit of work, but here’s how I solved this problem. First some background info:
Router – Speedstream 6520
Server – Binded and listening on “localhost”
External IP – aa.bb.cc.dd
Internal IP – 192.168.2.10
Localhost – 127.0.0.1
So the first problem is getting the requests going to the External IP to actually reach the Internal IP (which is the one your computer has). To actually get this to happen, we must actually set up the router to do “port forwarding“. What port forwarding means, is any requests that come to aa.bb.cc.dd on port 1337 (aa.bb.cc.dd:1337), we take those requests and just pass it along directly to a specified Internal IP. You have to be thorough! So don’t forget to forward requests for BOTH TCP and UDP! Each router is different, so just look up the manual for your router and it shoudl contain instructions on how to forward IP.
Okay, so now everything is being forwarded to 127.168.2.10, but we’re not done yet. My server is binded to localhost- 127.0.0.1 – and the requests are coming into 127.168.2.10. So what we gotta do now is get those requests to come to 127.0.0.1. We do this by messing around with the hosts file.
Every OS has a hosts file. The hosts file is actually the same one used in old-school DNS servers, which is a list of addresses, with the IP it should be going to. In there, you will find “localhost” with a specified IP of 127.0.0.1 (which is how your computer KNOWS what the value of local host is… you can do a nice prank on someone, by specifying their favourite site as another IP). You then add a new entry:
127.0.0.1 192.168.2.10
Which tells the os, “if anyone tries to access 192.168.2.10, give them localhost instead!” Which is what we want! Now our server that’s sitting there patiently on 127.0.0.1, will actually get the requests from the interwebs and be able to send back a response!
One drawback. As I mentioned before, I’m using Bell Sympatico ADSL. ADSL is asynchronous DSL, which means the download and upload rates are different. Download rates tend to be VASTLY higher then upload rates, due to the fact that for more common web tasks, uploads will be minimal (usually just requests for pages). So running a server on this connection will give you an extremely slow server. But hey, it works!


No User Comments Yet. In This Post
Subscribe To This Post Comment Rss Or TrackBack URL