Wake-On-LAN with IPWorks, Turn on Computers Remotely

Wake-On-LAN (WOL) is the name for the Magic Packet technology first produced by AMD. The idea is that your network card has a low power mode and monitors the network for a special packet that will wake up the machine.

This technology is essential for network administrators who need  the ability to centralize scheduled maintenance and need to be sure that all of the computers on a subnet are currently "on" to take advantage of the update

Note: This article applies to IPWorks Version 5.0. IPWorks Version 6.0 and later include Wake-On-Lan functionality built into the PING component.


Requirements:

In order to take advantage of Wake-On-LAN there are a couple important requirements.  First, you will need to have WOL capable hardware.  This includes:

  • An ATX 2.01 (or later)-compliant power supply, and an ATX motherboard w/WOL connector.
  • A WOL-compliant network card w/WOL connector as well as NIC drivers with WOL support.
  • Your BIOS must support WOL and it must be enabled.


Sound a little confusing?  Well not to worry, most new machines that are produced have all of the requirements needed for supporting WOL.  For security purposes however, Wake-On-LAN is usually disabled by default on the network driver.  You will need to enable this feature in the device manager under the network drivers power management tab.

How does IPWorks fit in?

Using the IPWorks UDP control we are able to send the Magic Packet needed in order to wake up a machine.  A Magic Packet is simply a UDP packet with a specific sequence of bytes.  The sequence is a 6 byte synchronization byte sequence (0xFFFFFFFFFFFF), followed by the primary network cards Physical Addresses (MAC address) repeated 16 times in sequence, for the machine you are attempting to wake up.  After building this packet we then broadcast it to a local subnet.

using nsoftware.IPWorks;

private void WakeUp(byte[] MacAddress, string Subnet) {

  byte[] MagicPacket = new byte[102];
  for (int i = 0; i<6; i++) 
    MagicPacket[i] = 255;
					
  for (int i = 0; i<16; i++) 
    MacAddress.CopyTo(MagicPacket, 6 + (i * MacAddress.Length));
		
  Udpport udp = new Udpport();
  udp.RemoteHost = SubnetAddress;
  udp.RemotePort = 9;
  udp.Active = true;

  udp.Send(MagicPacket);
}

That's all there is to it.  All we have to do is call this procedure with the subnet where we wish to broadcast, and the MAC address of the machine we wish to wake up:

string SubnetAddress = "255.255.255.255";
byte[] MacAddress = new byte[6] {0,1,63,109,51,25};
WakeUp(MacAddress, SubnetAddress);

On Windows machines you can find the MAC address of a computer on your network using the following command:

nbtstat -a <ip address>

More Info

More information about Wake-On-LAN can be found at the AMD website: http://www.amd.com/us-en/ConnectivitySolutions/TechnicalResources/0,,50_2334_2481,00.html.


We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.