|
|
NDIS Loopback Discussion
IntroductionUnder certain conditions packets that are sent a NDIS protocol by calling NdisSend or NdisSendPackets are "looped back" to the sender's ProtocolReceive or ProtocolReceivePacket handlers where they appear as if they were received from the network. Having a loopback facility greatly simplifies some aspects of network protocol implementation. One example concerns MAC-level broadcast packets. When a broadcast packet is sent all hosts on the local network (including the sending host) should receive the broadcast. NDIS loopback can be used loop the broadcast packet back to the local host where it is "received" as if it was actually from the network. From the perspective of the NDIS protocol sending a packet, loopback is simply an operation that is performed sometime between the point that NdisSend or NdisSendPackets is called to send packets and the point that the send is completed. There are several factors that control loopback behavior as observed by the sending NDIS protocol:
There are other factors that influence loopback the loopback implementation and and behavior to a limited extent. These include:
Protocol's NDIS Packet Filter SettingThe two primary factors that influence NDIS loopback are:
The protocol's NDIS packet filter is set when it makes a NdisRequest call to set information on OID_GEN_CURRENT_PACKET_FILTER. The packet filter specifies the types of net packets for which a protocol receives indications from a NIC driver. The "type of net packet" is really a filter on the receive packet's destination link address. For example:
The protocol can specify a bit combination of these NDIS packet types:
The DDK documentation provides more complete descriptions of the NDIS packet type values.
Send Packet's CharacteristicAs part of the NdisSend and NdisSendPackets operation NDIS examines each packet sent to decide whether it should be looped back to the sending protocol. The loopback decision is made just before the packet is returned to the protocol's ProtocolSendComplete handler. The loopback decision is made on the basis of two characteristics of the packet being sent:
The Flags used to inhibit loopback is the NDIS_FLAGS_DONT_LOOPBACK flag, defined in NDIS.H in the Windows 2000 and higher DDK.
On Windows 2000 (only) it is necessary to OR the undocumented value 0x400 with the NDIS_FLAGS_DONT_LOOPBACK flag to inhibit loopback of a send packet. This value is used in the Windows 2000 DDK MUX driver sample, where it is defined as:
Please do review the details of using these flags by examining the Windows XP DDK MUX driver sample. Unfortunately there are no similar loopback-inhibit flags on Windows 9X/ME or Windows NT 4.0. On those platforms there is no NDIS mechanism to inhibit loopback. One approach that may work in some designs is to filter received packets based on their source link address. If the received packet's source link address is the same as that of the NIC the packet is being received on, then the packet is a loopback packet.
Receive (looped-back) Packet's CharacteristicsThe NDIS header file defines this interesting NDIS_PACKET Flag:
Although the intended use of this flag is not difficult to infer, the actual use is not documented in the DDK Help file. Microsoft has provided this information concerning this flag:
Protocol's Options
Miniport's Options
In most cases physical miniports will report the NDIS_MAC_OPTION_NO_LOOPBACK option and let NDIS perform the send packet loopback.
Handling Miniport Options in a NDIS Intermediate DriverIf you are writing a NDIS IM driver then you will probably need to add code to deal with loopback packets. The code that you will need to add will depend on the functionality that you implement in your NDIS IM driver. In addition, there are runtime-dependent NDIS version differences in how you handle loopback in a NDIS IM driver. The goal of the NDIS IM driver loopback handling is to insure that higher-level protocols bound to the miniport edge of your driver see sane loopback behavior. Here are some things to consider:
The Windows XP Passthru NDIS IM driver filters completion OID_GEN_MAC_OPTIONS query to insure that the NDIS_MAC_OPTION_NO_LOOPBACK bit is NOT set. This effectively tells NDIS that the NDIS IM driver's miniport section actually has its own loopback mechanism. This is not really the case, but it works for PassThru because the lower-level miniport will perform the loopback.
For modifying NDIS IM drivers the trivial loopback process used in PassThru may not be correct. If instead, it may be more appropriate to set the NDIS_MAC_OPTION_NO_LOOPBACK, causing NDIS to loopback packet from the IM miniport edge, and also block packets looped back from the lower miniport.
Loopback QuirksThere are some "quirks" associated with NDIS loopback:
Loopback Packets May Not Appear To Have Correct Checksum
Loopback Packets Out Of Order
Network Monitors May Not See Sent Packets If NDIS IM Driver Installed
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
PCAUSA Home
· Privacy Statement ·
Products · Ordering · Support ·
Utilities ·
Resources
|