wol 本质也是一个网络包,用于局域网内部唤醒只用。
WOL 包分析
使用工具Wake On Lan 配置wol.mac 地址,ip.mac 地址(255.255.255.255),然后出发一下。
使用Wireshark抓取刚刚的WOL 包
可以看到服务端发出的这个包的大小为144 byte,下面我们
看看包里面有哪些字段。
- destination broadcast( eth.dst)
占用6 个字节
- source hardware address(eth.src)
占用6个字节
- Type(eth.type)
占用两个字节,当前为ipv4
- Version & Header Length (ip.version & ip.hdr_len)
版本是4,长度是5
- Differentiated Service Field (ip.dsfired)
占据1个字节
- Total Length(ip.len)
占据2个字节,值为130
- Identification (ip.id)
占据2个字节
- Fragement offset(ip.frag_offset)
占2个字节 - Time to live(tp.ttl)
占1个字节 - Protocol (ip.proto)
占1个字节
- Header checksum(ip.checksum.status)
占2个字节 - Source(ip.src)
占4个字节
- Destination (ip.dst)
占4个字节
- Source Port(udp.srcport)
占2个字节 - Destination Port(udp.dstport)
占2个字节 - Lenghth (udp.length)
占2个字节
- CheckSum (udp.checksum)
占2个字节
- Sync stream(wol.sync)
占6个字节,是wol 信息的sync 帧
- Text Item (text)
占用96 字节,发送16次被唤醒机器的mac 地址。
数据解析
服务端,发送完上面的wol packet。 客户端就可以绑定对应端口,解析局域网内网络了。
#define DEBUG (0)
void * monitorWolPktThread(void *pData)
{
int sock = -1;
int nb