locked
Cannot send packets for local addresses (one local to another local) through virtual loopback driver, NDIS 5.1 RRS feed

  • Question

  • Hello,

    I am new to WDD & I am trying to create a loopback driver. I want to create a virtual driver which will perform the following -

    I want to have two identical interface with different network address. And I want to send data from one interface to another interface. Whenever I send a packet from interface1 to interface2, instead of calling NdisSendPacket I want to modify the packet and notify the interface1 that send was successful by calling NdisSendComplete indication. At the MPSendPackets function I want to perform some modification like swapping MAC, Net address then put the buffer into new packet, put it in the receiving queue and call the NdisReceiveIndication to inform ndis that a packet was received.

    Now the problem is, as the two network is local to computer, the packet does not reaches the MPSendPackets. Instead of calling the function, the system loopbacks it from upper layer, which is not what I want. Is there any way to forcefully send all packets (Including local addresses) through MPSendPackets?

    Also it would be helpful if you could verify my concept of loopback driver.

    I am using only miniport driver. If the functionality can be done with other driver like - ID, TDI please let me know.

    Thank you in advance & sorry for my English.

    Thursday, March 17, 2011 4:15 AM

Answers

  • Somehow I managed to do this later on NDIS 6.20.

    You can indicate the loopback packet iff -

    1. ip checksum ok (recalculate)

    2. udp/ tcp checksum ok (recalculate)

    3. indicating up the packets

    I think this is a dead topic, still though I should share the general process.

    regards,


    fadedreamz
    • Marked as answer by fadedreamz Wednesday, September 28, 2011 7:05 AM
    Wednesday, September 28, 2011 7:05 AM

All replies

  • Is this just a learning experience?  Because I think you have already discovered why it would not be a particularly useful construct - TCPIP will loop the traffic back all by itself.

    So depending on what you are trying to actually accomplish you can see your choices are to send a packet to a destination address that is *reachable* over your virtual miniport link(s) or send a packet that TCPIP will always send on any or all links.

    The first approach:   Assume VNIC1 is 192.168.201.1/24 and VNIC2 is 192.168.202.1/24  you can send packets to 192.168.201.2-254 and 192.168.202.2-254 assuming you have spoofed ARP on the entire subnet range.   Do whatever you need to do (edit the src/dst IP address) to 'loop back and NAT' the packet(s).

    The second approach:  Send multicast packets.   Bind your 'sender' to one VNIC's IP Address and your 'receiver' to the other VNIC's IP address and just 'loopback' the multicast packets as proof it is working.

    The third approach:  Virtual Machines - bind different virtual machines to each virtual NIC.  The two VMs will be happy to send packets to each other via your VNIC-VNIC path.

    If you go look back at the WDK/DDK the VMINI sample does infact do exactly what you say you are writing.    I hope you have taken advantage of the samples in the WDK/DDK to assist you in your learning.

    Good Luck,

    Dave Cattley

     


    David R. Cattley
    Thursday, March 17, 2011 1:49 PM
  • Thanks Cattley for your quick and helpful reply.

    As soon as I discovered that the TCP/IP itself was making the loopback, I understood what I have to do to forcefully loopback the packets from MPSendPackets (same as your first approach). But it seemed to me that it was not a good solution, because then the packet's destination address will be different from the VNIC address. That is why I was looking for a better solution to make the packets go through the MPSendPacket callback function.

    And as per your second suggestion, it should work if I use multicast packet.So, I will try this approach.

    I didn't get your last suggestion. Are you suggesting me to run two instance of window in VM (e,g - VMware) and then send one address to other one?If so then, I think it will work also :) (VNIC1->guest1->host->guest2->VNIC2).

    I am trying to learn NDIS using msdn library as primary source. But the documentation of NDIS look too much scattered to me. I am using netvmini example from wddk to clear my prof of concept regarding the NDIS architecture.

    Thank you again & sorry for my English.

    Regards,

    Shovon.


    fadedreamz
    Thursday, March 17, 2011 2:41 PM
  • Somehow I managed to do this later on NDIS 6.20.

    You can indicate the loopback packet iff -

    1. ip checksum ok (recalculate)

    2. udp/ tcp checksum ok (recalculate)

    3. indicating up the packets

    I think this is a dead topic, still though I should share the general process.

    regards,


    fadedreamz
    • Marked as answer by fadedreamz Wednesday, September 28, 2011 7:05 AM
    Wednesday, September 28, 2011 7:05 AM