1.WOL
局域网唤醒(WOL)是一种以太网或令牌环计算机网络标准,允许通过网络消息打开或唤醒远程设备。
该信息通常由在连接到相同局域网(例如智能电话)的设备上执行的程序发送到目标设备,还可以通过使用子网定向广播或WOL网关服务从另一网络发起消息。
如果被唤醒的设备正在通过Wi-Fi进行通信,则称为补充标准必须使用无线LAN唤醒(WoWLAN)
Wake-on-LAN (WoL) is an Ethernet or token ring computer networking standard that allows a computer to be turned on or awakened by a network message.
The message is usually sent to the target computer by a program executed on a device connected to the same local area network, such as a smartphone. It is also possible to initiate the message from another network by using subnet directed broadcasts or a WOL gateway service. Equivalent terms include wake on WAN, remote wake-up, power on by LAN, power up by LAN, resume by LAN, resume on LAN and wake up on LAN. If the computer being awakened is communicating via Wi-Fi, a supplementary standard called Wake on Wireless LAN (WoWLAN) must be employed.[1]
1.1 MagicPacket概述
A standard magic packet has the following basic limitations:
• Requires destination computer MAC address (also may require a SecureOn password)
• Does not provide a delivery confirmation
• May not work outside of the local network
• Requires hardware support of Wake-on-LAN on destination computer
• Most 802.11 wireless interfaces do not maintain a link in low power states and cannot receive a magic packet
The Wake-on-LAN implementation is designed to be very simple and to be quickly processed by the circuitry present on the network interface card with minimal power requirement. Because Wake-on-LAN operates below the IP protocol layer, IP addresses and DNS names are meaningless and so the MAC address is required.
1.2 MagicPacket格式
MagicPacket格式:FFFFFFFFFFFF(6个FF)+16个MAC地址(被唤醒的设备MAC) = 102byte
The magic packet is a broadcast frame containing anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer's 48-bit MAC address, for a total of 102 bytes.
1.3 MagicPacket使用
MagicPacket在局域网内使用的是广播包
The magic packet is sent on the data link layer (layer 2 in the OSI model) and when sent, is broadcast to all attached devices on a given network, using the network broadcast address; the IP-address (layer 3 in the OSI model) is not used.
MagicPacket通过传输层协议发送,通常被作为一个UDP数据包(端口0.7.9)或直接在以太网上通过EtherType 0x0842
Since the magic packet is only scanned for the string above, and not actually parsed by a full protocol stack, it could be sent as any network- and transport-layer protocol, although it is typically sent as a UDP datagram to port 0,[6] 7 or 9, or directly over Ethernet as EtherType 0x0842.[7] A connection-oriented transport-layer protocol like TCP is less suited for this task as it requires establishing an active connection before sending user data.
Subnet directed broadcasts:子网定向广播,SDB只是为了解决广播包不能出局域网的问题
Subnet directed broadcasts are treated like unicast network packets until processed by the final (local) router. This router then broadcasts the packet using layer 2 broadcast. This technique allows a broadcast to be initiated on a remote network but requires all intervening routers to forward the SDB.[10][11] When preparing a network to forward SDB packets, care must be taken to filter packets so that only desired (e.g. WoL) SDB packets are permitted — otherwise the network may become a participant in DDoS attacks such as the Smurf Attack.
Internet的情况,需要NAT配置转发规则
When sending over the Internet, and in particular where a NAT (Network Address Translator) router, as typically deployed in most homes, is involved, special settings often need to be set. For example, in the router, the computer to be controlled needs to have a dedicated IP address assigned (aka a DHCP reservation). Also, since the controlled computer will be "sleeping" except for some electricity on to part of its LAN card, typically it will not be registered at the router as having an active IP lease.