npcap-devguide.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Developing software with Npcap</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.2"><meta name="description" content="Writing software that captures or injects network traffic is easy with Npcap. This guide describes the Npcap SDK, WinPcap compatibility, and the Npcap API."><link rel="home" href="index.html" title="Npcap Reference Guide"><link rel="up" href="index.html" title="Npcap Reference Guide"><link rel="prev" href="npcap-users-guide.html" title="Npcap Users' Guide"><link rel="next" href="npcap-api.html" title="The Npcap API"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Developing software with Npcap</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="npcap-users-guide.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="npcap-api.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="npcap-devguide"></a>Developing software with Npcap</h2></div><div><div class="abstract"><p class="title"><b>Abstract</b></p>
  2. <p> Writing software that captures or injects network traffic is easy
  3. with Npcap. This guide describes the Npcap SDK, WinPcap compatibility,
  4. and the Npcap API.</p>
  5. </div></div></div></div>
  6. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-development"></a>Using the Npcap SDK</h3></div></div></div>
  7. <p>
  8. To build software that uses Npcap, use the latest version of the Npcap Software Development Kit (SDK).
  9. The latest SDK can be downloaded on <a class="ulink" href="https://npcap.com/#download" target="_top">Npcap.org</a>.
  10. Updates to the SDK are much less frequent than updates to the Npcap binaries.
  11. </p>
  12. </div>
  13. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-examples"></a>Examples</h3></div></div></div>
  14. <p>
  15. Examples of applications using Npcap are available <a class="ulink" href="https://github.com/nmap/npcap/tree/master/Examples" target="_top">in the Examples directory</a> in the source distribution.
  16. Several of these examples are explored in more depth in the <a class="xref" href="npcap-tutorial.html" title="Npcap Development Tutorial">the section called &#8220;Npcap Development Tutorial&#8221;</a>.
  17. </p>
  18. <p>
  19. Npcap developer Yang Luo has also provided an example:
  20. <a class="ulink" href="https://github.com/hsluoyz/UserBridge/" target="_top">UserBridge</a>,
  21. which is a tool to redirect all packets from one interface to another.
  22. </p>
  23. </div>
  24. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-devguide-updating"></a>Updating WinPcap software to Npcap</h3></div></div></div>
  25. <p>
  26. For the most part, Npcap is completely compatible with software written
  27. for WinPcap. Minor changes need to be made to <a class="xref" href="npcap-devguide.html#npcap-feature-native-dll" title="DLL loading">the section called &#8220;DLL loading&#8221;</a> and in some
  28. cases <a class="xref" href="npcap-devguide.html#npcap-feature-native-servicename" title="Service name">the section called &#8220;Service name&#8221;</a>. However, there have been many improvements to the libpcap
  29. API between the last release of WinPcap and the current release of Npcap.
  30. Reviewing the changes may help improve performance, reliability, and
  31. maintainability of software that uses Npcap.
  32. </p>
  33. <p>Apart from the libpcap API, WinPcap exported a few functions used by
  34. <a class="ulink" href="https://www.winpcap.org/windump/" target="_top">WinDump</a> that were
  35. related to porting a Unix-style tool to Windows but unrelated to packet
  36. capture. Those functions were not documented in the WinPcap
  37. documentation, have never been included in libpcap, and are therefore not
  38. in the Npcap API: <code class="code">getservent</code>, <code class="code">endservent</code>, and
  39. <code class="code">eproto_db</code>.</p>
  40. <p>One other function exported by WinPcap, <code class="code">wsockinit</code>, is
  41. available via the Npcap API as <code class="code">pcap_wsockinit</code>. It calls
  42. <code class="code">WSAStartup</code> for Windows Sockets version 1.1 and ensures that
  43. <code class="code">WSACleanup</code> is called when the process ends.</p>
  44. </div>
  45. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-detect"></a>How to detect what version Npcap/WinPcap you are using?</h3></div></div></div>
  46. <p>
  47. Sometimes, our user software needs to detect the existence of Npcap/WinPcap
  48. at install-time or run-time. Although Npcap's GUI installer has the ability
  49. to handle this, you may want to handle it by yourself in some conditions,
  50. like you run Npcap installer in silent-mode. The run-time detection is even
  51. more useful. Your software probably has some functions that rely on Npcap's
  52. particular features (like loopback capture). You need to know if you
  53. are running on top of Npcap or the legacy WinPcap to control whether to
  54. switch your functions on. Fortunately, Npcap provides you some methods to
  55. detect Npcap/WinPcap at install-time and run-time.
  56. </p>
  57. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-detect-version"></a>Npcap version</h4></div></div></div>
  58. <p> Npcap has a version number that is independent of WinPcap. The last
  59. release of WinPcap was version 4.1.3, but Npcap started over counting
  60. versions from 0.00. In order to make it clear to the installers and other
  61. software that Npcap is newer and more advanced, the executable
  62. <span class="quote">&#8220;<span class="quote">file version</span>&#8221;</span> was advanced to <span class="quote">&#8220;<span class="quote">5.0.0.000</span>&#8221;</span> at
  63. that point. The major version will always be <span class="quote">&#8220;<span class="quote">5</span>&#8221;</span> to
  64. distinguish Npcap from WinPcap. The minor version is Npcap's major
  65. version; the revision is Npcap's minor version; and the build number is
  66. an encoding of the build date. So a file version of
  67. <span class="quote">&#8220;<span class="quote">5.0.92.612</span>&#8221;</span> is Npcap 0.92, built on June 12th.</p>
  68. </div>
  69. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-detect-install-time"></a>Install-time detection</h4></div></div></div>
  70. <p>
  71. You can check the existence of <code class="filename">C:\Program Files\Npcap\NPFInstall.exe</code> to
  72. detect Npcap's existence. If Npcap exists, you can check the file version of
  73. <code class="filename">C:\Program Files\Npcap\NPFInstall.exe</code> to detect Npcap e-version. The
  74. e-version also gives you the version. The NSIS code is shown below. <code class="varname">$inst_ver</code>
  75. is an e-version string like <span class="quote">&#8220;<span class="quote">5.0.7.424</span>&#8221;</span>
  76. </p>
  77. <pre class="screen">
  78. GetDllVersion "C:\Program Files\Npcap\NPFInstall.exe" $R0 $R1
  79. IntOp $R2 $R0 / 0x00010000
  80. IntOp $R3 $R0 &amp; 0x0000FFFF
  81. IntOp $R4 $R1 / 0x00010000
  82. IntOp $R5 $R1 &amp; 0x0000FFFF
  83. StrCpy $inst_ver "$R2.$R3.$R4.$R5"</pre>
  84. <p>
  85. You can check the installation options of an already installed Npcap by reading the registry
  86. key: <code class="filename">HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\npcap\Parameters</code>.
  87. The entries like <code class="filename">AdminOnly</code>,
  88. <code class="filename">LoopbackSupport</code>, <code class="filename">DltNull</code>,<code class="filename">Dot11Support</code>,
  89. <code class="filename">VlanSupport</code>, <code class="filename">WinPcapCompatible</code>, etc.
  90. are <code class="code">REG_DWORD</code> type. A 0x00000001 value
  91. indicates the installation option is <span class="emphasis"><em>CHECKED</em></span>.
  92. </p>
  93. <p>Note: Prior to Npcap 0.93, these values were stored in the
  94. <code class="filename">Services\npcap</code> key directly.</p>
  95. </div>
  96. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-detect-run-time"></a>Run-time detection</h4></div></div></div>
  97. <p>
  98. Npcap and WinPcap can be installed together on a system. Which capture
  99. library is used by the user software relies on the DLL loading path. If
  100. Npcap's <code class="filename">wpcap.dll</code> is loaded first, then you are using
  101. Npcap, vice versa. However, it's difficult and fragile to check the DLL
  102. loading path by yourself. Fortunately, you can use
  103. <code class="function">pcap_lib_version</code> to get the Npcap/WinPcap version
  104. string.
  105. </p>
  106. <pre class="screen">
  107. char *pcap_version = pcap_lib_version();
  108. printf("%s", pcap_version);
  109. // Npcap output: "Npcap version 0.92, based on libpcap version 1.8.1"
  110. // WinPcap output: "WinPcap version 4.1.3"</pre>
  111. <p>Npcap requires the <code class="varname">npcap</code> service to be running. If
  112. installed in <span class="quote">&#8220;<span class="quote">WinPcap Compatible Mode</span>&#8221;</span>, the
  113. <code class="varname">npf</code> service can be started instead. Given that
  114. <code class="varname">npcap</code> service is always installed
  115. in both modes, a good practice is just trying the <code class="varname">npcap</code> service first.
  116. If it fails, then try the <code class="varname">npf</code> service. This is also what most of our users
  117. do in their software based on our investigation. A code sample from Nmap is
  118. <a class="ulink" href="https://github.com/nmap/nmap/blob/8c8e4a08c6c6b7abd2343e5921aafb6077bdb257/mswin32/winfix.cc#L322-L328" target="_top">here</a>.
  119. </p>
  120. </div>
  121. </div>
  122. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-feature-native"></a>For software that want to use Npcap first when Npcap and WinPcap coexist</h3></div></div></div>
  123. <p>
  124. Prerequisite: Uncheck the <code class="option">Install Npcap in WinPcap API-compatible Mode</code> option at
  125. install-time (which is by default).
  126. </p>
  127. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-native-dll"></a>DLL loading</h4></div></div></div>
  128. <p>Npcap installs its DLLs into <code class="filename">C:\Windows\System32\Npcap\</code>
  129. instead of WinPcap's <code class="filename">C:\Windows\System32\</code>. Because of how Windows'
  130. <a class="ulink" href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms686203(v=vs.85).aspx" target="_top">DLL search path</a> works,
  131. your application will use WinPcap first by default when Npcap and WinPcap coexist,
  132. as <code class="filename">C:\Windows\System32\</code> is prior to <code class="filename">C:\Windows\System32\Npcap\</code>.
  133. So when Npcap and WinPcap coexist, an application that want to use Npcap instead
  134. of WinPcap must make <code class="filename">C:\Windows\System32\Npcap\</code> precedent to the
  135. <code class="filename">C:\Windows\System32\</code> in the DLL search path. Here are two ways
  136. to modify this search path to make your application load Npcap's DLLs first,
  137. based on how your application links Npcap/WinPcap's library
  138. (<code class="filename">wpcap.dll</code>).</p>
  139. <div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="npcap-feature-native-dll-implicitly"></a>If the application <span class="emphasis"><em>implicitly</em></span> links <code class="filename">wpcap.dll</code></h5></div></div></div>
  140. <p>Implicit linking means that either you specified <code class="filename">wpcap.lib</code>
  141. in your <code class="option">Project Properties</code> -&gt; <code class="option">Configuration Properties</code>
  142. -&gt; <code class="option">Linker</code> -&gt; <code class="option">Input</code> -&gt; <code class="option">Additional Dependencies</code> in Visual Studio,
  143. or specified <code class="code">#pragma comment(linker, "wpcap.lib")</code> in your code.</p>
  144. <p>You need to do the following two steps:</p>
  145. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Specify <code class="filename">wpcap.dll</code> as a delay-loaded DLL: In
  146. Visual Studio, open the <code class="option">Project Properties</code> window. Go to:
  147. <code class="option">Configuration Properties</code> -&gt; <code class="option">Linker</code> -&gt; <code class="option">Input</code>
  148. -&gt; <code class="option">Delay Loaded Dlls</code>. Enter <code class="filename">wpcap.dll</code>
  149. in that option.</p></li><li class="listitem"><p>Before calling any <code class="filename">wpcap.dll</code> functions,
  150. call <code class="function">SetDllDirectory</code> to add <code class="filename">C:\Windows\System32\Npcap\</code>
  151. to DLL search path.</p></li></ul></div>
  152. <p><a class="ulink" href="https://github.com/hsluoyz/WinDump/" target="_top">Here</a>
  153. is an example called WinDump, a simple packet capture tool using Npcap/WinPcap.
  154. And <a class="ulink" href="https://github.com/hsluoyz/WinDump/commit/dffe2eaa520fc3b449ec0a90dcfa24f96359bbfa" target="_top">this commit</a>
  155. makes it able to use Npcap first when Npcap and WinPcap coexist.</p>
  156. </div>
  157. <div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="npcap-feature-native-dll-explicitly"></a>If the application <span class="emphasis"><em>explicitly</em></span> links <code class="filename">wpcap.dll</code></h5></div></div></div>
  158. <p>Explicit linking means that you explicitly called <code class="function">LoadLibrary</code>
  159. to load <code class="filename">wpcap.dll</code> and called <code class="function">GetProcAddress</code> to get the
  160. function pointers.</p>
  161. <p>You need to do the following one step:</p>
  162. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Before calling <code class="function">LoadLibrary</code> to load <code class="filename">wpcap.dll</code>,
  163. call <code class="function">SetDllDirectory</code> to add <code class="filename">C:\Windows\System32\Npcap\</code>
  164. to DLL search path.</p></li></ul></div>
  165. <p>The function <code class="function">init_npcap_dll_path</code> is provided in the following example:
  166. <a class="ulink" href="https://github.com/hsluoyz/WinDump/commit/dffe2eaa520fc3b449ec0a90dcfa24f96359bbfa" target="_top">WinDump</a></p>
  167. </div>
  168. </div>
  169. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-native-servicename"></a>Service name</h4></div></div></div>
  170. <p>Because Npcap is a NDIS 6 LWF filter driver it is designed to run
  171. at system boot, so software will generally not need to start it,
  172. unlike WinPcap which was often installed in a demand-start
  173. configuration.</p>
  174. <p>Npcap uses service name <span class="quote">&#8220;<span class="quote">npcap</span>&#8221;</span> instead of WinPcap's <span class="quote">&#8220;<span class="quote">npf</span>&#8221;</span> with
  175. <span class="quote">&#8220;<span class="quote">WinPcap Compatible Mode</span>&#8221;</span> OFF. So applications using
  176. <span class="command"><strong>net start npf</strong></span> for starting service must change to this:
  177. run <span class="command"><strong>net start npcap</strong></span> first, if it fails, then try
  178. <span class="command"><strong>net start npf</strong></span>.</p>
  179. </div>
  180. </div>
  181. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-feature-loopback"></a>For software that uses Npcap loopback feature</h3></div></div></div>
  182. <p>
  183. Npcap 0.9983 and newer support loopback traffic capture and injection without requiring a particular installation option.
  184. </p>
  185. <p>
  186. Npcap's loopback adapter device is reported by
  187. <code class="function">pcap_findalldevs()</code> as
  188. <span class="quote">&#8220;<span class="quote">\Device\NPF_Loopback</span>&#8221;</span>. This name is always available even
  189. if <span class="quote">&#8220;<span class="quote">Legacy loopback support</span>&#8221;</span> was chosen at install time,
  190. which puts the name of the legacy loopback adapter in the
  191. <code class="filename">LoopbackAdapter</code> REG_SZ value of the
  192. <code class="filename">HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\npcap\Parameters</code>.
  193. Registry key.
  194. </p>
  195. <p>
  196. Traffic captured and injected on the loopback adapter uses the
  197. <code class="varname">DLT_NULL</code> data link type, which consists of a 4-byte
  198. header in host byte order that is either 2 for IPv4 packets or 24 for
  199. IPv6 packets.
  200. </p>
  201. <p>
  202. The MTU of <span class="quote">&#8220;<span class="quote">Npcap Loopback Adapter</span>&#8221;</span> is hard-coded to 65536 by Npcap. Software
  203. using Npcap should get this value automatically and no special handling is needed. This value is
  204. arbitrary and does not imply a limitation on the Windows loopback stack,
  205. so it may be possible to capture packets with a size larger than the adapter's MTU.
  206. </p>
  207. <p>
  208. Don't try to make OID requests to <span class="quote">&#8220;<span class="quote">Npcap Loopback Adapter</span>&#8221;</span> except
  209. <code class="varname">OID_GEN_MAXIMUM_TOTAL_SIZE</code> (MTU). Those requests will still succeed like
  210. other adapters do, but they only make sense for NDIS adapters and Npcap doesn't even use the
  211. NDIS way to handle the loopback traffic. The only handled OID request by Npcap is
  212. <code class="varname">OID_GEN_MAXIMUM_TOTAL_SIZE</code>. If you query its value, you will always get
  213. 65550 (65536 + 14). If you try to set its value, the operation will always fail.
  214. </p>
  215. <p>If you use IP Helper API to get adapter list, you will get an interface named
  216. like <span class="quote">&#8220;<span class="quote">Loopback Pseudo-Interface 1</span>&#8221;</span>. This interface is a DUMMY interface by Microsoft
  217. and can't be seen in NDIS layer. And it also takes the 127.0.0.1/::1 IP address. A good practice
  218. for software is replacing the <code class="varname">AdapterName</code> of the
  219. <span class="quote">&#8220;<span class="quote">Loopback Pseudo-Interface 1</span>&#8221;</span> entry with
  220. <span class="quote">&#8220;<span class="quote">NPF_Loopback</span>&#8221;</span>, as Nmap does in its enhancements to
  221. libdnet.</p>
  222. <p><span class="quote">&#8220;<span class="quote">Legacy loopback support</span>&#8221;</span> installs a copy of the
  223. Microsft KM-TEST loopback adapter named <span class="quote">&#8220;<span class="quote">Npcap Loopback
  224. Adapter</span>&#8221;</span> for software that expects to find the loopback adapter
  225. via ordinary Windows API calls. The features and operation are no
  226. different from standard loopback support, but the
  227. name of the adapter will be written to the
  228. <code class="filename">LoopbackAdapter</code> Registry value.
  229. </p>
  230. </div>
  231. <div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="npcap-feature-dot11"></a>For software that uses Npcap raw 802.11 feature</h3></div></div></div>
  232. <p>
  233. Prerequisite: Check the <code class="option">Support raw 802.11 traffic (and monitor mode) for wireless adapters</code> option at install-time.
  234. </p>
  235. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-steps"></a>Steps</h4></div></div></div>
  236. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Install the latest version Npcap with the
  237. <code class="option">Support raw 802.11 traffic (and monitor mode) for wireless
  238. adapters</code> option checked in the installation wizard. With this
  239. option checked, Npcap will see packets with <span class="emphasis"><em>Radiotap +
  240. 802.11</em></span> headers for wireless adapters. Otherwise, Npcap will
  241. see packets with <span class="emphasis"><em>fake Ethernet</em></span> headers for wireless
  242. adapters.</p></li><li class="listitem"><p>Run <code class="filename">WlanHelper.exe</code> with
  243. <span class="emphasis"><em>Administrator privilege</em></span>. If you use
  244. <code class="option">-i</code>, follow the interactive prompts to choose your
  245. wireless adapter and select <span class="quote">&#8220;<span class="quote">Network Monitor</span>&#8221;</span> mode.
  246. <code class="filename">WlanHelper.exe</code> also supports parameters to be used
  247. in an API manner, run <span class="command"><strong>WlanHelper.exe -h</strong></span> for
  248. details.</p></li><li class="listitem"><p>Use the Npcap API from your user software as usual. For
  249. example, launch Wireshark and capture on the wireless adapter, viewingall
  250. 802.11 packets (<span class="emphasis"><em>data + control + management</em></span>).
  251. </p></li><li class="listitem"><p>If you need to return to <span class="quote">&#8220;<span class="quote">Managed Mode</span>&#8221;</span>, run
  252. <span class="command"><strong>WlanHelper.exe</strong></span> again, following the prompts or
  253. selecting the appropriate command-line options to switch off the
  254. <span class="quote">&#8220;<span class="quote">Monitor Mode</span>&#8221;</span>.</p></li></ul></div>
  255. </div>
  256. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-tips"></a>Tips</h4></div></div></div>
  257. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>You can use <code class="filename">WlanHelper.exe</code> tool to
  258. switch on the <span class="quote">&#8220;<span class="quote">Monitor Mode</span>&#8221;</span> in order to see
  259. <span class="emphasis"><em>802.11 control and management</em></span> packets. You
  260. can also use the <code class="code">pcap_set_rfmon</code> function within your
  261. code, as Wireshark does.
  262. </p></li><li class="listitem"><p>Switching on the <span class="quote">&#8220;<span class="quote">Monitor Mode</span>&#8221;</span> will
  263. disconnect your wireless network from the AP, you can switch back to
  264. <span class="quote">&#8220;<span class="quote">Managed Mode</span>&#8221;</span> using the same
  265. <code class="filename">WlanHelper.exe</code> tool.</p></li><li class="listitem"><p>The <code class="filename">WlanHelper.exe</code> tool is
  266. installed to <span class="quote">&#8220;<span class="quote">%SYSTEMROOT%\System32\Npcap</span>&#8221;</span> after installing Npcap.</p></li></ul></div>
  267. </div>
  268. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-terminology"></a>Terminology</h4></div></div></div>
  269. <p>
  270. <span class="quote">&#8220;<span class="quote">Managed Mode</span>&#8221;</span> (for Linux) = <span class="quote">&#8220;<span class="quote">Extensible Station Mode</span>&#8221;</span> (aka <span class="quote">&#8220;<span class="quote">ExtSTA</span>&#8221;</span>, for Windows)
  271. </p>
  272. <p>
  273. <span class="quote">&#8220;<span class="quote">Monitor Mode</span>&#8221;</span> (for Linux) = <span class="quote">&#8220;<span class="quote">Network Monitor Mode</span>&#8221;</span> (aka <span class="quote">&#8220;<span class="quote">NetMon</span>&#8221;</span>, for Windows)
  274. </p>
  275. <p>
  276. <span class="quote">&#8220;<span class="quote">Master Mode</span>&#8221;</span> (for Linux) = <span class="quote">&#8220;<span class="quote">Extensible Access Point</span>&#8221;</span> (aka <span class="quote">&#8220;<span class="quote">ExtAP</span>&#8221;</span>, for Windows)
  277. </p>
  278. </div>
  279. <div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a name="npcap-feature-dot11-wlanhelper"></a>WlanHelper</h4></div></div></div>
  280. <p>
  281. WlanHelper is used to set/get the operation mode (like <span class="quote">&#8220;<span class="quote">Monitor
  282. Mode</span>&#8221;</span>) for a wireless adapter on Windows. WlanHelper tries to
  283. follow the grammar of <code class="filename">iwconfig</code>, a wireless
  284. management tool for Linux. So if you rename
  285. <code class="filename">WlanHelper.exe</code> to <code class="filename">iwconfig.exe</code>,
  286. your command lines for WlanHelper will be exactly the same with the
  287. iwconfig tool.
  288. </p>
  289. <div class="sect4"><div class="titlepage"><div><div><h5 class="title"><a name="npcap-feature-dot11-wlanhelper-usage"></a>WlanHelper's Usage</h5></div></div></div>
  290. <p>
  291. Note: <span class="command"><strong>WlanHelper</strong></span> must run under <span class="emphasis"><em>Administrator privilege</em></span>.
  292. </p>
  293. <div class="sect5"><div class="titlepage"><div><div><h6 class="title"><a name="npcap-feature-dot11-wlanhelper-usage-interactive"></a>Interactive way</h6></div></div></div>
  294. <p>
  295. Run <span class="command"><strong>WlanHelper</strong></span> with the <code class="option">-i</code> option.
  296. </p>
  297. </div>
  298. <div class="sect5"><div class="titlepage"><div><div><h6 class="title"><a name="npcap-feature-dot11-wlanhelper-usage-api"></a>Command-line API way</h6></div></div></div>
  299. <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>Run <span class="command"><strong>netsh wlan show interfaces</strong></span>, get the <code class="option">Name</code> or <code class="option">GUID</code> for the interface.</p></li><li class="listitem"><p>Run <span class="command"><strong>WlanHelper -h</strong></span> to see the man page.</p></li></ul></div>
  300. <div class="example"><a name="npcap-ex-wlanhelper-man"></a><p class="title"><b>Example 1. WlanHelper Man</b></p><div class="example-contents">
  301. <pre class="screen">
  302. C:\&gt; <strong class="userinput"><code>WlanHelper.exe</code></strong>
  303. WlanHelper for Npcap 0.91 ( https://npcap.com )
  304. Usage: WlanHelper [Commands]
  305. or: WlanHelper {Interface Name or GUID} [Options]
  306. OPTIONS:
  307. mode : Get interface operation mode
  308. mode &lt;managed|monitor|master|..&gt; : Set interface operation mode
  309. modes : Get all operation modes supported by the interface, comma-separated
  310. channel : Get interface channel
  311. channel &lt;1-14&gt; : Set interface channel (only works in monitor mode)
  312. freq : Get interface frequency
  313. freq &lt;VALUE&gt; : Set interface frequency (only works in monitor mode)
  314. modu : Get interface modulation
  315. modu &lt;dsss|fhss|irbaseband|ofdm|hrdsss|erp|ht|vht|ihv (VALUE)|..&gt; : Set interface modulation
  316. modus : Get all modulations supported by the interface, comma-separated
  317. COMMANDS:
  318. -i : Enter the interactive mode
  319. -h : Print this help summary page
  320. OPERATION MODES:
  321. managed : The Extensible Station (ExtSTA) operation mode
  322. monitor : The Network Monitor (NetMon) operation mode
  323. master : The Extensible Access Point (ExtAP) operation mode (supported from Windows 7 and later)
  324. wfd_device : The Wi-Fi Direct Device operation mode (supported from Windows 8 and later)
  325. wfd_owner : The Wi-Fi Direct Group Owner operation mode (supported from Windows 8 and later)
  326. wfd_client : The Wi-Fi Direct Client operation mode (supported from Windows 8 and later)
  327. 802.11 MODULATIONS (https://en.wikipedia.org/wiki/IEEE_802.11):
  328. 802.11-1997 : dsss, fhss
  329. 802.11a : ofdm
  330. 802.11b : dsss
  331. 802.11g : ofdm
  332. 802.11n : mimo-ofdm
  333. 802.11ac : mimo-ofdm
  334. EXAMPLES:
  335. WlanHelper Wi-Fi mode
  336. WlanHelper 42dfd47a-2764-43ac-b58e-3df569c447da channel 11
  337. WlanHelper 42dfd47a-2764-43ac-b58e-3df569c447da freq 2
  338. WlanHelper "Wireless Network Connection" mode monitor
  339. SEE THE MAN PAGE (https://github.com/nmap/npcap) FOR MORE OPTIONS AND EXAMPLES</pre>
  340. </div></div><br class="example-break">
  341. <p>
  342. An example:
  343. </p>
  344. <div class="example"><a name="npcap-ex-wlanhelper-api"></a><p class="title"><b>Example 2. WlanHelper API Usage</b></p><div class="example-contents">
  345. <pre class="screen">
  346. C:\&gt; <strong class="userinput"><code>netsh wlan show interfaces</code></strong>
  347. There is 1 interface on the system:
  348. Name : <em class="replaceable"><code>Wi-Fi</code></em>
  349. Description : Qualcomm Atheros AR9485WB-EG Wireless Network Adapter
  350. GUID : <em class="replaceable"><code>42dfd47a-2764-43ac-b58e-3df569c447da</code></em>
  351. Physical address : a4:db:30:d9:3a:9a
  352. State : connected
  353. SSID : LUO-PC_Network
  354. BSSID : d8:15:0d:72:8c:18
  355. Network type : Infrastructure
  356. Radio type : 802.11n
  357. Authentication : WPA2-Personal
  358. Cipher : CCMP
  359. Connection mode : Auto Connect
  360. Channel : 1
  361. Receive rate (Mbps) : 150
  362. Transmit rate (Mbps) : 150
  363. Signal : 100%
  364. Profile : LUO-PC_Network
  365. Hosted network status : Not available
  366. C:\&gt; <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode</code></strong>
  367. managed
  368. C:\&gt; <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode monitor</code></strong>
  369. Success
  370. C:\&gt; <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode </code></strong>
  371. monitor
  372. C:\&gt; <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode managed</code></strong>
  373. Success
  374. C:\&gt; <strong class="userinput"><code>WlanHelper.exe <em class="replaceable"><code>wi-fi</code></em> mode</code></strong>
  375. managed</pre>
  376. </div></div><br class="example-break">
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. </div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="npcap-users-guide.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="npcap-api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Npcap Users' Guide </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> The Npcap API</td></tr></table></div></body></html>