Difference between revisions of "Microduino ENC Network (4)"
(Created page with "{{Language | Microduino ENC网络(四)}} {| style="width: 800px;" |- | ==Objective== This tutorial will show you how to power on a PC using the wake on Lan feature and you...") |
|||
Line 15: | Line 15: | ||
==Requirements== | ==Requirements== | ||
− | Almost all the actual network adapters have a feature called Wake on Lan, that is the ability to | + | Almost all the actual network adapters have a feature called Wake on Lan, that is the ability to "wake" the PC with a special command sent through the network. |
Two main requirements to use this feature: | Two main requirements to use this feature: | ||
Line 24: | Line 24: | ||
the WOL functionality has to be enabled in the BIOS: | the WOL functionality has to be enabled in the BIOS: | ||
[[File:BIOSSetup1.jpg|600px|center|thumb]] | [[File:BIOSSetup1.jpg|600px|center|thumb]] | ||
− | A typical limit in WOL usage is that network adapter | + | A typical limit in WOL usage is that network adapter isn't able to wake the PC if it was shut down by power loss. Actually, recent motherboards can enable WOL functionality even after a power loss; you can configure this feature in motherboard’s BIOS: |
[[File:BIOSSetup2.jpg|600px|center|thumb]] | [[File:BIOSSetup2.jpg|600px|center|thumb]] | ||
Magic Packet: | Magic Packet: | ||
− | The wake command is issued sending on the network a specific packet, called Magic Packet (refer to http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet). This packet is | + | The wake command is issued sending on the network a specific packet, called Magic Packet (refer to http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet). This packet is received by all the devices connected to local network because it presents – as destination MAC address – the broadcast address (FF:FF:FF:FF:FF:FF). It includes six bytes valued FF, followed by the target PC's MAC address repeated 16 times. |
− | Even if | + | Even if it's not important which high level protocols you choose, it's a convention to use UDP protocol and destination port 7 or 9. |
==Schematic== | ==Schematic== | ||
Line 49: | Line 49: | ||
==Debug== | ==Debug== | ||
− | Step | + | Step 1: Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE. |
https://github.com/jcw/ethercard | https://github.com/jcw/ethercard | ||
− | Step | + | Step 2: Explain the program: |
− | Note: EtherCard library had a bug in the Magic Packet creation. I solved the problem and my change has been accepted in the official repository: so make sure to download | + | Note: EtherCard library had a bug in the Magic Packet creation. I solved the problem and my change has been accepted in the official repository: so make sure to download library's latest version |
− | You can use sendWol() method to send the Magic Packet; that method needs target | + | You can use sendWol() method to send the Magic Packet; that method needs target PC's MAC address as a parameter: |
static byte targetmac[] = {0x00,0x1A,0x4B,0x38,0x0F,0x5C}; | static byte targetmac[] = {0x00,0x1A,0x4B,0x38,0x0F,0x5C}; | ||
Line 61: | Line 61: | ||
ether.sendWol(targetmac); | ether.sendWol(targetmac); | ||
− | Step | + | Step 3: Compile the code and download it. |
− | Step | + | Step 4: Using a network analysis tool like Wireshark, you can inspect the packet sent by Microduino and note that it's correct: |
in red the destination broadcast MAC address | in red the destination broadcast MAC address |
Latest revision as of 10:03, 12 September 2016
Language: | English • 中文 |
---|
ObjectiveThis tutorial will show you how to power on a PC using the wake on Lan feature and your Microduino. Equipment
RequirementsAlmost all the actual network adapters have a feature called Wake on Lan, that is the ability to "wake" the PC with a special command sent through the network. Two main requirements to use this feature: if your network adapter is not embedded in the motherboard, you have to connect them with a cable the WOL functionality has to be enabled in the BIOS: A typical limit in WOL usage is that network adapter isn't able to wake the PC if it was shut down by power loss. Actually, recent motherboards can enable WOL functionality even after a power loss; you can configure this feature in motherboard’s BIOS: Magic Packet: The wake command is issued sending on the network a specific packet, called Magic Packet (refer to http://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet). This packet is received by all the devices connected to local network because it presents – as destination MAC address – the broadcast address (FF:FF:FF:FF:FF:FF). It includes six bytes valued FF, followed by the target PC's MAC address repeated 16 times. Even if it's not important which high level protocols you choose, it's a convention to use UDP protocol and destination port 7 or 9. Schematic
Stack all modules and then connect the ethernet cable, as follows:
ProgramRefer to ENCnetwork4 DebugStep 1: Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE. https://github.com/jcw/ethercard Step 2: Explain the program: Note: EtherCard library had a bug in the Magic Packet creation. I solved the problem and my change has been accepted in the official repository: so make sure to download library's latest version You can use sendWol() method to send the Magic Packet; that method needs target PC's MAC address as a parameter: static byte targetmac[] = {0x00,0x1A,0x4B,0x38,0x0F,0x5C}; ... ether.sendWol(targetmac); Step 3: Compile the code and download it. Step 4: Using a network analysis tool like Wireshark, you can inspect the packet sent by Microduino and note that it's correct: in red the destination broadcast MAC address in green the choice of IP and UDP protocol in light blue the target PC’s MAC address repeated 16 times ResultYou PC will be waken by Microduino. Video |