Friday, January 30, 2009

Simulating Network Delay Using Linux

In a previous blog post I documented how to create a router using Linux:
http://purefinity.blogspot.com/2008/10/making-linux-router-or-gateway.html

Now that we have that setup, we can use it to emulate WAN latency using netem. If you're running a 2.6 kernel you should already have it installed.

Keep in mind that this only works for outbound traffic, so choose your network interface accordingly.

To add 100ms to all outbound traffic on eth0
tc qdisc add dev eth0 root netem delay 100ms

To check status
tc -s qdisc

To remove the delay from eth0
tc qdisc del dev eth0 root

You can also use netem to simulate packet loss, variable delay and rate control. For more information on netem:
http://www.linuxfoundation.org/en/Net:Netem

If you're looking for an easy to use tool to test throughput and latency that is more sophisticated than ping, I recommend QCheck. You can install it on two Windows machines and test between those two points, or install QCheck on a Windows machine and an Ixia Endpoint on a Linux machine. Both QCheck and the Endpoint were available for free at the time this article was written.
http://www.ixchariot.com/downloads.html

I would like to note that my first choice to emulate network latency was to use tcmon from the Windows resource kit, but I quickly found the tool to be poorly documented, unsupported on Windows Server 2003, and only provided rate control on Windows XP. It's sad when a command line tool for Linux is simpler and easier to use than a GUI tool from Microsoft.

Wednesday, January 21, 2009

Howto disable autorun in Windows XP

Handy info!

  1. Click Start
  2. Click Run
  3. Enter GPEDIT.MSC
  4. Group Policy mmc will popup. On left panel:
  5. Double-click Computer Configuration to open submenu
  6. Double-click Administrative Templates to open submenu
  7. Double-click System to open submenu
  8. Double-click Turn autoplay off option which will be near the bottom of the list in the right panel.
  9. The default is the Not configured . Set it to Enabled.

Tuesday, January 20, 2009

L4d Server Basic Howto

Here's the steps I used to setup a Left4Dead server on my Windows Server 2003 box.

Step 1: Get the files to install the source dedicated server (I used C:\srcds as my dir)
http://www.srcds.com/

Step 2: Run hldsupdatetool and agree to the terms of use etc

Step 3: Update/Install your game
C:\srcds\hldsupdatetool.exe -command update -game "left4dead" -dir C:\srcds

Step 4: Create a server.cfg file in C:\srcds\l4d\left4dead\cfg to look like the following
// server
name
hostname

// password for rcon

rcon_password ""

// Difficulty of the current game (easy, normal, hard, impossible)

z_difficulty normal


// Only allows connections from game
lobbies
sv_allow_lobby_connect_only 0


Step 5: Run the game server
C:\srcds\l4d\srcds.exe -console -game left4dead +ip -port 27015 -nohltv +sv_lan 0 +map l4d_vs_hospital01_apartment


Tips and Tricks:
  • You can control your server by joining the game from a different machine and using rcon.
    1. Open the developers console by hitting tilde (enable it from keyboard setup first)
    2. Type: rcon_password
    3. Now that you're authenticated you can disable autokick by simply typing: rcon
    4. You can also change game settings and more by typing things like: rcon sv_cheats 1
    5. To see each player's latency just type: ping
  • There are useful commands you can run from the console too!
    1. You can see when people type in the game, here's how to respond: say "blah blah"
    2. To kick a player: kick "playername"
    3. To shutdown the server: quit
  • You need a public IP address bound to your server's NIC in order to host a game, here's how to do it while keeping your home network intact.
    1. First off, there are a few requirements for what I'm about to tell you. You must have DHCP based cable or DSL without an authentication mechanism like PPPOE. You must have Windows 2000 or newer with two NICs. Your cable modem must be bridged or otherwise setup so that your NIC will be assigned the public IP address directly from your ISP upon being connected (Not NAT'd through your modem and given a private IP). You'll also need a crossover cable. Got all that? Then read on...
    2. Connect an ethernet cable from your modem to NIC1 on your server.
    3. Connect a crossover cable from NIC2 on your server to the WAN port of your router.
    4. On NIC1, Right click -> Properties -> Advanced -> Check the box for Internet Connection Sharing.
    5. Assuming your router, NIC1, and NIC2 were all set for DHCP, you should now have a server with a public IP address and your home network should still allow all the rest of your machines to access the internet. If you have problems getting the addresses assigned, trying rebooting your router and/or the server. You can also try using DHCP release/renew commands.
Happy gaming!

Tuesday, January 13, 2009

Playstation to USB Adapter for PC

Testing the Playstation to USB Controller Adapter

You can find these adapters on eBay (usually direct from Hong Kong) for less than $8 including shipping. It was so cheap, I decided to buy one and test it out. On to the tests!

The Test System:
  • MSI AM2 Motherboard
  • AMD Athlon X2 Processor
  • Windows XP SP3 (32bit)
  • PCSX2 Playground v1.0.0395 VM
  • ePSXe v1.7.0
