NL2NICDriverSample
NL2NICDriverSample provides a basic example of a NIC Driver for the Network Link Layer (NL2). This sample doesn't control a hardware device but simulates some NICs with basic functionality. The driver simulates immediate consumption of every buffer submitted for transmit and simulates immediate filling, with dummy content, of every buffer submitted for receive.
NL2NICDriverSample provides these capabilities:
- Simulate the existence of 4 NICs.
- Supports 4 Transmit Queues, each with 8 to 1024 DMA descriptors (configurable by steps of 8).
- Supports 2 Receive Queues, each with 8 to 1024 DMA descriptors (configurable by steps of 8).
- Supports Line-Based, MSI, and MSI-X with 5 messages.
- Supports Jumbo packets up to 2000 bytes.
- Supports VLANs.
- Supports auto-negotiation or these forced-link options: 10Mbps Half-duplex, 100Mbps Full-duplex.
- Supports Promiscuous mode.
- Supports Pass Bad Frames mode.
- Supports EtherType dispatching with 5 slots.
- Supports Launch Time functionality on all Transmit Queues.
- Supports Credit-Based Shaper on Transmit Queues 0 and 1.
- Supports special functions.
You can find the sample files at .
Source Files
| File | Description |
|---|---|
NL2NICDriverSample.c
|
Driver source code. |
|
NL2NICDriverSampleSpecialFunctions.h |
A header file containing sample special functions of a device. |
Building the Sample
This sample application requires Visual Studio 2022.
- Open NL2NICDriverSample.sln in Visual Studio 2022.
- Set the configuration to RTSSRelease.
- Build the solution.
You should end up with an RTDLL file called NL2NICDriverSample.rtdll.
Running the Sample
- Create an NL2 Interface in wRTOS Settings.
- Set DriverPathname to NL2NICDriverSample.rtdll (make sure that the file’s location is in the wRTOS search path; see wRTOS Settings for more information).
- Set PciLocation to one of the four locations that the driver simulates (see the code in
NL2NICDriverSample.c). - Start the NL2 through wRTOS Settings or wRTOS Control Panel.
By default, NL2NICDriverSample prints traces on the console output whenever one of its entry point functions is called by the NL2. You can modify it to behave differently and observe its behavior when you start the NL2 and run an application that links with the NL2.
Remarks
You can use NL2NICDriverSample for the following purposes:
- Understand how a NIC driver should be structured.
- Use as a starting point for developing a custom NIC driver for a real NIC.
- Run it with a real application to understand how the NL2 interacts with the NIC driver.
- Modify the sample source to see how your modifications affect external NL2 behavior.
- Use it as reference when NL2 behavior is not sufficiently detailed in the documentation.
APIs Referenced
|
RTAPI functions |
Supported Windows functions |
|---|---|