Monday, March 5, 2012

WakeOnLAN and Magic Packets Explained

WakeOnLAN concept is used to Power on the system when you know its MAC address. This WakeOnLAN uses Magic Packet technology to power on the target system.

Brief note on setting up WakeOnLAN:

Let say we have two systems A and B. B wants to wakeup A remotely. So here are the steps for that

  1. Enter BIOS setup in A system. And Enable Wake on LAN option in it. (Name may be different in different systems)
  2. Now you need to enable WakeOnLAN for the NIC card also. Run the following command in A system.
    $sudo ethtool eth0 -s wol g

    Install ethtool if it is not there

    $sudo apt-get install ethtool
  3. Notedown the MAC address of A's system. ( let's say aa:bb:cc:dd:ee:ff)
  4. Install wakeonlan on B's system
    $sudo apt-get install wakeonlan


    write a script for wakeonlan ( you can have it from here).

  5. Run the following command in B's system powering off A's system:
    $wakeonlan aa:bb:cc:dd:ee:ff

That's only a four step method. Have fun.... :-)

Not satisfied with the brief one.... Okay. Read on geek, there's more for you.

Magic Packet Technology:

Previously we had a problem of remotely powering on a system. So here comes a new technology, Magic Packet Technology to solve this issue. Both IBM and AMD claim that Magic Packet Technology was their idea but thankfully we all benefit from it.

In this technology a magic packet is sent to a powered off system for waking it up. The Network Administrator or Ethernet Controller when receives a magic packet targeted to it wakes the system. This involves three steps:

  1. Magic Packet Mode Enabled
  2. Magic Packet Frame Detection
  3. Magic Packet Mode Disabled

Magic Packet Mode Enabled: Before shutting down the system, it should go to magic packet listening mode for waking up remotely. We need to change BIOS settings and Ethernet controller for making it enabled (That's what we do with Step 1 & 2). After enabling it and shutting down, the system listens for a magic packet. It wont sends any packet out. It just listens for magic packet.

Magic Packet Frame Detection: If a magic packet targeted to a system, which is in Magic Packet Listening Mode, arrives it wakes up the system.

Magic Packet Mode Disabled: The magic packet listening mode should be disabled if a magic packet is arrived or external power is on. And restore the normal network configuration.

To send a magic packet we use WakeOnLan script (Step 4 & 5).

Coming to network related issues, Magic Packet Technology and WakeOnLAN works on Data Link Layer. It uses the port 7 or 9 or ethertype.

PS: The only difference of Magic Packet from normal Ethernet packet is Magic Packet has 16 duplications of 6 byte MAC address.

That's it. Hope you enjoyed.

Do comment if you have any problem with it.

Source: Magic Packet Technology