---
title: "Discussion on \"使用raw socket发送magic packet\" | Hashnode"
description: "Discussion on \"使用raw socket发送magic packet\". Magic Packet是进行网络唤醒的数据包，将这个数据包以广播的形式发到局域网上，与数据包中所关联的MAC相同的电脑就会被唤醒开机，通常我们都是使用UDP报文的形式来发送这个数据包，但实际上在进行网络唤醒的时候，只要报文中包含Magic Packet应该就可以唤醒相关的计算机，与IP协议、UDP协议没有任何关系，本文将试图抛开网络层(IP层)和传输层(TCP/UDP层)，直接在数据链路层发出Magic Packet，并成功实现网络唤醒，本文将提供完整的源代码。阅读本文需要有较好的网络编程基础..."
url: "https://hashnode.com/posts/180015-send-magic-packet-via-raw-socket/63e5ca2714ac8cb2b71f206c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [使用raw socket发送magic packet](https://whowin.cn/180015-send-magic-packet-via-raw-socket?utm_source=hashnode&utm_medium=feed)

Magic Packet是进行网络唤醒的数据包，将这个数据包以广播的形式发到局域网上，与数据包中所关联的MAC相同的电脑就会被唤醒开机，通常我们都是使用UDP报文的形式来发送这个数据包，但实际上在进行网络唤醒的时候，只要报文中包含Magic Packet应该就可以唤醒相关的计算机，与IP协议、UDP协议没有任何关系，本文将试图抛开网络层(IP层)和传输层(TCP/UDP层)，直接在数据链路层发出Magic Packet，并成功实现网络唤醒，本文将提供完整的源代码。阅读本文需要有较好的网络编程基础...

Feb 9, 2023 · 2 min read · whowin.cn  
Updated Oct 18, 2024  
Read the article

-   [#linux](https://hashnode.com/tag/linux)
-   [#raw-socket](https://hashnode.com/tag/raw-socket)
-   [#magic-packet](https://hashnode.com/tag/magic-packet)

## Written by

[whowin](https://hashnode.com/@whowin)

@whowin · Beijing, China

  
[View profile](https://hashnode.com/@whowin)

一枚有30多年经验的退休程序员，主要从事嵌入式软件开发

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
