Socket Removing a Wake-on-LAN Step by Step

zhaozj2021-02-16  78

Step 1: Cognition Remote Wake

"Computer Abstract" 2003.9 - Application and Skills - Remote Waken

"Computer Application Abstract" has introduced how to implement remote control technology in the article No. 7 of 2003, a proceedings, and a long-distance remote control, but remote control primary conditions are that the remote computer must be turned on by hand. However, it is unrealistic to let the remote computer 24 hours to wait for the client's connection. Can you remotely control your computer boot when you need? The answer is certain. We can achieve this feature with remote wake-up technology. Remote wake-up technology has two implementations: Wake-Up On LAN (WOL) and WAKE-UP ON MODEM (modem power on, abbreviation WOM). The author introduces you to the implementation of remote wake-up technology. First, WOL To implement a local area network, the motherboard and the NIC must support remote wake-up feature. Generally, the current motherboard supports this feature, which typically has a special 3-core socket on the motherboard to power the NIC when shutdown. But not all the NIC supports this feature (especially some cheaper low-end network cards), it is easy to determine if the network card supports remote wake-up function is simple, supporting remote wake-up network cards with a 3-pin WOL interface and one 3-core remote wake-up cable, by judging whether the network card has a WOL interface (some newer NIC may not support remote wake-up. This is because the popular motherboard supports PCI2.2 standard, while PCI 2. 2 The standard does not need to power the NIC through a dedicated WOL interface, allowing the motherboard to provide a Standby power supply to the NIC directly through the PCI slot). 1. After the hardware connection network card is installed, one end of the remote wake-up cable is inserted onto the WOL interface of the NIC, and the other end is connected to the 3-pin WOL remote wake-up interface of the motherboard (the interface is usually marked with WOL_CON, of course, if the motherboard and network card support The PCI2.2 standard does not have to do this. 2. CMOS settings Open the CMOS remote wakeup feature is simple, as long as the "Wake Up LAN" item of "Power Management Setup" in the CMOS setting is "enable". 3. Remote Wake-up Computer Remote Computer Network Cards only activate the system boot only, so we also generate these data frames with the appropriate software. Similar software, the most famous is the Magic Packet developed by AMD, and there are also some of the diagnostic programs that come with the network cards. The author refers to the software developed by people - "Network Waken". Network wake-up is a green software that does not have to be installed. After first decompress the downloaded compressed package, then "Network Wake-up V041.exe" opens "Network Wake-up". The interface is shown in the figure above, since only the MAC address of the remote computer can be woken up, so we must first make the software know the MAC address of the remote computer. Click the "Scanning Network" of the LAN menu, "Network Wake" will scan all the computer that is in the boot state in the LAN and display information such as computer name, IP address, and MAC address in "List Info" (if not Scan to the target computer, you can click "Handmade" menu of the LAN menu), then click the "Save List" of the "List" menu, save the results of the scan for the next use. To wake up a computer in the network, you can right at the "list information" and select "Wake up". If you want to wake all your computers in the list, you can select "Wake All". Second, WOM WOL can only be used in the LAN, if the remote wakes up computer is far from the local distance, we must achieve remote wobbles through WOM (you can say no exaggeration, wherever the phone can pass, the ancestors use WOM to implement Remote awakening). WOM also requires double support for motherboards and MODEMs (currently most of the motherboards and MODEMs support this feature).

Implementing the WOM is relatively simple, after connecting the Modem to the computer and telephone line, set the "Power On By Ring" item in "Power Management Setup" in CMOS to "Enable". Now as long as the Modem is turned on, call the phone number connected to the MODEM to achieve remote boot through the WOM. And use WOM to remotely wake up without worrying about the problem of the phone bill, because Modem can start the machine as long as the phone shock does not need to answer the phone, you can start the machine (so we don't have to spend a penny can play international long distance to wake up in another country) The computer is a computer. Step 2: Remote awakening technology principle

Magic Packet ™ TechnologyThe Magic Packet ™ technology is used to remotely wake up a sleeping or powered off PC on a network. This is accomplished by sending a specific packet of information, called a Magic Packet frame, to a node on the network. When a PC capable of receiving the specific frame goes to sleep, it will enable the Magic Packet mode in the LAN controller, and when the LAN controller receives a Magic Packet frame, it will alert the system to wake up. The patented Magic Packet technology is implemented entirely in the LAN controller. This architecture allows the PC to go into a very low power mode, even as far as to remove the power from the entire system, except for the LAN chip. Magic Packet Technology Details Once the LAN controller has been put into the Magic Packet mode, it scans all incoming frames addressed to the node for a specific data sequence, which indicates to the controller that this is a Magic Packet frame. A Magic Packet frame must also meet the basic require Ments for the lanology chosen, Such As Source Address, Destination Address (Which May Be The Receiving Station)

s IEEE address or a MULTICAST address which includes the BROADCAST address), and CRC. The specific sequence consists of 16 duplications of the IEEE address of this node, with no breaks or interruptions. This sequence can be located anywhere within the packet, but must be preceded by a synchronization stream. The synchronization stream allows the scanning state machine to be much simpler. The synchronization stream is defined as 6 bytes of FFh. The device will also accept a BROADCAST frame, as long as the 16 duplications of the IEEE address match the address of the machine to be awakened If the IEEE address for a particular node on the network was 11h 22h 33h 44h 55h 66h, then the LAN controller would be scanning for the data sequence (assuming an Ethernet Frame):. DESTINATION SOURCE MISC . FF FF FF FF 11 22 33 44 55 66 11 22 33 44 55 66 11 22 33 44 55 66 11 22 33 44 55 66 11 22 33 44 55 66 11 22 33 44 55 66 11 22 33 44 55 66 11 22 33 44 55 66 11 .. 44 55 66 Misc. CRC. There are no other restrictions on a magic packet frame. For instance, the sequence could be in a TCP / IP packet, an IPX packet, etc. The frame may be bridged or routed across the network, without affecting its ability to wake up a node at the destination of the frame. If the LAN controller scans a frame and does not find the specific sequence shown above, it discards the frame and takes no further action. If the controller detects the data sequence, however, then it alerts the PC '

.. S power management circuitry to wake up the system Magic Packet Today Hewlett-Packard, IBM, Gateway 2000 and other leading manufacturers implement AMD's Magic Packet technology Magic Packet allows IS managers to increase their efficiency by remotely accessing any PC on the network - on, powered down, or powered off. Magic Packet technology is currently offered on AMD's PCnet ™ -ISA II, PCnet-PCI II, PCnet-FAST, PCnet-FAST and PCnet-FAST III, and is a standard feature that will be integrated into future AMD PCnet controllers. With Magic Packet Technology, AMD set the standard and built the foundation for today's advanced power management technologies for networked PCs, including the OnNow power management industry intitiative. The OnNow design initiative is a comprehensive, system-wide approach to System and Device Power Control. in Fact, AMD Co-Authored THE ONNOW Power Management ative AMD licenses the Magic Packet technology to device manufacturers If you are interested in getting licensing information, please contact Rahul Deshmukh at (408) 749-5448 or email at rahul.deshmukh@amd.com.Step3:.. remote wake-up technology

/ ************************************************** ******************* Created: 2004/06/02 * Updated: 2006/03/28 * file name: wakeup.cpp * author: xiaoping zhang * purpose: *********************************************************** ***************************** / # include "stdafx.h" #include "iphlpapi.h" #include

#define mac_addr_len 6 # Define Magic_Data_Len 102

#pragma comment (lib, "iphlpapi.lib")

