In embedded Linux systems, when a device is in a low power state such as sleep or standby, it can be awakened or powered on via the Ethernet card using Wake on LAN (WOL) technology (depending on the hardware design). Below is the corresponding demonstration:1. Execute the following command on Device A to put it into sleep mode: Configure the Ethernet card to enter WOL mode:
ethtool -s eth0 wol g
Change the device’s operational state to put it into sleep:
echo standby> /sys/power/state or echo mem> /sys/power/state
2. On Device B, after knowing the MAC address of Device A’s Ethernet card, you can wake Device A within the local area network using the following command:
ether-wake -i eth0 XX:XX:XX:XX:XX:XX
The above command sends a WOL packet to the local area network through Device B’s Ethernet port. When the corresponding MAC address’s Ethernet card is in WOL mode and receives the appropriate wake-up packet, it will wake the corresponding device.3. Regarding WOL, here is an introduction:
WOL (Wake On LAN) is a remote wake-up technology that allows a computer in a local area network to be awakened remotely by sending a special signal over the network. This signal is sent through a specially formatted data packet (commonly referred to as a “Magic Packet” or “WOL packet”). The WOL technology is applicable because most modern network cards support listening for specific messages in ultra-low power mode.
-
The WOL packet is a broadcast frame that contains the MAC address of the target computer.
-
The simplest structure of a WOL packet consists of 6 bytes of 255 (i.e., the hexadecimal representation “FF FF FF FF FF FF”), followed by the target computer’s 48-bit MAC address, repeated 16 times, making the total packet size 102 bytes (6+48/8*16). This packet can be encapsulated in any protocol, with the most common being UDP.
-
Using this technology, computers with appropriate hardware support can be awakened by software from another computer within the local area network. This software typically broadcasts a UDP packet within the local area network, with no specific port restrictions (usually ports 8 or 9), and the data content is a WOL packet with a specific format. Only the designated WOL-supported network cards will process this packet and wake the computer.