Personal Understanding of NDIS development based on passthru

Source: Internet
Author: User

The basic idea of learning NDIS over the past few days is: first familiarize yourself with the theoretical knowledge → then download an example for research → last example for self-imitation extension → finally try to write a new one.

Passthru is a framework Driver written by Microsoft NDIS. NDIS developers can expand the framework and perform secondary development.
NDIS provides some basic operation functions. The functions in passthru are a network driver made of these basic functions.

The Extension Based on passthru is encapsulated on the basis of this driver. For example, for mypassthru, the functions in NDIS are encapsulated in their own custom functions for external calls.
The main function is ptreceive or ptreceivepacket in NDIS (responsible for receiving network packets), mpsend or mpsendpacket (responsible for sending packets prepared by the upper layer to the network ), these four callback functions are the key to packet interception and filtering.

In general, NDIS-basedProgramThere are three main parts: application, driver, and communication between the two:

(1) Driver Based on the NDIS intermediate layer (Passthru. sys)
This program runs in kernel mode and mainly has the following functional modules:
A. network packet interception: capture all received packets between the data link layer and the network layer.
B. network packet filtering: determines the behavior (allow or discard) of each packet based on the filtering rules)
C. Network Packet sending: Send user-constructed packets to the network

(2)application layer test program (ndisdemo.exe)
Applications mainly control driver behaviors and have the following functional modules:
A. Packet parsing: analyze the underlying packets
B. Set the driver to control the driving behaviors, such as the number of buffers and filter rules.
C. Construct a packet, construct any data packet, and control the driver to send the packet.

(3) communication between drivers and Applications
A. This article uses the shared memory method described in the document. The application layer can directly perform operations on the memory after obtaining the shared Intranet address, thus reducing the number of data copies;
B. to reduce packet loss in the driver when the application parses data packets, apply for a large buffer (as shared memory) in the kernel ), uses the cyclic queue method to access the buffer zone;
C. To further improve the efficiency, the driver notifies the application of events only after a certain number of caches. At the same time, the timer mechanism is used to ensure that all data can be read by the application.

The first part only needs to be understood by developers. The key is to deal with the connection between the second and third parts.
Of course, the second part is just an example. You can also write your own library, and then the specific application will directly call the library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.