VirtualBox

Changeset 78822 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
May 28, 2019 2:30:02 PM (6 years ago)
Author:
vboxsync
Message:

ValKit/NetPerf: Adding -buffer-size/-b option for setting socket receive & send buffer sizes. bugref:9474

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/utils/network/NetPerf.cpp

    r76870 r78822  
    8686#define NETPERF_MIN_COOL_DOWN                   1000  /*  1s */
    8787
     88/** Maximum socket buffer size possible (bytes). */
     89#define NETPERF_MAX_BUF_SIZE                    _128M
     90/** Minimum socket buffer size possible (bytes). */
     91#define NETPERF_MIN_BUF_SIZE                    256
     92
    8893/** The length of the length prefix used when submitting parameters and
    8994 * results. */
     
    142147    /** Server: Quit after the first client. */
    143148    bool            fSingleClient;
     149    /** Send and receive buffer sizes for TCP sockets, zero if to use defaults. */
     150    uint32_t        cbBufferSize;
    144151    /** @} */
    145152
     
    235242    { "--check-data",       'C', RTGETOPT_REQ_NOTHING },
    236243    { "--verbose",          'v', RTGETOPT_REQ_NOTHING },
     244    { "--buffer-size",      'b', RTGETOPT_REQ_UINT32  },
    237245    { "--help",             'h', RTGETOPT_REQ_NOTHING } /* for Usage() */
    238246};
     
    303311            case 'C':
    304312                pszHelp = "Check payload data at the receiving end";
     313                break;
     314            case 'b':
     315                pszHelp = "Send and receive buffer sizes for TCP";
    305316                break;
    306317            case 'v':
     
    11361147        RTTestIPrintf(RTTESTLVL_ALWAYS, "Failed to get client details: %Rrc\n", rc);
    11371148        Addr.enmType = RTNETADDRTYPE_INVALID;
     1149    }
     1150
     1151    /*
     1152     * Adjust send and receive buffer sizes if necessary.
     1153     */
     1154    if (pParams->cbBufferSize)
     1155    {
     1156        rc = RTTcpSetBufferSize(hSocket, pParams->cbBufferSize);
     1157        if (RT_FAILURE(rc))
     1158            return RTTestIFailedRc(rc, "Failed to set socket buffer sizes to %#x: %Rrc\n", pParams->cbBufferSize, rc);
    11381159    }
    11391160
     
    16391660
    16401661    /*
     1662     * Adjust send and receive buffer sizes if necessary.
     1663     */
     1664    if (pParams->cbBufferSize)
     1665    {
     1666        rc = RTTcpSetBufferSize(hSocket, pParams->cbBufferSize);
     1667        if (RT_FAILURE(rc))
     1668            return RTTestIFailedRc(rc, "Failed to set socket buffer sizes to %#x: %Rrc\n", pParams->cbBufferSize, rc);
     1669    }
     1670
     1671    /*
    16411672     * Verify the super secret Start Connect Id to start the connection.
    16421673     */
     
    17941825    Params.cMsCoolDown      = NETPERF_DEFAULT_COOL_DOWN;
    17951826    Params.cbPacket         = NETPERF_DEFAULT_PKT_SIZE_LATENCY;
     1827    Params.cbBufferSize     = 0;
    17961828
    17971829    Params.hSocket          = NIL_RTSOCKET;
     
    19221954                break;
    19231955
     1956            case 'b':
     1957                Params.cbBufferSize = ValueUnion.u32;
     1958                if (   (    Params.cbBufferSize < NETPERF_MIN_BUF_SIZE
     1959                         || Params.cbBufferSize > NETPERF_MAX_BUF_SIZE)
     1960                    && Params.cbBufferSize  != 0)
     1961                {
     1962                    RTTestFailed(g_hTest, "Invalid packet size %u bytes, valid range: %u-%u or 0\n",
     1963                                 Params.cbBufferSize, NETPERF_MIN_BUF_SIZE, NETPERF_MAX_BUF_SIZE);
     1964                    return RTTestSummaryAndDestroy(g_hTest);
     1965                }
     1966                break;
     1967
    19241968            default:
    19251969                return RTGetOptPrintError(rc, &ValueUnion);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette