locked
forward TCP mode ,why transfer flow is very slow (only 200kbits/s) ? RRS feed

  • Question

  • forward TCP mode ,why transfer flow is very slow (only 200kbits/s) ?
    the main work by dpc , here's the source code:
    VOID
    InjectPacket(
        IN WDFDPC Dpc
        )
    {
        NTSTATUS    status = STATUS_SUCCESS ;
        LListItem*  pItem  = NULL ;
        InjectInfo* pInjectInfo = NULL ;

    #ifdef SHOW_TIME
     LONGLONG    llStart = 0 ,
              llEnd   = 0 ;
     LONGLONG    llTmpStart = 0 ,
              llTmpEnd   = 0 ;
    #endif

     KIRQL      irql ;

        UNREFERENCED_PARAMETER(Dpc) ;
        //UNREFERENCED_PARAMETER(pDeferredContext) ;
        //UNREFERENCED_PARAMETER(pSystemArgument1) ;
        //UNREFERENCED_PARAMETER(pSystemArgument2) ;

     ASSERT_DBG((KeGetCurrentIrql() == DISPATCH_LEVEL)) ; /* Mukund J*/

        LOCKinDPC(&gDriverMutex) ;

        while( (pItem = LListGetFirst(gpInjectQueue)) != NULL )
        {
            pInjectInfo = (InjectInfo*)pItem->pObject ;
    #ifdef SHOW_TIME
      llTmpStart = 0 ;
      llTmpEnd   = 0 ;
      llTmpStart = GetCycleCount();
    #endif

            if( pItem->type == OT_INJECT_SEND )
            {
    #ifdef SHOW_TIME
       llStart = 0 ;
       llEnd   = 0 ;
       llStart = GetCycleCount();
    #endif
                LListRemove(gpInjectQueue, pItem) ;
                UNLOCKinDPC(&gDriverMutex);
    #ifdef SHOW_TIME
       llEnd = GetCycleCount();


       llStart = 0 ;
       llEnd   = 0 ;
       llStart = GetCycleCount();
    #endif
                status = HandleEsspConnect(pInjectInfo) ;
                if( !NT_SUCCESS(status) )
                    goto errorexit ;
    #ifdef SHOW_TIME
       llEnd = GetCycleCount();
       DbgPrint( "HandleEsspConnect cost time %I64d\n" , (llEnd-llStart));

       llStart = 0 ;
       llEnd   = 0 ;
       llStart = GetCycleCount();
    #endif
                status = InjectSendPacket(pInjectInfo) ;
                if( !NT_SUCCESS(status) )
                    goto errorexit ;

    #ifdef SHOW_TIME
       llEnd = GetCycleCount();
       DbgPrint( "InjectSendPacket cost time %I64d\n" , (llEnd-llStart));
    #endif
                LOCKinDPC(&gDriverMutex) ;
            }
    #ifdef SHOW_TIME
      llTmpEnd = GetCycleCount();
      DbgPrint( "OT_INJECT_SEND cost time %I64d\n" , (llTmpEnd-llTmpStart));

      llTmpStart = 0 ;
      llTmpEnd   = 0 ;
      llTmpStart = GetCycleCount();
    #endif

      if( pItem->type == OT_INJECT_RECV )
            {
                LListRemove(gpInjectQueue, pItem) ;
                UNLOCKinDPC(&gDriverMutex);


                status = InjectReceivePacket(pInjectInfo) ;
                if( !NT_SUCCESS(status) )
                    goto errorexit ;

               LOCKinDPC(&gDriverMutex) ;
            }
    #ifdef SHOW_TIME
      llTmpEnd = GetCycleCount();
      DbgPrint( "OT_INJECT_RECV cost time %I64d\n" , (llTmpEnd-llTmpStart));
    #endif
        }

        UNLOCKinDPC(&gDriverMutex);

    errorexit:

        return ;
    }

    in this code,  SHOW_TIME was added by me,  I wanna get the code execute time . I find if( pItem->type == OT_INJECT_SEND ) cost most time , logs snippet just like:

    LListRemove cost time 99
    HandleEsspConnect cost time 1837
    InjectSendPacket cost time 791351
    OT_INJECT_SEND cost time 43323500
    OT_INJECT_RECV cost time 616

    I am very wondered this result.

    here is the GetCycleCount():

    __int64 GetCycleCount()
    {
     __asm _emit 0x0F
     __asm _emit 0x31
    }

    thank you

    Monday, July 26, 2010 6:12 AM