当前位置: 首页 > 工具软件 > udp_over_tcp > 使用案例 >

UDP TCP 双流

张高义
2023-12-01
Imports System.IO
Imports System.Threading
Imports BaseDLL
Imports BaseDLL.BasePubModule
Imports Newtonsoft.Json
Imports ZedGraph

Public Class FormMultiThreadDataThroughput

    Private m_IpVersion As eIPVersionDT = eIPVersionDT.IPv4
    Private m_TransferTime As Integer = 60
    Private m_DLInterval As Integer = 1
    Private m_ULInterval As Integer = 1
    Private m_RemoteServerPDNAddr As String = "99.99.3.1"
    Private m_UEIPAddr As String = "99.99.3.2"
    Private m_ClientUEAssignedIPAddr As String = "192.168.42.167"
    Private m_ClientUEAssigneGateway As String = "192.168.42.249"
    Private m_TransferIterationNumber As Integer = 1
    Private m_StreamNumber As Integer = 1
    Private m_DLBlasterRate As String = "100M"
    Private m_DLBufferSize As String = "1M"
    Private m_DLThreads As Integer = 1
    Private m_ULBlasterRate As String = "50M"
    Private m_ULBufferSize As String = "1M"
    Private m_ULThreads As Integer = 1
    Private m_DLBlasterRate_2nd As String = "50M"
    Private m_DLBufferSize_2nd As String = "1M"
    Private m_DLThreads_2nd As Integer = 1
    Private m_ULBlasterRate_2nd As String = "20M"
    Private m_ULBufferSize_2nd As String = "1M"
    Private m_ULThreads_2nd As Integer = 1
    Private m_DTCmdData As clsDTCmdData
    Public m_ClientType As eCLIENT_TYPE = eCLIENT_TYPE.ADB
    Private m_TransfreDirectoin As eTransferDirection = eTransferDirection.Bidirection
    Private m_TransportLayerProtocol As eTransportLayerProtocol = eTransportLayerProtocol.UDP
    Private TOOL_LOG_LOCAL As String = Environment.CurrentDirectory + "\ToolLog\"

    Dim scpclient As clsWinSCP

    Private TOOL_LOG_REMOTE As String = "/tmp/"
    Private RC As New RemoteControl(m_RemoteServerAddr)

    'should add paras when add a thread
    Private UDP_TOOL_LOG_LOCAL_DL_Copy1 As String = Environment.CurrentDirectory + "\ToolLog\udp_dl_temp1.log"
    Private UDP_TOOL_LOG_LOCAL_DL_Copy2 As String = Environment.CurrentDirectory + "\ToolLog\udp_dl_temp2.log"
    Private UDP_TOOL_LOG_LOCAL_UL_Copy1 As String = Environment.CurrentDirectory + "\ToolLog\udp_ul_temp1.log"
    Private UDP_TOOL_LOG_LOCAL_UL_Copy2 As String = Environment.CurrentDirectory + "\ToolLog\udp_ul_temp2.log"
    Private TCP_TOOL_LOG_LOCAL_DL_Copy1 As String = Environment.CurrentDirectory + "\ToolLog\udp_dl_temp1.log"
    Private TCP_TOOL_LOG_LOCAL_DL_Copy2 As String = Environment.CurrentDirectory + "\ToolLog\udp_dl_temp2.log"
    Private TCP_TOOL_LOG_LOCAL_UL_Copy1 As String = Environment.CurrentDirectory + "\ToolLog\udp_ul_temp1.log"
    Private TCP_TOOL_LOG_LOCAL_UL_Copy2 As String = Environment.CurrentDirectory + "\ToolLog\udp_ul_temp2.log"

    Private b_UDP_DL_Decode_Finished1 = False
    Private b_UDP_DL_Decode_Finished2 = False
    Private b_UDP_UL_Decode_Finished1 = False
    Private b_UDP_UL_Decode_Finished2 = False
    Private b_TCP_DL_Decode_Finished1 = False
    Private b_TCP_DL_Decode_Finished2 = False
    Private b_TCP_UL_Decode_Finished1 = False
    Private b_TCP_UL_Decode_Finished2 = False

    Private UDPDLThread1 As Thread
    Private UDPDLThread2 As Thread
    Private UDPULThread1 As Thread
    Private UDPULThread2 As Thread
    Private UDPDLFileThread1 As Thread
    Private UDPDLFileThread2 As Thread
    Private UDPUpdateSumGraphThread As Thread

    Private TCPDLThread1 As Thread
    Private TCPDLThread2 As Thread
    Private TCPULThread1 As Thread
    Private TCPULThread2 As Thread
    Private TCPDLFileThread1 As Thread
    Private TCPDLFileThread2 As Thread
    Private TCPUpdateSumGraphThread As Thread



    Private File_No_Change_Time_Setting = 5
    Private UDPDLProcessedlineCount1 = 0
    Private UDPDLProcessedlineCount2 = 0
    Private UDPULProcessedlineCount1 = 0
    Private UDPULProcessedlineCount2 = 0
    Private TCPDLProcessedlineCount1 = 0
    Private TCPDLProcessedlineCount2 = 0
    Private TCPULProcessedlineCount1 = 0
    Private TCPULProcessedlineCount2 = 0

    Private linearPane As GraphPane = Nothing
    Private UDP_DL_Stream1 As LineItem = Nothing
    Private UDP_DL_Stream2 As LineItem = Nothing
    Private UDP_UL_Stream1 As LineItem = Nothing
    Private UDP_UL_Stream2 As LineItem = Nothing
    Private UDP_UL_SUM_Stream As LineItem = Nothing
    Private UDP_DL_SUM_Stream As LineItem = Nothing
    Private TCP_DL_Stream1 As LineItem = Nothing
    Private TCP_DL_Stream2 As LineItem = Nothing
    Private TCP_UL_Stream1 As LineItem = Nothing
    Private TCP_UL_Stream2 As LineItem = Nothing
    Private TCP_UL_SUM_Stream As LineItem = Nothing
    Private TCP_DL_SUM_Stream As LineItem = Nothing


    Private UDP_DL_List1 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private UDP_DL_List2 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private UDP_UL_List1 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private UDP_UL_List2 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private TCP_DL_List1 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private TCP_DL_List2 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private TCP_UL_List1 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    Private TCP_UL_List2 As List(Of clsDTInfo) = New List(Of clsDTInfo)
    '/should add paras when add a thread




    Private Sub BtnExecute_Click(sender As Object, e As EventArgs) Handles btnExecute.Click

        KillAllADBAndIperf()
        If Not Directory.Exists(TOOL_LOG_LOCAL) Then
            Directory.CreateDirectory(TOOL_LOG_LOCAL)
        End If

        AdbPushIperf()
        GetParaFromUI()
        Dim m_DTCmdCfgFile = Environment.CurrentDirectory() + "\DTCmdConfiguraiton\DTCmds-ADBPushBased.cfg"
        If Not ReadDTCmd(m_DTCmdCfgFile, m_DTCmdData) Then
            Return
        End If
        Init()

        StartTransfer()



    End Sub



    Private Sub KillAllADBAndIperf()
        Dim pros = Process.GetProcessesByName("adb")
        If pros.Count > 0 Then
            For Each item In pros
                item.Kill()
            Next
        End If
        RC.RunRemoteCommand("killall iperf")
    End Sub

    Private Sub Init()
        InitialGraph()
        UDP_DL_List1.Clear()
        UDP_DL_List2.Clear()
        UDP_UL_List1.Clear()
        UDP_UL_List2.Clear()
        TCP_DL_List1.Clear()
        TCP_DL_List2.Clear()
        TCP_UL_List1.Clear()
        TCP_UL_List2.Clear()

        UDPDLProcessedlineCount1 = 0
        UDPDLProcessedlineCount2 = 0
        UDPULProcessedlineCount1 = 0
        UDPULProcessedlineCount2 = 0
        TCPDLProcessedlineCount1 = 0
        TCPDLProcessedlineCount2 = 0
        TCPULProcessedlineCount1 = 0
        TCPULProcessedlineCount2 = 0

        b_UDP_DL_Decode_Finished1 = False
        b_UDP_DL_Decode_Finished2 = False
        b_UDP_UL_Decode_Finished1 = False
        b_UDP_UL_Decode_Finished2 = False
        b_TCP_DL_Decode_Finished1 = False
        b_TCP_DL_Decode_Finished2 = False
        b_TCP_UL_Decode_Finished1 = False
        b_TCP_UL_Decode_Finished2 = False

    End Sub

    Private Sub InitialGraph()

        linearPane = ZedGraphControl.GraphPane
        linearPane.XAxis.Title.Text = "Time"
        linearPane.YAxis.Title.Text = "Throughput"
        linearPane.Title.Text = "Throughput Test"
        linearPane.XAxis.Scale.Max = m_TransferTime
        linearPane.XAxis.Scale.Min = 0
        linearPane.YAxis.Scale.Min = -0

        linearPane.YAxis.Scale.Max = 220
        linearPane.CurveList.Clear()

        UDP_DL_Stream1 = Nothing
        UDP_DL_Stream2 = Nothing
        UDP_UL_Stream1 = Nothing
        UDP_UL_Stream2 = Nothing
        TCP_DL_Stream1 = Nothing
        TCP_DL_Stream2 = Nothing
        TCP_UL_Stream1 = Nothing
        TCP_UL_Stream2 = Nothing


        InitGraphCurveByProtocol()


        RefreshGraph()
    End Sub

    Private Sub InitUDPGraphCurve()
        Dim x_values(0) As Double
        Dim y_values(0) As Double
        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Download Then
            If m_StreamNumber >= 1 Then
                If IsNothing(UDP_DL_Stream1) Then
                    UDP_DL_Stream1 = linearPane.AddCurve("DL_Stream1", x_values, y_values, Color.DarkGreen, SymbolType.Circle)
                End If
            End If
            If m_StreamNumber >= 2 Then
                If IsNothing(UDP_DL_Stream2) Then
                    UDP_DL_Stream2 = linearPane.AddCurve("DL_Stream2", x_values, y_values, Color.DarkBlue, SymbolType.Circle)
                End If
            End If
        End If

        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Upload Then
            If m_StreamNumber >= 1 Then
                If IsNothing(UDP_UL_Stream1) Then
                    UDP_UL_Stream1 = linearPane.AddCurve("UL_Stream1", x_values, y_values, Color.Brown, SymbolType.Circle)
                End If
            End If
            If m_StreamNumber >= 2 Then
                If IsNothing(UDP_UL_Stream2) Then
                    UDP_UL_Stream2 = linearPane.AddCurve("UL_Stream2", x_values, y_values, Color.Red, SymbolType.Circle)
                End If
            End If
        End If
        If m_TransfreDirectoin = eTransferDirection.Bidirection Then
            If m_StreamNumber >= 2 Then
                If IsNothing(UDP_UL_SUM_Stream) Then
                    UDP_UL_SUM_Stream = linearPane.AddCurve("UL_SUM_Stream", x_values, y_values, Color.Plum, SymbolType.Circle)
                End If
                If IsNothing(UDP_DL_SUM_Stream) Then
                    UDP_DL_SUM_Stream = linearPane.AddCurve("DL_SUM_Stream", x_values, y_values, Color.Purple, SymbolType.Circle)
                End If
            End If
        End If
    End Sub

    Private Sub InitTCPGraphCurve()
        Dim x_values(0) As Double
        Dim y_values(0) As Double
        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Download Then
            If m_StreamNumber >= 1 Then
                If IsNothing(TCP_DL_Stream1) Then
                    TCP_DL_Stream1 = linearPane.AddCurve("DL_Stream1", x_values, y_values, Color.DarkGreen, SymbolType.Circle)
                End If
            End If
            If m_StreamNumber >= 2 Then
                If IsNothing(TCP_DL_Stream2) Then
                    TCP_DL_Stream2 = linearPane.AddCurve("DL_Stream2", x_values, y_values, Color.DarkBlue, SymbolType.Circle)
                End If
            End If
        End If

        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Upload Then
            If m_StreamNumber >= 1 Then
                If IsNothing(TCP_UL_Stream1) Then
                    TCP_UL_Stream1 = linearPane.AddCurve("UL_Stream1", x_values, y_values, Color.Brown, SymbolType.Circle)
                End If
            End If
            If m_StreamNumber >= 2 Then
                If IsNothing(TCP_UL_Stream2) Then
                    TCP_UL_Stream2 = linearPane.AddCurve("UL_Stream2", x_values, y_values, Color.Red, SymbolType.Circle)
                End If
            End If
        End If
        If m_TransfreDirectoin = eTransferDirection.Bidirection Then
            If m_StreamNumber >= 2 Then
                If IsNothing(TCP_UL_SUM_Stream) Then
                    TCP_UL_SUM_Stream = linearPane.AddCurve("UL_SUM_Stream", x_values, y_values, Color.Plum, SymbolType.Circle)
                End If
                If IsNothing(TCP_DL_SUM_Stream) Then
                    TCP_DL_SUM_Stream = linearPane.AddCurve("DL_SUM_Stream", x_values, y_values, Color.Purple, SymbolType.Circle)
                End If
            End If
        End If
    End Sub

    Private Sub InitGraphCurveByProtocol()
        If m_TransportLayerProtocol = eTransportLayerProtocol.UDP Then
            InitUDPGraphCurve()
        Else
            InitTCPGraphCurve()
        End If
    End Sub

    Private Sub StartUDPTransfer()
        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Download Then
            If m_StreamNumber >= 1 Then
                b_UDP_DL_Decode_Finished1 = False
                UDPDLThread1 = New Thread(New ThreadStart(AddressOf UDPDownload1))
                UDPDLThread1.SetApartmentState(ApartmentState.STA)
                UDPDLThread1.IsBackground = True
                UDPDLThread1.Start()

            End If
            If m_StreamNumber >= 2 Then
                b_UDP_DL_Decode_Finished2 = False
                UDPDLThread2 = New Thread(New ThreadStart(AddressOf UDPDownload2))
                UDPDLThread2.SetApartmentState(ApartmentState.STA)
                UDPDLThread2.IsBackground = True
                UDPDLThread2.Start()
            End If

        End If

        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Upload Then
            If m_StreamNumber >= 1 Then
                b_UDP_UL_Decode_Finished1 = False
                UDPULThread1 = New Thread(New ThreadStart(AddressOf UDPUpload1))
                UDPULThread1.SetApartmentState(ApartmentState.STA)
                UDPULThread1.IsBackground = True
                UDPULThread1.Start()

            End If
            If m_StreamNumber >= 2 Then
                b_UDP_UL_Decode_Finished2 = False
                UDPULThread2 = New Thread(New ThreadStart(AddressOf UDPUpload2))
                UDPULThread2.SetApartmentState(ApartmentState.STA)
                UDPULThread2.IsBackground = True
                UDPULThread2.Start()
            End If
        End If

        If m_StreamNumber >= 2 Then
            UDPUpdateSumGraphThread = New Thread(New ThreadStart(AddressOf UpdateUDPSumGraph))
            UDPUpdateSumGraphThread.SetApartmentState(ApartmentState.STA)
            UDPUpdateSumGraphThread.IsBackground = True
            UDPUpdateSumGraphThread.Start()
        End If
    End Sub

    Private Sub StartTCPTransfer()
        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Download Then
            If m_StreamNumber >= 1 Then
                b_TCP_DL_Decode_Finished1 = False
                TCPDLThread1 = New Thread(New ThreadStart(AddressOf TCPDownload1))
                TCPDLThread1.SetApartmentState(ApartmentState.STA)
                TCPDLThread1.IsBackground = True
                TCPDLThread1.Start()

            End If
            If m_StreamNumber >= 2 Then
                b_TCP_DL_Decode_Finished2 = False
                TCPDLThread2 = New Thread(New ThreadStart(AddressOf TCPDownload2))
                TCPDLThread2.SetApartmentState(ApartmentState.STA)
                TCPDLThread2.IsBackground = True
                TCPDLThread2.Start()
            End If

        End If

        If m_TransfreDirectoin = eTransferDirection.Bidirection Or m_TransfreDirectoin = eTransferDirection.Upload Then
            If m_StreamNumber >= 1 Then
                b_TCP_UL_Decode_Finished1 = False
                TCPULThread1 = New Thread(New ThreadStart(AddressOf TCPUpload1))
                TCPULThread1.SetApartmentState(ApartmentState.STA)
                TCPULThread1.IsBackground = True
                TCPULThread1.Start()

            End If
            If m_StreamNumber >= 2 Then
                b_TCP_UL_Decode_Finished2 = False
                TCPULThread2 = New Thread(New ThreadStart(AddressOf TCPUpload2))
                TCPULThread2.SetApartmentState(ApartmentState.STA)
                TCPULThread2.IsBackground = True
                TCPULThread2.Start()
            End If
        End If

        If m_StreamNumber >= 2 Then
            TCPUpdateSumGraphThread = New Thread(New ThreadStart(AddressOf UpdateTCPSumGraph))
            TCPUpdateSumGraphThread.SetApartmentState(ApartmentState.STA)
            TCPUpdateSumGraphThread.IsBackground = True
            TCPUpdateSumGraphThread.Start()
        End If
    End Sub


    Private Sub StartTransfer()
        If m_TransportLayerProtocol = eTransportLayerProtocol.UDP Then
            StartUDPTransfer()
        Else
            StartTCPTransfer()
        End If
    End Sub

    Private Sub UpdateUDPSumGraph()
        While (True)
            Dim b_Over = True
            If Not IsNothing(UDPDLThread1) Then
                b_Over = b_Over And b_UDP_DL_Decode_Finished1
            End If
            If Not IsNothing(UDPDLThread2) Then
                b_Over = b_Over And b_UDP_DL_Decode_Finished2
            End If

            If Not IsNothing(UDPULThread1) Then
                b_Over = b_Over And b_UDP_UL_Decode_Finished1
            End If

            If Not IsNothing(UDPULThread2) Then
                b_Over = b_Over And b_UDP_UL_Decode_Finished2
            End If

            If b_Over Then
                Dim dlCount = Math.Min(UDP_DL_List1.Count, UDP_DL_List2.Count)
                For i = 0 To dlCount - 1
                    UDP_DL_SUM_Stream.AddPoint(UDP_DL_List1(i).sec, UDP_DL_List1(i).val + UDP_DL_List2(i).val)
                    RefreshGraph()
                Next

                Dim ulCount = Math.Min(UDP_UL_List1.Count, UDP_UL_List2.Count)
                For i = 0 To ulCount - 1
                    UDP_UL_SUM_Stream.AddPoint(UDP_UL_List1(i).sec, UDP_UL_List1(i).val + UDP_UL_List2(i).val)
                    RefreshGraph()
                Next
                b_UDP_DL_Decode_Finished1 = False
                b_UDP_DL_Decode_Finished2 = False
                b_UDP_UL_Decode_Finished1 = False
                b_UDP_UL_Decode_Finished2 = False
            End If
            System.Threading.Thread.Sleep(1000)
        End While


    End Sub

    Private Sub UpdateTCPSumGraph()
        While (True)
            Dim b_Over = True
            If Not IsNothing(TCPDLThread1) Then
                b_Over = b_Over And b_TCP_DL_Decode_Finished1
            End If
            If Not IsNothing(UDPDLThread2) Then
                b_Over = b_Over And b_TCP_DL_Decode_Finished2
            End If

            If Not IsNothing(UDPULThread1) Then
                b_Over = b_Over And b_TCP_UL_Decode_Finished1
            End If

            If Not IsNothing(UDPULThread2) Then
                b_Over = b_Over And b_TCP_UL_Decode_Finished2
            End If

            If b_Over Then
                Dim dlCount = Math.Min(TCP_DL_List1.Count, TCP_DL_List2.Count)
                For i = 0 To dlCount - 1
                    TCP_DL_SUM_Stream.AddPoint(TCP_DL_List1(i).sec, TCP_DL_List1(i).val + TCP_DL_List2(i).val)
                    RefreshGraph()
                Next

                Dim ulCount = Math.Min(TCP_UL_List1.Count, TCP_UL_List2.Count)
                For i = 0 To ulCount - 1
                    TCP_UL_SUM_Stream.AddPoint(TCP_UL_List1(i).sec, TCP_UL_List1(i).val + TCP_UL_List2(i).val)
                    RefreshGraph()
                Next
                b_TCP_DL_Decode_Finished1 = False
                b_TCP_DL_Decode_Finished2 = False
                b_TCP_UL_Decode_Finished1 = False
                b_TCP_UL_Decode_Finished2 = False
            End If
            System.Threading.Thread.Sleep(1000)
        End While


    End Sub


    Private Sub UDPDownload1()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_S2C_Server_Log_Name = "S2C_S_UDP_" + TimstampStr + "_DL1.log"
        Dim m_S2C_Client_log_Name = "S2C_C_UDP_" + TimstampStr + "_DL1.log"
        Dim log = TOOL_LOG_LOCAL + m_S2C_Client_log_Name

        If m_ClientType = eCLIENT_TYPE.ADB Then
            '/data/local/tmp/iperf -u -s -B 99.99.6.2 -p 10000 -f m -i 1 -w 1M -l 1430 >

            Dim cmd = m_DTCmdData.sUDP_Server_to_Client_C_Cmd + " >""" + log + """"
            StartUEIperfProcess(cmd)
            Threading.Thread.Sleep(3000)
            'iperf -u -B 99.99.6.1 -c 99.99.6.2 -p 10000 -f m -i 1 -P 1 -w 1M -b 50M -l 1430 -t 20 >/
            cmd = m_DTCmdData.sUDP_Server_to_Client_S_Cmd + " >" + TOOL_LOG_REMOTE + m_S2C_Server_Log_Name
            SyncLock RC
                RC.RunRemoteCommand(cmd, True)
            End SyncLock
            Threading.Thread.Sleep(3000)
            DecodeUDPDLDTFile1(log)
        End If
    End Sub

    Private Sub TCPDownload1()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_S2C_Server_Log_Name = "S2C_S_TCP_" + TimstampStr + "_DL1.log"
        Dim m_S2C_Client_log_Name = "S2C_C_TCP_" + TimstampStr + "_DL1.log"
        Dim log = TOOL_LOG_LOCAL + m_S2C_Client_log_Name

        If m_ClientType = eCLIENT_TYPE.ADB Then
            Dim cmd = m_DTCmdData.sTCP_Server_to_Client_C_Cmd + " >""" + log + """"
            StartUEIperfProcess(cmd)
            Threading.Thread.Sleep(3000)
            cmd = m_DTCmdData.sTCP_Server_to_Client_S_Cmd + " >" + TOOL_LOG_REMOTE + m_S2C_Server_Log_Name
            SyncLock RC
                RC.RunRemoteCommand(cmd, True)
            End SyncLock
            Threading.Thread.Sleep(3000)
            DecodeTCPDLDTFile1(log)
        End If
    End Sub
    Private Sub UDPDownload2()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_S2C_Server_Log_Name = "S2C_S_UDP_" + TimstampStr + "_DL2.log"
        Dim m_S2C_Client_log_Name = "S2C_C_UDP_" + TimstampStr + "_DL2.log"
        Dim log = TOOL_LOG_LOCAL + m_S2C_Client_log_Name

        If m_ClientType = eCLIENT_TYPE.ADB Then
            Dim cmd = m_DTCmdData.sUDP_Server_to_Client_C_cmd_2nd + " >""" + log + """"
            StartUEIperfProcess(cmd)
            Threading.Thread.Sleep(3000)
            cmd = m_DTCmdData.sUDP_Server_to_Client_S_cmd_2nd + " >" + TOOL_LOG_REMOTE + m_S2C_Server_Log_Name
            SyncLock RC
                RC.RunRemoteCommand(cmd, True)
            End SyncLock
            Threading.Thread.Sleep(3000)
            DecodeUDPDLDTFile2(log)

        End If
    End Sub

    Private Sub TCPDownload2()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_S2C_Server_Log_Name = "S2C_S_TCP_" + TimstampStr + "_DL2.log"
        Dim m_S2C_Client_log_Name = "S2C_C_TCP_" + TimstampStr + "_DL2.log"
        Dim log = TOOL_LOG_LOCAL + m_S2C_Client_log_Name

        If m_ClientType = eCLIENT_TYPE.ADB Then
            Dim cmd = m_DTCmdData.sTCP_Server_to_Client_C_cmd_2nd + " >""" + log + """"
            StartUEIperfProcess(cmd)
            Threading.Thread.Sleep(3000)
            cmd = m_DTCmdData.sTCP_Server_to_Client_S_cmd_2nd + " >" + TOOL_LOG_REMOTE + m_S2C_Server_Log_Name
            SyncLock RC
                RC.RunRemoteCommand(cmd, True)
            End SyncLock
            Threading.Thread.Sleep(3000)
            DecodeTCPDLDTFile2(log)

        End If
    End Sub
    Private Sub UDPUpload1()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_C2S_Server_Log_Name = "UL_C2S_S_UDP_" + TimstampStr + "_UL1.log"
        Dim m_C2S_Client_log_Name = "UL_C2S_C_UDP_" + TimstampStr + "_UL1.log"
        Dim log = TOOL_LOG_REMOTE + m_C2S_Server_Log_Name

        Dim cmd = m_DTCmdData.sUDP_Client_to_Server_S_Cmd + " >" + log
        SyncLock RC
            RC.RunRemoteCommand(cmd, True)
        End SyncLock

        If m_ClientType = eCLIENT_TYPE.ADB Then
            cmd = m_DTCmdData.sUDP_Client_to_Server_C_Cmd + " >""" + TOOL_LOG_LOCAL + m_C2S_Client_log_Name + """"
            StartUEIperfProcess(cmd)
            DecodeUDPULDTFile1(log)


        End If
    End Sub

    Private Sub TCPUpload1()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_C2S_Server_Log_Name = "UL_C2S_S_TCP_" + TimstampStr + "_UL1.log"
        Dim m_C2S_Client_log_Name = "UL_C2S_C_TCP_" + TimstampStr + "_UL1.log"
        Dim log = TOOL_LOG_REMOTE + m_C2S_Server_Log_Name

        Dim cmd = m_DTCmdData.sTCP_Client_to_Server_S_Cmd + " >" + log
        SyncLock RC
            RC.RunRemoteCommand(cmd, True)
        End SyncLock

        If m_ClientType = eCLIENT_TYPE.ADB Then
            cmd = m_DTCmdData.sTCP_Client_to_Server_C_Cmd + " >""" + TOOL_LOG_LOCAL + m_C2S_Client_log_Name + """"
            StartUEIperfProcess(cmd)
            DecodeTCPULDTFile1(log)


        End If
    End Sub

    Private Sub UDPUpload2()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_C2S_Server_Log_Name = "UL_C2S_S_UDP_" + TimstampStr + "_UL2.log"
        Dim m_C2S_Client_log_Name = "UL_C2S_C_UDP_" + TimstampStr + "_UL2.log"
        Dim log = TOOL_LOG_REMOTE + m_C2S_Server_Log_Name

        Dim cmd = m_DTCmdData.sUDP_Client_to_Server_S_cmd_2nd + " >" + log
        SyncLock RC
            RC.RunRemoteCommand(cmd, True)
        End SyncLock

        If m_ClientType = eCLIENT_TYPE.ADB Then
            cmd = m_DTCmdData.sUDP_Client_to_Server_C_cmd_2nd + " >""" + TOOL_LOG_LOCAL + m_C2S_Client_log_Name + """"
            StartUEIperfProcess(cmd)
            DecodeUDPULDTFile2(log)
        End If
    End Sub

    Private Sub TCPUpload2()
        Dim TimstampStr As String = DateTime.Now.ToString("MM-dd-hh-mm-ss-fff")
        Dim m_C2S_Server_Log_Name = "UL_C2S_S_TCP_" + TimstampStr + "_UL2.log"
        Dim m_C2S_Client_log_Name = "UL_C2S_C_TCP_" + TimstampStr + "_UL2.log"
        Dim log = TOOL_LOG_REMOTE + m_C2S_Server_Log_Name

        Dim cmd = m_DTCmdData.sTCP_Client_to_Server_S_cmd_2nd + " >" + log
        SyncLock RC
            RC.RunRemoteCommand(cmd, True)
        End SyncLock

        If m_ClientType = eCLIENT_TYPE.ADB Then
            cmd = m_DTCmdData.sTCP_Client_to_Server_C_cmd_2nd + " >""" + TOOL_LOG_LOCAL + m_C2S_Client_log_Name + """"
            StartUEIperfProcess(cmd)
            DecodeTCPULDTFile2(log)
        End If
    End Sub

    Private Sub DecodeUDPDLDTFile1(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            While (True)
                If File.Exists(log) Then
                    File.Copy(log, UDP_TOOL_LOG_LOCAL_DL_Copy1, True)
                    Dim fi As FileInfo = New FileInfo(UDP_TOOL_LOG_LOCAL_DL_Copy1)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(UDP_TOOL_LOG_LOCAL_DL_Copy1)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_UDP_DL_Decode_Finished1 = True
                            Exit While
                        End If

                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(UDPDLProcessedlineCount1).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = UDP_DL_List1.Count + 1
                                               dtinfo.val = val
                                               UDP_DL_List1.Add(dtinfo)
                                               UDP_DL_Stream1.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            UDPDLProcessedlineCount1 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeUDPDLDTFile1:" + ex.Message)
            Console.WriteLine("DecodeUDPDLDTFile1:" + ex.Message)
        End Try
    End Sub

    Private Sub DecodeTCPDLDTFile1(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            While (True)
                If File.Exists(log) Then
                    File.Copy(log, TCP_TOOL_LOG_LOCAL_DL_Copy1, True)
                    Dim fi As FileInfo = New FileInfo(TCP_TOOL_LOG_LOCAL_DL_Copy1)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(TCP_TOOL_LOG_LOCAL_DL_Copy1)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_TCP_DL_Decode_Finished1 = True
                            Exit While
                        End If

                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(TCPDLProcessedlineCount1).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = TCP_DL_List1.Count + 1
                                               dtinfo.val = val
                                               TCP_DL_List1.Add(dtinfo)
                                               TCP_DL_Stream1.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            TCPDLProcessedlineCount1 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeTCPDLDTFile1:" + ex.Message)
            Console.WriteLine("DecodeTCPDLDTFile1:" + ex.Message)
        End Try
    End Sub


    Private Sub DecodeUDPDLDTFile2(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            While (True)
                If File.Exists(log) Then
                    File.Copy(log, UDP_TOOL_LOG_LOCAL_DL_Copy2, True)
                    Dim fi As FileInfo = New FileInfo(UDP_TOOL_LOG_LOCAL_DL_Copy2)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(UDP_TOOL_LOG_LOCAL_DL_Copy2)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_UDP_DL_Decode_Finished2 = True
                            Exit While
                        End If
                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(UDPDLProcessedlineCount2).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = UDP_DL_List2.Count + 1
                                               dtinfo.val = val
                                               UDP_DL_List2.Add(dtinfo)
                                               UDP_DL_Stream2.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            UDPDLProcessedlineCount2 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeUDPDLDTFile2:" + ex.Message)
            Console.WriteLine("DecodeUDPDLDTFile2:" + ex.Message)
        End Try
    End Sub

    Private Sub DecodeTCPDLDTFile2(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            While (True)
                If File.Exists(log) Then
                    File.Copy(log, TCP_TOOL_LOG_LOCAL_DL_Copy2, True)
                    Dim fi As FileInfo = New FileInfo(TCP_TOOL_LOG_LOCAL_DL_Copy2)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(TCP_TOOL_LOG_LOCAL_DL_Copy2)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_TCP_DL_Decode_Finished2 = True
                            Exit While
                        End If
                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(TCPDLProcessedlineCount2).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = TCP_DL_List2.Count + 1
                                               dtinfo.val = val
                                               TCP_DL_List2.Add(dtinfo)
                                               TCP_DL_Stream2.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            TCPDLProcessedlineCount2 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeTCPDLDTFile2:" + ex.Message)
            Console.WriteLine("DecodeTCPDLDTFile2:" + ex.Message)
        End Try
    End Sub

    Private Sub DecodeUDPULDTFile1(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            If IsNothing(scpclient) Then
                scpclient = New clsWinSCP(m_RemoteServerAddr, m_RemoteServerUsr, GetStringInput())
            End If
            Dim logName = Path.GetFileName(log)
            While (True)
                scpclient.RetriveFile(log, TOOL_LOG_LOCAL + logName)
                'UL_C2S_C_UDP_04-30-02-25-31-480_UL1.log
                If File.Exists(TOOL_LOG_LOCAL + logName) Then
                    File.Copy(TOOL_LOG_LOCAL + logName, UDP_TOOL_LOG_LOCAL_UL_Copy1, True)
                    Dim fi As FileInfo = New FileInfo(UDP_TOOL_LOG_LOCAL_UL_Copy1)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(UDP_TOOL_LOG_LOCAL_UL_Copy1)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_UDP_UL_Decode_Finished1 = True
                            Exit While
                        End If

                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(UDPULProcessedlineCount1).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = UDP_UL_List1.Count + 1
                                               dtinfo.val = val
                                               UDP_UL_List1.Add(dtinfo)
                                               UDP_UL_Stream1.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            UDPULProcessedlineCount1 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeUDPULDTFile1:" + ex.Message)
            Console.WriteLine("DecodeUDPULDTFile1:" + ex.Message)
        End Try
    End Sub


    Private Sub DecodeTCPULDTFile1(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            If IsNothing(scpclient) Then
                scpclient = New clsWinSCP(m_RemoteServerAddr, m_RemoteServerUsr, GetStringInput())
            End If
            Dim logName = Path.GetFileName(log)
            While (True)
                scpclient.RetriveFile(log, TOOL_LOG_LOCAL + logName)
                'UL_C2S_C_UDP_04-30-02-25-31-480_UL1.log
                If File.Exists(TOOL_LOG_LOCAL + logName) Then
                    File.Copy(TOOL_LOG_LOCAL + logName, TCP_TOOL_LOG_LOCAL_UL_Copy1, True)
                    Dim fi As FileInfo = New FileInfo(TCP_TOOL_LOG_LOCAL_UL_Copy1)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(TCP_TOOL_LOG_LOCAL_UL_Copy1)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_TCP_UL_Decode_Finished1 = True
                            Exit While
                        End If

                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(TCPULProcessedlineCount1).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = TCP_UL_List1.Count + 1
                                               dtinfo.val = val
                                               TCP_UL_List1.Add(dtinfo)
                                               TCP_UL_Stream1.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            TCPULProcessedlineCount1 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeTCPULDTFile1:" + ex.Message)
            Console.WriteLine("DecodeTCPULDTFile1:" + ex.Message)
        End Try
    End Sub


    Private Sub DecodeUDPULDTFile2(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            If IsNothing(scpclient) Then
                scpclient = New clsWinSCP(m_RemoteServerAddr, m_RemoteServerUsr, GetStringInput())
            End If
            Dim logName = Path.GetFileName(log)
            While (True)
                scpclient.RetriveFile(log, TOOL_LOG_LOCAL + logName)
                If File.Exists(TOOL_LOG_LOCAL + logName) Then
                    File.Copy(TOOL_LOG_LOCAL + logName, UDP_TOOL_LOG_LOCAL_UL_Copy2, True)
                    Dim fi As FileInfo = New FileInfo(UDP_TOOL_LOG_LOCAL_UL_Copy2)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(UDP_TOOL_LOG_LOCAL_UL_Copy2)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_UDP_UL_Decode_Finished2 = True
                            Exit While
                        End If

                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(UDPULProcessedlineCount2).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = UDP_UL_List2.Count + 1
                                               dtinfo.val = val
                                               UDP_UL_List2.Add(dtinfo)
                                               UDP_UL_Stream2.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            UDPULProcessedlineCount2 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeUDPULDTFile2:" + ex.Message)
            Console.WriteLine("DecodeUDPULDTFile2:" + ex.Message)
        End Try
    End Sub


    Private Sub DecodeTCPULDTFile2(ByVal log As String)
        Try
            Dim fileLength = -1
            Dim fileLengthNoChangeTime = 0
            Dim lines As String() = Nothing
            If IsNothing(scpclient) Then
                scpclient = New clsWinSCP(m_RemoteServerAddr, m_RemoteServerUsr, GetStringInput())
            End If
            Dim logName = Path.GetFileName(log)
            While (True)
                scpclient.RetriveFile(log, TOOL_LOG_LOCAL + logName)
                If File.Exists(TOOL_LOG_LOCAL + logName) Then
                    File.Copy(TOOL_LOG_LOCAL + logName, TCP_TOOL_LOG_LOCAL_UL_Copy2, True)
                    Dim fi As FileInfo = New FileInfo(TCP_TOOL_LOG_LOCAL_UL_Copy2)
                    If fi.Length > fileLength Then
                        lines = File.ReadAllLines(TCP_TOOL_LOG_LOCAL_UL_Copy2)
                        fileLength = fi.Length
                    Else
                        fileLengthNoChangeTime += 1
                        If fileLengthNoChangeTime >= File_No_Change_Time_Setting Then
                            b_TCP_UL_Decode_Finished2 = True
                            Exit While
                        End If

                    End If

                    If lines.Count > 0 Then
                        Dim validLines = lines.Skip(TCPULProcessedlineCount2).ToArray()
                        Dim bwStrs = validLines.Where(Function(s) s.Contains("bits/sec")).ToList()
                        If validLines.Count > 0 Then
                            bwStrs.ForEach(Sub(s)
                                               Dim startIndex = s.IndexOf("Bytes") + "Bytes".Length
                                               Dim endIndex = s.IndexOf("bits/sec")
                                               Dim msStr = s.Substring(startIndex, endIndex - startIndex).Trim()
                                               Dim val As Double = Convert.ToDouble(msStr.Split(" ")(0))
                                               Dim dtinfo = New clsDTInfo
                                               dtinfo.sec = TCP_UL_List2.Count + 1
                                               dtinfo.val = val
                                               TCP_UL_List2.Add(dtinfo)
                                               TCP_UL_Stream2.AddPoint(dtinfo.sec, dtinfo.val)
                                               RefreshGraph()
                                           End Sub)
                            TCPULProcessedlineCount2 += validLines.Count
                        End If
                    End If
                End If

                Thread.Sleep(1000)
            End While

        Catch ex As Exception
            WriteLog("DecodeTCPULDTFile2:" + ex.Message)
            Console.WriteLine("DecodeTCPULDTFile2:" + ex.Message)
        End Try
    End Sub


    Private Sub GetParaFromUI()
        m_StreamNumber = Convert.ToInt32(txtStreamCount.Text)
        m_TransfreDirectoin = [Enum].Parse(m_TransfreDirectoin.GetType(), cmbDirection.SelectedItem.ToString())
        m_TransportLayerProtocol = [Enum].Parse(m_TransportLayerProtocol.GetType(), cmbProtocol.SelectedItem.ToString())
        Dim dl_rates = txtDLTranferRate.Text.Trim().Split(",")
        m_DLBlasterRate = dl_rates(0)
        m_DLBlasterRate_2nd = dl_rates(1)
        Dim ul_rates = txtULTransferRate.Text.Trim().Split(",")
        m_ULBlasterRate = ul_rates(0)
        m_ULBlasterRate_2nd = ul_rates(1)

        Dim dl_buffers = txtDLBufferSize.Text.Trim().Split(",")
        m_DLBufferSize = dl_buffers(0)
        m_DLBufferSize_2nd = dl_buffers(1)

        Dim ul_buffers = txtULBufferSize.Text.Trim().Split(",")
        m_ULBufferSize = ul_buffers(0)
        m_ULBufferSize_2nd = ul_buffers(1)

    End Sub


    Public Sub AdbPushIperf()
        Dim iperfpath As String = """" + Environment.CurrentDirectory() + "\iperf" + """"
        Dim cmd As String = "adb push " + iperfpath + " /data/local/tmp"
        ExecuteLocalCmd(cmd)
        Thread.Sleep(2000)
        cmd = "adb shell chmod 777 /data/local/tmp/iperf"
        ExecuteLocalCmd(cmd)
    End Sub

    Private Sub FormMultiThreadDataThroughput_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cmbDirection.SelectedIndex = 2
        cmbProtocol.SelectedIndex = 1
        cmbClentType.SelectedIndex = 0
    End Sub

    Private Function ReadDTCmd(ByVal DTCmdFile As String, ByRef m_DTCmdData As clsDTCmdData) As Boolean
        Try

            'WaitSeconds(10)
            Dim rawJson = File.ReadAllText(DTCmdFile)
            '替换双流公共参数
            rawJson = rawJson.Replace("[DLInterval]", m_DLInterval)
            rawJson = rawJson.Replace("[ULInterval]", m_ULInterval)
            rawJson = rawJson.Replace("[Server_IP]", m_RemoteServerPDNAddr).Replace("[ClientIP]", m_ClientUEAssignedIPAddr).Replace("[UEIP]", m_UEIPAddr).Replace("[TransferTime]", m_TransferTime.ToString())

            '替换第一个流参数
            rawJson = rawJson.Replace("[DLTransRate]", m_DLBlasterRate).Replace("[ULTransRate]", m_ULBlasterRate)
            rawJson = rawJson.Replace("[DLBufferSize]", m_DLBufferSize).Replace("[ULBufferSize]", m_ULBufferSize)
            rawJson = rawJson.Replace("[DLThread]", m_DLThreads.ToString())
            rawJson = rawJson.Replace("[ULThread]", m_ULThreads.ToString())

            '替换第二个流参数
            If m_StreamNumber = 2 Then
                rawJson = rawJson.Replace("[DLTransRate_2nd]", m_DLBlasterRate_2nd).Replace("[ULTransRate_2nd]", m_ULBlasterRate_2nd)
                rawJson = rawJson.Replace("[DLBufferSize_2nd]", m_DLBufferSize_2nd).Replace("[ULBufferSize_2nd]", m_ULBufferSize_2nd)
                rawJson = rawJson.Replace("[DLThread_2nd]", m_DLThreads_2nd.ToString())
                rawJson = rawJson.Replace("[ULThread_2nd]", m_ULThreads_2nd.ToString())
            End If

            If m_IpVersion = eIPVersionDT.IPv6 Then
                rawJson = rawJson.Replace(""",", " -V "",")
            End If

            m_DTCmdData = ToClass(Of clsDTCmdData)(rawJson)


            Return True
        Catch ex As Exception

            Return False
        End Try
    End Function

    Private Function ToClass(Of T)(data As String,
                                  Optional jsonSettings As JsonSerializerSettings = Nothing) As T

        Dim response = Nothing

        If Not String.IsNullOrEmpty(data) Then
            response = If(jsonSettings Is Nothing,
                JsonConvert.DeserializeObject(Of T)(data),
                JsonConvert.DeserializeObject(Of T)(data, jsonSettings))
        End If

        Return response

    End Function

    Private Function StartUEIperfProcess(ByVal cmd As String) As Boolean

        Try
            Dim Process As System.Diagnostics.ProcessStartInfo
            Dim p As System.Diagnostics.Process
            ' Process.Arguments = "/c " + "adb shell /data/data/com.arubanetworks.arubautilities/files/" + cmd
            Process = New System.Diagnostics.ProcessStartInfo With {
                .WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
                .CreateNoWindow = True,
                .FileName = "cmd.exe",
                .Arguments = "/c " + "adb shell " + cmd
            }
            p = System.Diagnostics.Process.Start(Process)
            Thread.Sleep(5000)
            Return True
        Catch ex As Exception
            WriteLog("At StartCPCBasedUEIperfProcess() " + ex.Message)
            Return False
        End Try

    End Function




    Private Sub RefreshGraph()
        ZedGraphControl.Invoke(Sub()
                                   ZedGraphControl.AxisChange()
                                   ZedGraphControl.Invalidate()
                               End Sub)

    End Sub

