Bandwidth limit with NDIS IM driver

Discussion in 'Windows Vista Drivers' started by serge, Dec 18, 2004.

  1. serge

    serge Guest

    Hello,

    I want to limit TCP bandwidth using NDIS IM traffic.
    I know when and what packets to drop exactly.

    But I am not sure how to drop them without breaking entire connection.

    I am improving Passthru DDK sample. I tried to return different status codes
    in PtReceive() and MPSend() without any luck.

    Any thoughts would be greatly appreciated.

    Best regards,
    Serge.
     
    serge, Dec 18, 2004
    #1
    1. Advertisements

  2. serge

    Pavel A. Guest

    A thought.... Don't be the next guy to reinvent the wheel.
    Somebody had had this done before. Search for prototypes, read on theory of QoS...

    Good luck,
    --PA
     
    Pavel A., Dec 18, 2004
    #2
    1. Advertisements

  3. serge

    serge Guest

    Hello, Pavel!
    You wrote on Sat, 18 Dec 2004 19:54:06 +0200:

    PA> A thought.... Don't be the next guy to reinvent the wheel.
    PA> Somebody had had this done before. Search for prototypes, read on
    PA> theory of QoS...

    I read a lot about this.

    You can not support QoS if it's not supported by operating system.
    QoS RSVP service is stopped by default in Windows 2000.

    So, I have to invent new wheel.

    I know theory, but I do not understand how this can be done in Windows
    (please do not reffer to dummynet, it's not Windows).

    Thanks.

    --
    Serge


    PA> Good luck,
    PA> --PA



    With best regards, serge. E-mail:
     
    serge, Dec 18, 2004
    #3
  4. serge

    Pavel A. Guest

    Ok. For example, have you seen this?
    http://deterministicnetworks.com/Products/Bandwidth_Management.asp
    Can you tell how your requirements differ from what they provide?

    About the reasons why MS dropped RSVP after win2k - haven't seen any explanation yet,
    will be grateful if somebody kindly points me to it.

    /* My own incompetent guess is, this was simply because negative balance of demand
    to support QoS in the OS itself vs. cost of implementation.
    Support of traffic control has moved into managed network infrastructure (Cisco).
    And same with support of QoS: it either moved to infrastructure providers (using custom gateways etc),
    or implemented in applications (such as Skype) on existing network. */
    --PA
     
    Pavel A., Dec 18, 2004
    #4
  5. Bandwidth is not necessary QoS.

    Things like FreeBSD's "dummynet" is not connected to QoS IIRC, just the
    stupid limiter.
     
    Maxim S. Shatskih, Dec 19, 2004
    #5
  6. serge

    Steve Guest

    Dropping packets is easy. To drop an inbound packet dont
    call NdisMIndicateReceivePacket in ptReceive /
    ptReceivePacket, to drop an outbound packet dont call
    NdisSend in MPSendPackets ... by the way, if you have an
    MPSendPackets function your MPSend will never get called!

    For Qos you will need to implement some kind of queueing
    mechanism - this will involve copying packets - passthru
    only copies packet descriptors and then points them to
    the original payload, but you will need to copy the
    payload as well if you want to queue the packets for
    sending later (possibly in a timer).

    Good luck.
    Steve.
     
    Steve, Dec 19, 2004
    #6
  7. No, you do not need to copy the packet data (payload) as long as you do
    not return the original NDIS_PACKET to NDIS. If you want to use
    PASSTHRU as a starting point, simply add the *original* NDIS_PACKET to
    a queue in MPSend[Packets]() and have your QoS mechanism handle this
    queue.

    Then, when your QoS dequeues an NDIS_PACKET, handle it the same way
    PASSTHRU originally did. That should do the trick.

    Not sure if QoS makes sense for the receive path also (maybe it does).
    Stephan
     
    Stephan Wolf [MVP], Dec 22, 2004
    #7
  8. serge

    serge Guest

    Hello, Stephan!

    Thanks for the information.
    Please find my comments below.

    SWM> No, you do not need to copy the packet data (payload) as long as you
    SWM> do not return the original NDIS_PACKET to NDIS. If you want to use
    SWM> PASSTHRU as a starting point, simply add the *original* NDIS_PACKET to
    SWM> a queue in MPSend[Packets]() and have your QoS mechanism handle this
    SWM> queue.

    Could you please tell me how to silently drop packets? I tried your
    suggestion, and it seems to work fine (at least I do not receive BSOD
    anymore:). But now TCP connection breaks for some reason if I queue packets.

    In my new MPSendPackets() I do nothing but queue packets.
    I do not call any Ndis* functions there.

    All queued packets are sent in separate thread using origial MPSendPackets
    function provided in PassThru sample.

    Is that correct approach?
    Thanks.

    Serge.
     
    serge, Dec 24, 2004
    #8
  9. serge

    Pavel A. Guest

    Which connections break - incoming or outgoing?

    --PA
     
    Pavel A., Dec 24, 2004
    #9
  10. serge

    serge Guest

    Hello, Pavel!
    You wrote on Fri, 24 Dec 2004 02:41:14 +0200:

    PA> Which connections break - incoming or outgoing?

    A few words about how I test driver: I am using FTP servers installed both
    on host computer and vmware in order to transfer large files. Driver is
    installed on vmware virtual computer. Both FTP servers operate in passive
    mode.

    If I connect host computer --> FTP server on vmware (incoming connection),
    it is broken.

    If I connect vmware --> FTP server on host computer (outbound connection),
    it works well, but there is a small problem, though. Packets are queued and
    send well, but FTP server continue to send new packets and my queue becomes
    very large. Is there any way to 'pause' FTP server?

    Thank you for the help.

    With best regards,
    Serge.
     
    serge, Dec 24, 2004
    #10
  11. send well, but FTP server continue to send new packets and my queue becomes
    No, this will be done automatically by TCP's congestion avoidance.

    Your shaper must do the following:
    - have a set of "queue" objects
    - just drop the packet on the floor instead of adding it to the queue if the
    queue is too long
    - consume not more then a given amount of bytes/s from the consumer end of the
    queue.

    There must be some per-queue signed LONG variable named like "Overhead", there
    must also be a timer routine firing as often as possible.

    The timer routine does the following:
    - gets the time elapsed since its last firing
    - enumerates all queues
    - for each queue, multiplies this TimeElapsed by BandwidthLimit and increments
    Overhead by it
    - then executes the QueueConsume routine

    The packet arrival routine does the following:
    - finds the queue to which the packet belongs
    - checks whether the queue is oversized, if yes - drops the packet on the floor
    - otherwise, attaches it to the head of the queue
    - calls QueueConsume routine

    The QueueConsume routine does:
    - checks whether the data size of the tail packet in the queue is <= Overhead
    - if no - quits
    - if yes - detaches the tail packet from the queue, decrements the Overhead by
    its data size and then delivers the packet to the destination (NdisSend for
    outgoing packets, NdisMIndicateReceivePacket for incoming).

    This is a nearly full logic of the traffic shaper, I only have omitted the
    locking issues - which locks guard what and so on.

    You must also have set of some control calls to create and delete queues,
    manipulate their attributes and query their status.
     
    Maxim S. Shatskih, Dec 25, 2004
    #11
  12. serge

    Pavel A. Guest

    Never drop TCP ACKs - not separate and not piggybacked.
    Inventing your own bicycle is fun, but do you have too much
    spare time to make all nuts and bolts from scratch?

    --PA
     
    Pavel A., Dec 25, 2004
    #12
    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.