Wake-On-Lan(WOL): Everything you need to know

Wake-on-LAN also known as WOL is a protocol to wake up the computer over the LAN by a network message which is called “Magic Packet”. This magic packet is sent to the MAC address of the system which we want to turn on over the network layer. It is also possible to wake the system from a different network, for that you need gateway services.

How does Wake-on-LAN Work?

The computers configured with Wake-on-LAN configuration eventually wait for the magic packet to deliver which includes the MAC address of the system and a particular message for that system. That message wakes up a sleeping computer system over the network. But, here the only condition is that the sender and the receiver must in the same network and if you want to wake the system which is located in a different network then you need to configure it using subnet directed broadcasts or WOL gateway service.

About Magic Packet in Wake-On-LAN

The magic packet is a frame that contains 6 bytes of Hexadecimal number. The magic packet is not parsed by the full protocol stack it can be sent as any network layer protocol but still it has some limitations. Once you send a magic packet, you will not get acknowledgment from the other system once it receives the frame. The MAC address of the destination system is required otherwise you won’t be able to perform Wake-on-LAN configuration.

MAC Address:

MAC address can be defined as the unique identity number of any system just like your username of twitter. Every system has one mac address which is unique and not any other system has that MAC address. To find out your system’s mac address just type ipconfig /all in the windows command-line interface and you will receive address in response. Not only computer systems but all the switches, routers, play stations, X-boxes have a unique mac address.

Node.js code for WOL

To build a computer program of WOL, you need to install a third-party package for node.js. For Linux add the following command in the terminal,

$ [sudo] npm install [-g] wol --save

If you are a windows user then add the following command in the windows command-line interface, make sure you are in the correct directory,

npm i wol –save

To build your own program, you need the mac address of the destination system where you want to send the magic packet, to get the mac just type the following command in the windows terminal,

Ipconfig /all

By typing this command, you will get MAC of the system, code

const wol = require(’wol’);
wol.wake(’20:AE:44:DE:45:CD’, err, res =>{
console.log(res);
})


What's Next?


We are currently developing our Wake-on-LAN tool from which you will be able to switch on the sleeping computer system from either a different system or your smart phone. But, our tool will only work for the systems which are connected to the same network. Not only for computers, we are also developing a tool for waking up the play station 4 and X-box from the same LAN. For more details about our tool, do check back soon in a few days.