打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
WOL: Wake

I love tweaking my computer! Every opportunity that allows me to specify what I want makes me excited of the possibilities. (With the exception of Azureus. That's just too confusing for me!) In fact, the first thing I check after installing a new program is the possible existence of "Options," "Preferences," "Tools," "Configuration," "Settings," or "Setup!"

 

BIOS (or CMOS)

When I first became involved with computers, I started to mess around with the BIOS. It was an intriguing little 16-color control panel. I'm talking about those settings that you can change after pressing "F1," "F2," or "Delete" before the operating system starts to load.

Mysterious Wake on LAN Setting

I pretty much understood all the settings and what each one did except for this strange "Remote Wake-on-LAN." It wasn't until much later I discovered that initiating this option allows the computer to boot upon command from the network. Personally, that is ultra cool! But at the time, I really didn't have a use for it. Then came college.

College Needs

I increasingly saw a need to get a laptop. There were countless times when I needed to access my computer while on campus. Sadly, the only computers that I could use were the ones in the computer labs. I came up with a nifty idea that wouldn't cost a dime. Since I can't leave my computer on all day, why don't I use the Wake-on-LAN function to turn it on remotely and then implement a remote access setup. It would enable me to access my computer from anywhere regardless of whether it was off or on!

How it Works

Wake-on-LAN gives me the impression of an undocumented obscure little function that hardly anyone makes use of. Really, it is so simple that the lack of documentation is understandable. Essentially, enabling this function allows the network device to stay half-awake while the rest of the computer is off. It consumes a miniscule amount of electricity while constantly listening to the network. The network device waits until it receives a "magic packet" (seriously!). A magic packet is a small bundle of data consisting of the bytes "FF FF FF FF FF FF" followed by 16 repetitions of the listening network device's MAC address.

Creating the "Magic Packet"

A magic packet is fairly easy to generate. Depicus provides great freeware tools that allow you to input the parameters. Personally, I PHP programmed my server to generate the packet. I found some useful PHP WOL code from the PHP website. I modified it so that it will fit my liking. Just change the lines in the end.

PHP:
  1. <?
  2. # Wake on LAN - (c) HotKey@spr.at, upgraded by Murzik
  3. # Modified by Allan Barizo http://www.hackernotcracker.com
  4. function WakeOnLan($addr, $mac,$socket_number) {
  5.   $addr_byte = explode(':', $mac);
  6.   $hw_addr = '';
  7.   for ($a=0; $a <6; $a++) $hw_addr .= chr(hexdec($addr_byte[$a]));
  8.   $msg = chr(255).chr(255).chr(255).chr(255).chr(255).chr(255);
  9.   for ($a = 1; $a <= 16; $a++) $msg .= $hw_addr;
  10.   // send it to the broadcast address using UDP
  11.   // SQL_BROADCAST option isn't help!!
  12.   $s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
  13.   if ($s == false) {
  14.     echo "Error creating socket!\n";
  15.     echo "Error code is '".socket_last_error($s)."' - " . socket_strerror(socket_last_error($s));
  16.     return FALSE;
  17.     }
  18.   else {
  19.     // setting a broadcast option to socket:
  20.     $opt_ret = socket_set_option($s, 1, 6, TRUE);
  21.     if($opt_ret <0) {
  22.       echo "setsockopt() failed, error: " . strerror($opt_ret) . "\n";
  23.       return FALSE;
  24.       }
  25.     if(socket_sendto($s, $msg, strlen($msg), 0, $addr, $socket_number)) {
  26.       echo "Magic Packet sent successfully!";
  27.       socket_close($s);
  28.       return TRUE;
  29.       }
  30.     else {
  31.       echo "Magic packet failed!";
  32.       return FALSE;
  33.       }
  34.    
  35.     }
  36.   }
  37. // Port number where the computer is listening. Usually, any number between 1-50000 will do. Normally people choose 7 or 9.
  38. $socket_number = "7";
  39. // MAC Address of the listening computer's network device
  40. $mac_addy = "00:12:4G:SF:12:13";
  41. // IP address of the listening computer. Input the domain name if you are using a hostname (like when under Dynamic DNS/IP)
  42. $ip_addy = gethostbyname("myhomeserver.dynamicdns.org");
  43.  
  44. WakeOnLan($ip_addy, $mac_addy,$socket_number)
  45.  
  46.  
  47. ?>

Common Hurdles

There are a couple of common problems computer users come across when trying to implement Wake-on-LAN.

  • Physical Network Layer - To my knowledge, WOL will only work with Ethernet. Sorry! No Wi-fi! (Though, I heard that there are some very rare exceptions!)
  • Incompatible BIOS or network device - Sometimes the BIOS or the Ethernet Device will not support WOL. These are the two main components of Wake-on-LAN. The Ethernet detects the "magic packet" and the BIOS turns the computer on.
  • Network Infrastructure - In order for WOL to work, the "magic packet" must go through a direct, IP-address-specific route. That means if there are any routers or if your computers on the network share a public IP address then you'll need to do some port mapping when send magic packet via the Internet.

Last Tips

If you're still having trouble with WOL, try sending the magic packet to the broadcast address of the network that the listening computer is a part of. The broadcast address is the IP address prefix with 255 appended at the end. Mine is 192.168.0.255. (Just a little FYI: Everything that is directed to the broadcast address goes to every computer on the network.) Good luck!

Update: Welcome to all of the digg.com users! Thanks for digging and for coming to my site.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
遠端桌面連線--遠端開機設定
广域网远程开机(远程唤醒)
网络远程唤醒 WOL Magic Packet
远程唤醒、WOL、Magic Packet[点点论坛]
【转】兴奋中,终于可以远程开机了
linux下网络唤醒其他主机(wol)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服