PSX and PS2 Emulator Compatibility
If you're reading this article you're probably a ePSEe or PCSX2 user looking for an easy way to get a controller working with the emulator. You'll be happy to know this cheap little device allows you to use two Playstation controllers at once, as advertised. I was even able to use my Red Octane Guitar. HOWEVER, it did not like every controller I tested, and the driver CD they shipped with the unit didn't help. All of these controllers were first tested on my Playstation 2 console before I tested them under an emulator.


(The test equipment pile)


Hardware Compatibility
So which controllers worked and which didn't?
  • Sony PS2 Dualshock 2 (SCPH-10010) FAIL
  • Sony PSX (SCPH1080) PASS
  • Verge Micro PS2 (VGP2MCONT) PASS
  • Red Octane Guitar (PSLGH) PASS
  • Madcatz Wireless PS2 (8246) FAIL
I found that it didn't matter which emulator I tried the Dualshock 2 controller in, or how many controllers I used at once, they always failed to work properly. The wireless controller also didn't work as it wouldn't sync. Perhaps these two controllers have voltage requirements that aren't being met by the adapter? I won't have the time to research.

I should note that while the guitar worked, Rock Band doesn't run properly under PCSX2. Perhaps with some tweaking I can get the emulator to see it as a guitar and get the blank menu options to appear, but I don't have the time.

Tip: Things seem to work the best if you plug the USB cable in first, then both controllers, then start the emulator.

Other Uses:
I also found that a Playstation controller with this USB adapter works great for the following other emulators:
  • Stella v2.3.5 (Atari)
  • Project 64 v1.3 (N64)
  • FCE Ultra v0.5 (NES)
  • Snes9X v1.41-1 (SNES)
  • Gens v2.14 (Genesis)
Further Reading:

http://www.epsxe.com
http://www.pcsx2.net
http://www.ngemu.com

Saturday, January 10, 2009

AMD Athlon X2 upgrade

In a previous post, I described the Pentium 4 architecture I was using and how it appeared to be nearing obsolescence.
http://purefinity.blogspot.com/2008/12/pentium-4-architecture-becoming.html

Well with the incredibly cheap prices in 2009 (ie: $35 for 4GB of RAM) , I thought it was a good time to upgrade.





Performance testing:

AMD Athlon X2 5000, MSI K9N2GM, Powercolor Radeon HD 3850 PCI-E (688mhz clock, 747mhz RAM), 4GB DDR2 800 RAM
Left4Dead 1024x768 + low settings - 66FPS (19FPS with 8200 on-board video)
LAME MP3 Encoding w/ defaults - 22sec
7zip ultra comp + AES256 encryption - 1m15s
Doom 3 (1280x1024, Ultra Quality, 4x AA, 8x AF) - 118FPS

The Doom 3 score actually exceeded my expectations. :-)
http://www.tomshardware.com/charts/gaming-graphics-charts-q1-2008/Doom-3,560.html

Old P4 / 6600 GT AGP
Left4Dead 1024x768 + low settings - 30FPS
LAME MP3 Encoding w/ defaults - 30sec
7zip ultra compression + AES256 encryption - 1m55s

Torture testing:
System temp was 44 deg C during torture testing.

AMD Athlon X2 5000 (Highest observed temp 53 deg C - 100% util @ 2600mhz for 1 hour)
Max Temp 55-68 Deg C
http://products.amd.com/en-us/DesktopCPUDetail.aspx?id=40&f1=&f2=&f3=&f4=&f5=&f6=&f7=&f8=&f9=&f10=

ATI Radeon HD 3850 (Highest observed temp 68 deg C - 100% util @ 688mhz for 1 hour)
Max Temp Unknown, but 75 Deg C is known to be stable according to some reports
http://www.xbitlabs.com/articles/video/display/radeon-hd3870-hd3850_13.html

The motherboard chipset is on par with similar chipsets from other vendors
http://www.tomshardware.com/reviews/amd-nvidia-chipset,1972-16.html

AGP lives! The ATI 3850 AGP performs about the same speed as the 3850 PCI-E
http://www.tomshardware.com/reviews/ati-agp-3850-agp,1939-4.html

The shader seems to have issues in certain games like Left 4 Dead where reflective surfaces look magenta or oddly reflective. Hopefully this will be fixed with future drivers from ATI.

Update:
The K9N2GM motherboard (AKA K9N2GM-FD) does not support Linux when using the SATA controller. This is a shame, but thankfully I was able to run Windows XP x64 with VMware Workstation 5.5 to use my Linux applications.

I've since bought 2 more sticks of Crucial RAM, and now have 8GB of memory running in dual channel mode. So far I have not run into the 7GB limit the user manual mentions.

The processor is now running at about 2.95Ghz and is cool and stable. (226x13)

The video card was overclocked in the BIOS to run a 695Mhz GPU clock and 828Mhz memory.