info:wake_on_lan_java
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
info:wake_on_lan_java [2008/07/05 19:38] – tomgee | info:wake_on_lan_java [2008/07/13 19:50] (current) – tomgee | ||
---|---|---|---|
Line 5: | Line 5: | ||
If your network socket still shows a green light after you've shut down computer, it probably supports Wake-on-LAN. The motherboard uses a small amount of power to monitor network traffic and look for special Wake-on-LAN packets. If it sees one, it will power up the system as if you had just pressed the on switch. | If your network socket still shows a green light after you've shut down computer, it probably supports Wake-on-LAN. The motherboard uses a small amount of power to monitor network traffic and look for special Wake-on-LAN packets. If it sees one, it will power up the system as if you had just pressed the on switch. | ||
- | Creating a Wake-on-LAN packet | + | |
+ | Creating a Wake-on-LAN packet\\ | ||
Some people are surprised how difficult it is to find out how to create a Wake-on-LAN packet. There are a few oddities about it, sure, but this guide will hopefully explain what you need to do. I'll show you how to create a simple Java program that sends a Wake-on-LAN packet to wake up a specified machine. This program can easily be translated into other languages, but Java offers the platform independence which is useful in a networked environment. | Some people are surprised how difficult it is to find out how to create a Wake-on-LAN packet. There are a few oddities about it, sure, but this guide will hopefully explain what you need to do. I'll show you how to create a simple Java program that sends a Wake-on-LAN packet to wake up a specified machine. This program can easily be translated into other languages, but Java offers the platform independence which is useful in a networked environment. | ||
- | UDP and MAC addresses | + | |
+ | UDP and MAC addresses\\ | ||
A Wake-on-LAN packet is an ordinary UDP packet which contains the MAC address of the target computer. For reasons unknown to me, the UDP packet must be 16 times larger than the byte representation of the MAC address, plus an extra 6 bytes for a header. A MAC address is usually specified as a string of hexadecimal digits, for example 00: | A Wake-on-LAN packet is an ordinary UDP packet which contains the MAC address of the target computer. For reasons unknown to me, the UDP packet must be 16 times larger than the byte representation of the MAC address, plus an extra 6 bytes for a header. A MAC address is usually specified as a string of hexadecimal digits, for example 00: | ||
Line 15: | Line 17: | ||
* The next 6 bytes are the MAC address of the target computer | * The next 6 bytes are the MAC address of the target computer | ||
* Each subsequent set of 6 bytes is also filled with the MAC address of the target computer, until the packet is full. | * Each subsequent set of 6 bytes is also filled with the MAC address of the target computer, until the packet is full. | ||
+ | |||
===== Sending the Magic Packet ===== | ===== Sending the Magic Packet ===== | ||
Line 22: | Line 25: | ||
Note that the delivery of a UDP packet is not guaranteed. You may need to send more than one Wake-on-LAN packet if you are using a busy network. | Note that the delivery of a UDP packet is not guaranteed. You may need to send more than one Wake-on-LAN packet if you are using a busy network. | ||
- | Finding out your MAC address | + | |
+ | Finding out your MAC address\\ | ||
If you are running Windows, your MAC address will be revealed when you type ipconfig /all into a command prompt. You'll be looking for a line similar to this: | If you are running Windows, your MAC address will be revealed when you type ipconfig /all into a command prompt. You'll be looking for a line similar to this: | ||
Line 65: | Line 69: | ||
---- | ---- | ||
+ | |||
+ | |||
+ | |||
Line 70: | Line 77: | ||
===== Source Code ===== | ===== Source Code ===== | ||
- | %% | + | |
import java.io.*; | import java.io.*; | ||
import java.net.*; | import java.net.*; | ||
Line 134: | Line 141: | ||
} | } | ||
- | %% | + |
info/wake_on_lan_java.1215301082.txt.gz · Last modified: 2008/07/05 19:38 by tomgee