Difference between revisions of "Microduino ENC Network (4)"

From Microduino Wiki
Jump to: navigation, search
(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 “wake” the PC with a special command sent through the network.
+
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 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:
+
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 receved 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.
+
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 destionation port 7 or 9.
+
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 1:Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE.
+
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 2:Explain the program:
+
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
+
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:
+
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 3:Compile the code and download it.
+
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:
+
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  • 中文

Objective

This tutorial will show you how to power on a PC using the wake on Lan feature and your Microduino.

Equipment

Requirements

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:

if your network adapter is not embedded in the motherboard, you have to connect them with a cable

NetCardConnetMotherBoard.jpg

the WOL functionality has to be enabled in the BIOS:

BIOSSetup1.jpg

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:

BIOSSetup2.jpg

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

  • Microduino-ENC28J60
  • Microduino-RJ45
  • Microduino-Core
  • Microduino-FT232R

Stack all modules and then connect the ethernet cable, as follows:

MicroduinoENCShow.jpg


Program

Refer to ENCnetwork4

Debug

Step 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

Wireshark.jpg

Result

You PC will be waken by Microduino.

Video