End Class

Public Class clsDTCmdData
    <JsonProperty("UDP_Server_to_Client_S_Cmd")>
    Public Property sUDP_Server_to_Client_S_Cmd As String
    <JsonProperty("UDP_Server_to_Client_C_Cmd")>
    Public Property sUDP_Server_to_Client_C_Cmd As String
    <JsonProperty("TCP_Server_to_Client_S_Cmd")>
    Public Property sTCP_Server_to_Client_S_Cmd As String
    <JsonProperty("TCP_Server_to_Client_C_Cmd")>
    Public Property sTCP_Server_to_Client_C_Cmd As String
    <JsonProperty("UDP_Client_to_Server_S_Cmd")>
    Public Property sUDP_Client_to_Server_S_Cmd As String
    <JsonProperty("UDP_Client_to_Server_C_Cmd")>
    Public Property sUDP_Client_to_Server_C_Cmd As String
    <JsonProperty("TCP_Client_to_Server_S_Cmd")>
    Public Property sTCP_Client_to_Server_S_Cmd As String
    <JsonProperty("TCP_Client_to_Server_C_Cmd")>
    Public Property sTCP_Client_to_Server_C_Cmd As String

    <JsonProperty("UDP_Server_to_Client_S_cmd_2nd")>
    Public Property sUDP_Server_to_Client_S_cmd_2nd As String
    <JsonProperty("UDP_Server_to_Client_C_cmd_2nd")>
    Public Property sUDP_Server_to_Client_C_cmd_2nd As String
    <JsonProperty("TCP_Server_to_Client_S_cmd_2nd")>
    Public Property sTCP_Server_to_Client_S_cmd_2nd As String
    <JsonProperty("TCP_Server_to_Client_C_cmd_2nd")>
    Public Property sTCP_Server_to_Client_C_cmd_2nd As String
    <JsonProperty("UDP_Client_to_Server_S_cmd_2nd")>
    Public Property sUDP_Client_to_Server_S_cmd_2nd As String
    <JsonProperty("UDP_Client_to_Server_C_cmd_2nd")>
    Public Property sUDP_Client_to_Server_C_cmd_2nd As String
    <JsonProperty("TCP_Client_to_Server_S_cmd_2nd")>
    Public Property sTCP_Client_to_Server_S_cmd_2nd As String
    <JsonProperty("TCP_Client_to_Server_C_cmd_2nd")>
    Public Property sTCP_Client_to_Server_C_cmd_2nd As String
End Class

 

 类似资料: