{"id":21548665,"url":"https://github.com/nikeee/wake-on-lan","last_synced_at":"2025-05-07T21:29:44.560Z","repository":{"id":8455266,"uuid":"10050603","full_name":"nikeee/wake-on-lan","owner":"nikeee","description":"Sending magic packets and performing IP address operations.","archived":false,"fork":false,"pushed_at":"2023-12-12T20:27:50.000Z","size":1220,"stargazers_count":62,"open_issues_count":5,"forks_count":16,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-17T06:57:12.924Z","etag":null,"topics":["arp-request","nuget","subnet","wake-on-lan"],"latest_commit_sha":null,"homepage":"https://nikeee.github.io/wake-on-lan/README.html","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikeee.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-14T08:13:48.000Z","updated_at":"2025-03-08T01:34:37.000Z","dependencies_parsed_at":"2024-06-21T14:23:26.025Z","dependency_job_id":"2d2bbdd0-f4bf-4a2e-bbdc-b20bc86e8bfb","html_url":"https://github.com/nikeee/wake-on-lan","commit_stats":null,"previous_names":["nikeee/wake-on-lan-library"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikeee%2Fwake-on-lan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikeee%2Fwake-on-lan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikeee%2Fwake-on-lan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikeee%2Fwake-on-lan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikeee","download_url":"https://codeload.github.com/nikeee/wake-on-lan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252956890,"owners_count":21831397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arp-request","nuget","subnet","wake-on-lan"],"created_at":"2024-11-24T06:19:20.766Z","updated_at":"2025-05-07T21:29:44.502Z","avatar_url":"https://github.com/nikeee.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wake-On-LAN ![Matrix Build Status](https://github.com/nikeee/wake-on-lan/workflows/Matrix%20Build/badge.svg) [![NuGet version](https://img.shields.io/nuget/v/WakeOnLan.svg)](https://nuget.org/packages/WakeOnLan)\n\nA simple library for sending magic packets and performing IP address operations. The default namespace is `System.Net`. There is an online documentation available [here](https://nikeee.github.io/wake-on-lan/README.html).\n\n## Samples\n### Sending a Magic Packet\nThis sample uses `00:11:22:33:44:55` as MAC address.\n\n```C#\nusing System.Net;\n// ...\n\n// Using the IPAddess extension\nIPAddress.Broadcast.SendWol(0x00, 0x11, 0x22, 0x33, 0x44, 0x55);\n\n// via core MagicPacket class\nvar endPoint = new IPEndPoint(IPAddress.Broadcast, 7); // You don't have to use Broadcast.\n                                                       // Every IP/port-combination is possible.\nMagicPacket.Send(endPoint, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55);\n\n// via IPEndPoint extension\nendPoint.SendWol(0x00, 0x11, 0x22, 0x33, 0x44, 0x55);\n\n// ...\nusing System.Net.NetworkInformation;\nPhysicalAddress.Parse(\"00-11-22-33-44-55\").SendWol();\n```\n\n\n### Getting Subnet Information\nYou can also retrieve information about a subnet.\n```C#\nusing System.Net;\nusing System.Net.Topology;\n// ...\n\nvar someIp = new IPAddress(new byte[] { 192, 168, 1, 23 }); // Some IP address in the subnet\nvar mask = new NetMask(255, 255, 255, 0); // the network mask of the subnet\n\n// CIDR-notation number of the network mask\nint cidr = mask.Cidr;\n\nvar networkPrefix = someIp \u0026 mask; // bitwise operation to get the network address (192.168.1.0)\nnetworkPrefix = someIp.GetNetworkPrefix(mask); // using the extension method for IPAddress\n\n// retrieve broadcast address of the subnet (192.168.1.255)\nvar broadcastAddress = someIp.GetBroadcastAddress(mask);\n\nIEnumerable\u003cIPAddress\u003e siblings = someIp.GetSiblings(mask, SiblingOptions.ExcludeUnusable);\n// Enumerate through all IP addresses in the subnet, except network prefix and broadcast (RFC 950, 2^n-2)\nforeach (IPAddress someIpInNetwork in siblings)\n{\n    Console.WriteLine(someIpInNetwork.ToString());\n}\n\n// Get number of possible siblings without someIp, broadcast and network prefix\nint siblingCount = mask.GetSiblingCount(SiblingOptions.ExcludeAll);\n```\n\n### ARP Requests\nTo retrieve the MAC address of a host, there is a functionality for ARP-request built-in. It uses the Windows API method [SendArp](http://msdn.microsoft.com/en-us/library/windows/desktop/aa366358(v=vs.85).aspx).\n```C#\nArpRequestResult res = ArpRequest.Send(someIp);\nif(res.Exception != null)\n{\n    Console.WriteLine(\"ARP error occurred: \" + res.Exception.Message);\n}\nelse\n{\n    Console.WriteLine($\"Host MAC address: {res.Address}\");\n}\n```\nNote that there isn't always an MAC address available although there is a host. The reason for this could be the host is offline and/or the physical address is not cached somewhere.\nAlso, this function uses a p/invoke. This might cause problems when used on platforms other than Windows.\n\n### Async/Await\nThis library also supports the Task-based Asynchronous Pattern (TAP). Every method that can send a magic packet synchronously is available as a TAP method returning a `Task`.\n```C#\nawait IPAddress.Broadcast.SendWolAsync(0x00, 0x11, 0x22, 0x33, 0x44, 0x55);\n```\n\n### Further Samples\nThe [System.Net.NetworkInformation.PhysicalAddress](http://msdn.microsoft.com/en-us/library/system.net.networkinformation.physicaladdress(v=vs.110).aspx) class is also supported as it represents a MAC address.\n```C#\nvar mac = new PhysicalAddress(new byte[] {0x00, 0x11, 0x22, 0x33, 0x44, 0x55});\nmac.SendWol(); // via extension method\n```\n\n### Install\nInstall the [NuGet package](https://nuget.org/packages/WakeOnLan) of this library:\n```Shell\n# NuGet CLI\nInstall-Package WakeOnLan\n# dotnet CLI\ndotnet add package WakeOnLAN\n```\n\n### Compatibility\nVersion `2+` will be available for .NET Standard only. Version 1 supports the following platforms:\n- .NET 2.0 (does not include extension methods and async features)\n- .NET 3.5 Client Profile (does not include async features)\n- .NET 4.0 Client Profile (does not include async features)\n- .NET 4.5\n- .NET 4.5.1\n\nTo install a version `\u003c2`, have a look at all the available versions of [the NuGet package](https://www.nuget.org/packages/WakeOnLan) and install a specific version. For example:\n```Shell\n# NuGet CLI\nInstall-Package WakeOnLAN -Version 1.6.0\n# dotnet CLI\ndotnet add package --version 1.6.0 WakeOnLAN\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikeee%2Fwake-on-lan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikeee%2Fwake-on-lan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikeee%2Fwake-on-lan/lists"}