Bool getMacfromip (const char * pip) {HRESULT HR; ipaddr ipaddr; ulong pulmac [2]; ulong ullen; ipaddr = inet_addr ("216.145.25.31"); MEMSET (Pulmac, 0xFF, Sizeof (Pullen); ullen = 6 HR = Sendarp (iPaddr, 0, Pulmac, & Ullen); Printf ("Return% 08X, Length% 8D / N", HR, ULLEN); SIZE_T I, J; Char * Szmac = New Char [Ullen * 3]; PBYTE PBHEXMAC = (Pbyte) Pulmac; /// Convert the binary mac address INTO HUMAN-readable // for (i = 0, j = 0; i

// Enter 6 bytes of MAC address BOOL WAKEUPSINGLEPC (const unsigned char PMAC []) {// Todo: add Your Command Handler Code Here if (pmac == null) {Trace ("Mac Address Error!"); Return False;} wsadata wsadata; int err = wsastartup (MakeWord (2, 2), & WSADATA); if (Err! = 0) {Trace ("WsaStartup Error% D!", Wsagetlasterror ()); Return False;} IF Lobyte (WSADATA.WVERSION)! = 2 || Hibyte (Wsadata.WVersion)! = 2) {Trace ("Winsock DLL Not Supports 2.2!"); Return False;} do {socket sfirst = Socket (AF_INET, SOCK_DGRAM, 0 ); If (sfirst == invalid_socket) {trace ("socket erroR% D!", Wsagetlasterror (); break;} do {bool boptval = true; int = size = sizeof (bool); err = setsockopt (Sfirst, SOL_Socket , SO_BROADCAST, (char *) & bOptVal, iOptLen); if (err == SOCKET_ERROR) {TRACE ( "setsockopt error% d!", WSAGetLastError ()); break;} char szMagicData [MAGIC_DATA_LEN]; memset (szMagicData, 0xff, SIZEOF (SZMagicData)); for (INT i = mac_addr_len; i

}}} While (0); err = wsacleanup (); if (err == SOCKET_ERROR) {Trace ("WSACLEANUP Error D!", Wsagetlasterror (); Return False;} return true;}

// Enter 6 bytes of MAC address array BOOL WAKEUPMULTIPC (int inum, const unsigned char * pszmac []) {// Todo: add your command handler code here if (pszmac == null) {trace ("Mac Address Error ! ", Wsagetlasterror ()); return false;} wsadata wsadata; int err = wsastartup (Makeword (2, 2), & WSADATA); if (Err! = 0) {Trace (" WsaStartup Error D! ", Wsagetlasterror ); Return false;} if (Lobyte (Wsadata.WVersion)! = 2 || Hibyte (Wsadata.WVersion)! = 2) {Trace ("Winsock DLL Not Supports 2.2"); Return False;} do {socket Sfirst = Socket (AF_INET, SOCK_DGRAM, 0); if (Sfirst == Invalid_socket) {trace ("Socket Error% D!", WsageTlasterror (); Break;} do {bool Boptval = true; int tentlen = sizeof (bool) ; err = setsockopt (sFirst, SOL_SOCKET, SO_BROADCAST, (char *) & bOptVal, iOptLen); if (err == SOCKET_ERROR) {TRACE ( "setsockopt error% d!", WSAGetLastError ()); break;} sockaddr_in addr; addr .SIN_FAMILY = AF_INET; addr.sin_port = htons (0); addr.sin_ad dr.s_addr = htonl (INADDR_BROADCAST); char szMagicData [MAGIC_DATA_LEN]; for (int index = 0; index

CloseSocket (Sfirst); if ("CloseSocket Error D!", WsageTlasterror (); Break;}} while (0); err = wsacleanup (); if (err == Socket_error) {Trace ("WSACLEANUP ERROR% D!", Wsagetlasterror ()); return false;} Return true;} STEP4: Remote Wake-up Sharing Software

Http://download.net.com.cn/html/010062001052902.html

Step5: Idea Expansion

http://www.scyld.com/wakeonlan.html

转载请注明原文地址:https://www.9cbs.com/read-15659.html

New Post(0)