Getting quick IP address on P2P RNDIS network

Discussion in 'Windows Vista Drivers' started by Max Paklin, Aug 17, 2004.

  1. Max Paklin

    Max Paklin Guest

    There is a small problem that we've run into, which I hope somebody can help
    us with.

    We have a USB device, which supports RNDIS and that causes an XP machine to
    create a separate network for it. The device also creates a "remote" node on
    that network essensially establishing point-to-point network inside the
    device itself.

    Now to the problem, how do we quickly assign IP address to this network?
    I am looking for any suggestions - from totally legal to semi-legal. So far
    this device is restricted to a lab environment, but having fully supported
    solution is obviously preferred.

    Static IP assignment is out of question. So is auto IP as it is too slow.
    We need to be able to assign a address in a matter of seconds or even
    faster. Also a requirement - multiple instances of this device can be
    connected to the same machine and they all have to sit on separate networks
    and don't conflict with each other.
    The only solution that I can think of at a moment is to have the device
    being a DHCP server for its own net. Problem: multiple devices can be
    connected to the PC and there must be a solid algorithm in place to avoid
    any conflicts.

    I was also told that IPv6 would solve this issue.

    This is very generic problem and I am sure there are good solutions to it.
    Can anybody offers any suggestions or refer me to relevant RFC or something?
    Any help would be appreciated.

    -- Max.
    Max Paklin, Aug 17, 2004
    1. Advertisements

  2. I've done this before, and it works well. If the same driver owns all
    of the devices, the address synch issue is trivial. Otherwise, you
    could do any number of other inter-driver communication mechanisms to
    get it done.

    The DHCP code itself isn't complicated; I wrote mine from scratch based
    on the RFC and tested it against windows. Not many lines of code at
    all, and not terribly challenging if you've ever worked with protocols.

    Steve Dispensa [MVP], Aug 17, 2004
    1. Advertisements

  3. faster. Also a requirement - multiple instances of this device can be
    My suggestion is similar to Host-Only networking in VMWare.

    Write 2 drivers:
    - the Virtual Network driver (root-enumerated hardware-less), which is the NDIS
    - the device's driver, which has nothing to do with NDIS.

    Make these drivers tighly coupled, so that the device's driver will emulate the
    remote node and the Virtual Network driver will emulate the local adapter.

    Provide the users with the UI to set up the IP subnet info for this emulated
    network. The remote nodes will pull the IP addresses from this range.
    Maxim S. Shatskih, Aug 17, 2004
  4. Max Paklin

    Max Paklin Guest

    Thanks for the info Steve.

    I agree that getting this implemented is not difficult at all. The only
    problem is that the device is totally RNDIS based, so we don't have any
    drivers on the PC for this thing.
    All network protocol code is fully based on the device, i.e. all instances
    are running independently from each other, they don't know about each
    other's existence. Well... I guess we can mix device's own MAC address in
    the picture to make the IP unique.

    Thanks for the suggestion.
    -- Max.
    Max Paklin, Aug 17, 2004
  5. Max Paklin

    Max Paklin Guest

    Max, thanks for the suggestion.

    This won't work for me though. I have hard requirement of "no-driver"
    design, so I am limited to RNDIS (not that I wanted to change it given a
    chance). Therefore I will have a network-per-device scenario anyway. I can't
    get away from this.

    It seems like implementing DHCP server with some logic regarding assigning
    unique IP address range based on MAC address is a way to go for me. Now, how
    do I fit MAC address into something that keep subnet reasonably small?

    -- Max.
    Max Paklin, Aug 17, 2004
  6. While you cannot fake out DHCP at the driver level, because you don't own
    the drivers at the RNDIS layer -- but you can do the same at the device
    level. When you see a DHCP request, just packet up a reply/lease and
    return in as if your device got that packet off the wire. This would be
    done in your device microcode.

    Bryan S. Burgin

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Bryan S. Burgin [MSFT], Aug 18, 2004
  7. Max Paklin

    Max Paklin Guest

    Bryan, thanks for replying.

    Obviously we won't be cheating or playing any games with this. Our device
    creates a real network between USB chip that implements RNDIS and the DSP
    where the rest of the code is running. Pretty short and high speed link, but
    as far as anybody is concern it is p2p network. We can implement real DHCP
    server on the DSP (we have enough cycles and expertise to do that).

    The only issue is how to gaurantee that two devices connected to the same
    machine won't issue conflicting IP addresses.
    I can't seem to think of any reliable algorithm for that. Everything has a
    chance of creating a collision, which is OK for a lab but unacceptable for
    the real world.
    If you can think of anything please share.

    -- Max.
    Max Paklin, Aug 18, 2004
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.