Results 1 to 6 of 6

Thread: [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

    Here's a Demo of the Tcp Extended Stats APIs, translated from MSDN.
    GetPerTcpConnectionEStats --> https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    Name:  TcpEStats.jpg
Views: 819
Size:  40.7 KB
    Attached Files Attached Files
    Last edited by DEXWERX; May 7th, 2018 at 11:11 AM.

  2. #2
    Member
    Join Date
    Jun 2013
    Posts
    43

    Re: [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

    Thank you. I will see what I can do with this. Trying to get all traffic for all connections along with RTT

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

    Small bug with the ToggleEStat() function. My refactoring/simplification left out a couple flags. I'll post an update later on.

    for now here's the updated function.
    Code:
    '
    ' Enable or disable the supplied EStat type on a TCP connection.
    '
    Sub ToggleEStat(ByVal Row As Long, _
                    ByVal EStatsType As TCP_ESTATS_TYPE, _
                    ByVal Enable As Boolean, _
                    ByVal V6 As Boolean _
                    )
        Dim Status As Long
        Dim Size As Long
        Dim Rw As Long
        Dim EnableRw As Byte ' BOOLEAN
        Dim BandwidthRw As TCP_ESTATS_BANDWIDTH_RW_v0
        
        If Enable Then EnableRw = TRUE_ ' TRUE == 1 == TcpBoolOptEnabled
        
        Select Case EStatsType
            Case TcpConnectionEStatsBandwidth
                BandwidthRw.EnableCollectionInbound = EnableRw
                BandwidthRw.EnableCollectionOutbound = EnableRw
                Rw = VarPtr(BandwidthRw)
                Size = LenB(BandwidthRw)
            Case TcpConnectionEStatsSynOpts To TcpConnectionEStatsFineRtt
                Rw = VarPtr(EnableRw)
                Size = LenB(EnableRw)
            Case Else
                Exit Sub
        End Select
    
        If V6 Then
            Status = SetPerTcp6ConnectionEStats(ByVal Row, EStatsType, _
                                                ByVal Rw, 0, Size, 0)
        Else
            Status = SetPerTcpConnectionEStats(ByVal Row, EStatsType, _
                                               ByVal Rw, 0, Size, 0)
        End If
    
        If Status <> NO_ERROR Then
            wprintf "SetPerTcp{2}ConnectionEStats {0} {1} failed. {3}", _
                    EStatsTypeNames(EStatsType), IIf(Enable, "enabled", "disabled"), _
                    IIf(V6, "6", ""), DLLError(Status, "iphlpapi")
        End If
    End Sub
    Last edited by DEXWERX; May 7th, 2018 at 08:43 AM.

  4. #4
    Member
    Join Date
    Jun 2013
    Posts
    43

    Re: [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

    Hi all,

    have done some more work on this. Just one question. I am interested in a bunch of stuff from TCP_ESTATS_PATH_ROD_v0 and am concerned that in particular that things like BytesRetrans is an unsigned long and my code is using a signed long and calculating the delta to log between this sample and the last sample. Will I not run into issues when the value exceeds what VB cal store in a signed long (so it goes negative I am assuming) or will the delta between the last sample (negative) and this sample (negative) actually be the correct number. Sorry if this is a dumb question !!

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

    definitely not a dumb question, but it does have a very simple answer.
    There's no difference between between Signed (2's complement) and Unsigned addition or subtraction. So feel free to do your addition/subtraction using signed longs.
    The only thing you need to worry about is overflow... you could use an API like VarAdd, to ignore the overflow.
    just remember to display them unsigned.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: [VB6] Tcp Extended Stats API / GetPerTcpConnectionEStats

    You can see if something like this works for you.

    Code:
    Public Function ULongLongSub(LeftSub As Currency, RightSub As Currency) As Currency
        Dim L, R, S, HResult As Long
        L = LeftSub:    VarVT(L) = vbLongLong
        R = RightSub:   VarVT(R) = vbLongLong
        'HResult = VarSub(VarPtr(L), VarPtr(R), VarPtr(S))
        'If HResult < 0 Then Err.Raise HResult
        S = L - R
        VarVT(S) = vbCurrency
        ULongLongSub = S
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width