WINC3400 iperf.
Copyright (c) 2017-2019 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "asf.h"
#include "iperf.h"
#include "driver/include/m2m_wifi.h"
#include "socket/include/socket.h"
#include "conf_winc.h"
Data Structures | |
struct | tstrIperfSocketInfo |
struct | tstrIperfUdpMsg |
struct | tstrIperfUdpServerMsg |
struct | tstrIperfUdpState |
struct | tstrIperfUint64 |
Macros | |
#define | IPERF_MAX_UDP_STATE 4 |
Variables | |
uint32 | clientIPAddress |
static tstrIperfSocketInfo | gastrIperfSocketInfo [MAX_SOCKET] |
static tstrIperfUdpState | gastrIperfUdpState [IPERF_MAX_UDP_STATE] |
static tstrIperfUdpMsg | gstrRxMsgBuffer |
static tstrIperfUdpMsg | gstrTxMsgBuffer |
static tstrIperfUdpServerMsg | gstrTxSrvMsg |
uint32 | gu32IPAddress |
static uint8 | gu8NumSockets |
app_status | iperf_app_stat |
static client_hdr | iperf_tcp_serv |
SOCKET | tcp_client_sock |
uint32_t | tcp_serv_pack_recv |
static uint32_t | u32LastStatsTime |
static uint32_t | u32msTicks |
uint32_t | udp_serv_pack_recv |
SOCKET | udp_server_sock |
#define IPERF_MAX_UDP_STATE 4 |
Referenced by IperfPrintStats(), IperfSocketClose(), IperfSocketEventHandler(), and IperfUpdate().
|
static |
Referenced by IperfSocketEventHandler(), and IperfUDP_SendTestPacket().
|
static |
References u32msTicks.
Referenced by IperfIncrementTimerUse().
|
static |
References tstrIperfUint64::u32H, and tstrIperfUint64::u32L.
Referenced by IperfSocketEventHandler(), IperfTCP_SendTestPacket(), and IperfUDP_SendTestPacket().
|
static |
References tstrIperfUint64::u32H, and tstrIperfUint64::u32L.
Referenced by IperfPrintStats(), IperfPrintUdpServerStats(), and IperfSocketEventHandler().
NMI_API sint8 IperfCreate | ( | tstrIperfInit * | pstrIperfInit, |
bool | bIsPaused | ||
) |
References IperfTCP_ClientStart(), IperfTCP_ServerStart(), IperfUDP_ClientStart(), IperfUDP_ServerStart(), M2M_ERR_FAIL, MODE_TCP_CLIENT, MODE_TCP_SERVER, MODE_UDP_CLIENT, MODE_UDP_SERVER, and tstrIperfInit::operating_mode.
Referenced by main().
|
static |
References gu8NumSockets, M2M_ERR, and nm_bsp_stop_1ms_timer().
Referenced by IperfSocketClose(), and IperfSocketEventHandler().
|
static |
References gu8NumSockets, Iperf1msTimerCB(), nm_bsp_start_1ms_timer(), u32LastStatsTime, and u32msTicks.
Referenced by IperfSocketEventHandler(), IperfTCP_Client_SendTestPacket(), and IperfUDP_ClientStart().
NMI_API void IperfInit | ( | void | ) |
References tstrIperfUdpMsg::gau8MsgBuffer, gu8NumSockets, IPERF_BUFFER_SIZE, and m2m_memset().
Referenced by main().
References IPERF_MAX_UDP_STATE, IperfCalculateBandwidthKbps(), IperfPrintUdpServerStats(), MODE_INIT, MODE_STOP, tstrIperfSocketInfo::strRxBytes, tstrIperfSocketInfo::strTxBytes, tcp_serv_pack_recv, TEST_STATE_TCP_RX, TEST_STATE_TCP_TX, TEST_STATE_UDP_RX, TEST_STATE_UDP_TX, tstrIperfUint64::u32H, u32msTicks, tstrIperfSocketInfo::u32TimeStart, app_status::udp_client, and app_status::udp_server.
Referenced by IperfSocketClose(), IperfSocketEventHandler(), IperfSocketStop(), and IperfUpdate().
References IperfCalculateBandwidthKbps(), tstrIperfUdpState::strRxBytes, tstrIperfUint64::u32H, u32msTicks, tstrIperfUdpState::u32TimeStart, and udp_serv_pack_recv.
Referenced by IperfPrintStats(), and IperfSocketEventHandler().
References close(), IPERF_MAX_UDP_STATE, IperfDecrementTimerUse(), IperfPrintStats(), IperfSocketClose(), M2M_ERR_FAIL, m2m_memset(), MAX_SOCKET, TCP_SOCK_MAX, TEST_STATE_TCP_RX, and TEST_STATE_UDP_RX.
Referenced by IperfSocketClose(), IperfSocketEventHandler(), IperfSocketStop(), IperfUpdate(), and main().
References _htonl, _htons, _ntohl, _ntohs, accept(), AF_INET, tstrIperfSocketInfo::bIsActive, tstrIperfUdpState::bIsActive, clientIPAddress, server_hdr::datagrams, server_hdr::error_cnt, client_hdr::flags, server_hdr::flags, tstrIperfUdpMsg::gau8MsgBuffer, gu32IPAddress, HEADER_VERSION1, UDP_datagram::id, inet_ntoa(), IPERF_MAX_UDP_STATE, IPERF_RX_BUFFER_SIZE, IperfAddUint64(), IperfCalculateBandwidthKbps(), IperfDecrementTimerUse(), IperfIncrementTimerUse(), IperfPrintStats(), IperfPrintUdpServerStats(), IperfSocketClose(), IperfTCP_SendTestPacket(), server_hdr::jitter1, server_hdr::jitter2, M2M_ERR, m2m_memset(), M2M_SUCCESS, m2m_wifi_yield(), MAX_SOCKET, MODE_FINISHED, MODE_INIT, MODE_RUN, MODE_START, MODE_WAIT, NBIT31, ntohl(), NULL, server_hdr::outorder_cnt, tstrSocketRecvMsg::pu8Buffer, recv(), recvfrom(), RUN_NOW, tstrSocketRecvMsg::s16BufferSize, tstrIperfSocketInfo::s32PktCount, tstrSocketConnectMsg::s8Error, in_addr::s_addr, sendto(), sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, tstrSocketAcceptMsg::sock, SOCK_ERR_BUFFER_FULL, SOCKET_MSG_ACCEPT, SOCKET_MSG_BIND, SOCKET_MSG_CONNECT, SOCKET_MSG_RECV, SOCKET_MSG_RECVFROM, SOCKET_MSG_SEND, tstrIperfSocketInfo::sockParent, tstrIperfUdpState::sockParent, tstrSocketBindMsg::status, server_hdr::stop_sec, server_hdr::stop_usec, tstrSocketAcceptMsg::strAddr, tstrSocketRecvMsg::strRemoteAddr, tstrIperfSocketInfo::strRxBytes, tstrIperfUdpState::strRxBytes, tstrIperfUdpServerMsg::strUdpDatagram, tstrIperfUdpServerMsg::strUdpServerHdr, app_status::tcp_client, app_status::tcp_server, TEST_STATE_TCP_RX, TEST_STATE_TCP_TX, TEST_STATE_UDP_RX, TEST_STATE_UDP_TX, server_hdr::total_len1, server_hdr::total_len2, tstrIperfSocketInfo::u16Port, tstrIperfUdpState::u16Port, tstrSocketRecvMsg::u16RemainingSize, tstrIperfUdpState::u16RxMissingPktsLastPeriod, tstrIperfUdpState::u16RxPktsLastPeriod, tstrIperfSocketInfo::u32BytesLastPeriod, tstrIperfUdpState::u32BytesLastPeriod, tstrIperfUint64::u32H, tstrIperfSocketInfo::u32IPAddress, tstrIperfUint64::u32L, tstrIperfSocketInfo::u32LastStatsTime, tstrIperfUdpState::u32LastStatsTime, u32msTicks, tstrIperfUdpState::u32NextRxSeqNum, tstrIperfSocketInfo::u32PktByteCount, tstrIperfSocketInfo::u32PktLength, tstrIperfUdpState::u32RxMissingPkts, tstrIperfSocketInfo::u32RxPkts, tstrIperfUdpState::u32RxPkts, tstrIperfSocketInfo::u32TimeStart, tstrIperfUdpState::u32TimeStart, tstrIperfSocketInfo::u32TxSQN, tstrIperfSocketInfo::u8PktsOutstanding, tstrIperfSocketInfo::u8State, udp_client_addr, app_status::udp_server, and udp_server_sock.
Referenced by main().
References IperfPrintStats(), IperfSocketClose(), M2M_SUCCESS, tstrIperfSocketInfo::s32PktCount, and TEST_STATE_UDP_TX.
Referenced by IperfStop().
References _htons, AF_INET, tstrIperfSocketInfo::bIsActive, tstrIperfSocketInfo::bIsPaused, IperfTCP_SendTestPacket(), IperfUDP_SendTestPacket(), M2M_SUCCESS, MAX_SOCKET, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, TEST_STATE_TCP_TX, TEST_STATE_UDP_TX, tstrIperfSocketInfo::u16Port, tstrIperfSocketInfo::u32IPAddress, tstrIperfSocketInfo::u32LastStatsTime, tstrIperfSocketInfo::u32LastTransmission, u32msTicks, tstrIperfSocketInfo::u32TimeStart, and tstrIperfSocketInfo::u8State.
References IperfSocketStop(), M2M_ERR_FAIL, M2M_SUCCESS, and MAX_SOCKET.
void IperfTCP_Client_SendTestPacket | ( | void | ) |
References IperfIncrementTimerUse(), IperfTCP_SendTestPacket(), and tcp_client_sock.
Referenced by main().
|
static |
References _htonl, _htons, AF_INET, tstrIperfSocketInfo::bIsActive, tstrIperfSocketInfo::bIsPaused, connect(), tstrIperfInit::ip, M2M_ERR_FAIL, m2m_memset(), M2M_SUCCESS, tstrIperfInit::packet_len, tstrIperfInit::packets_to_send, tstrIperfInit::port, tstrIperfSocketInfo::s32PktCount, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, socket(), SOCKET_FLAGS_SSL, tcp_client_sock, TEST_STATE_TCP_TX, tstrIperfInit::tls, tstrIperfSocketInfo::u16Port, tstrIperfSocketInfo::u32IPAddress, tstrIperfSocketInfo::u32PktLength, and tstrIperfSocketInfo::u8State.
Referenced by IperfCreate().
References tstrIperfUdpMsg::gau8MsgBuffer, IperfAddUint64(), M2M_ERR, send(), SOCK_ERR_BUFFER_FULL, tstrIperfSocketInfo::strTxBytes, tstrIperfSocketInfo::u32BytesLastPeriod, tstrIperfSocketInfo::u32LastStatsTime, u32msTicks, tstrIperfSocketInfo::u32PktLength, tstrIperfSocketInfo::u32TimeStart, tstrIperfSocketInfo::u32TxSQN, and tstrIperfSocketInfo::u8PktsOutstanding.
Referenced by IperfSocketEventHandler(), IperfStart(), and IperfTCP_Client_SendTestPacket().
|
static |
References _htons, accept(), AF_INET, bind(), tstrIperfSocketInfo::bIsActive, gu32IPAddress, listen(), M2M_ERR_FAIL, m2m_memset(), M2M_SUCCESS, NULL, tstrIperfInit::port, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, socket(), tstrIperfSocketInfo::sockParent, TCP_SOCK_MAX, TEST_STATE_TCP_RX, tstrIperfSocketInfo::u16Port, tstrIperfSocketInfo::u32IPAddress, and tstrIperfSocketInfo::u8State.
Referenced by IperfCreate().
|
static |
References _htonl, _htons, AF_INET, tstrIperfSocketInfo::bIsActive, tstrIperfSocketInfo::bIsPaused, tstrIperfInit::data_rate, tstrIperfInit::ip, IperfIncrementTimerUse(), IperfUDP_SendTestPacket(), M2M_ERR_FAIL, m2m_memset(), M2M_SUCCESS, MODE_START, tstrIperfInit::packet_len, tstrIperfInit::packets_to_send, tstrIperfInit::port, tstrIperfSocketInfo::s32PktCount, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, socket(), TEST_STATE_UDP_TX, tstrIperfSocketInfo::u16MsPeriod, tstrIperfSocketInfo::u16Port, tstrIperfSocketInfo::u32IPAddress, tstrIperfSocketInfo::u32LastStatsTime, tstrIperfSocketInfo::u32LastTransmission, u32msTicks, tstrIperfSocketInfo::u32PktLength, tstrIperfSocketInfo::u32TimeStart, tstrIperfSocketInfo::u8PktsOutstanding, tstrIperfSocketInfo::u8State, and app_status::udp_client.
Referenced by IperfCreate().
|
static |
References _htonl, client_hdr::flags, gu32IPAddress, UDP_datagram::id, inet_ntoa(), IperfAddUint64(), M2M_ERR, M2M_ERR_FAIL, M2M_SUCCESS, NULL, tstrIperfSocketInfo::s32PktCount, send(), sendto(), SOCK_ERR_BUFFER_FULL, tstrIperfUdpMsg::strUdpClientHdr, tstrIperfUdpMsg::strUdpDatagram, TEST_STATE_UDP_TX, UDP_datagram::tv_sec, UDP_datagram::tv_usec, tstrIperfSocketInfo::u32BytesLastPeriod, u32msTicks, tstrIperfSocketInfo::u32PktLength, and tstrIperfSocketInfo::u32TxSQN.
Referenced by IperfStart(), IperfUDP_ClientStart(), and IperfUpdate().
|
static |
References _htons, AF_INET, bind(), tstrIperfSocketInfo::bIsActive, gu32IPAddress, M2M_ERR_FAIL, m2m_memset(), M2M_SUCCESS, tstrIperfInit::port, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_DGRAM, socket(), TEST_STATE_UDP_RX, tstrIperfSocketInfo::u16Port, tstrIperfSocketInfo::u32IPAddress, and tstrIperfSocketInfo::u8State.
Referenced by IperfCreate().
References _htonl, client_hdr::flags, UDP_datagram::id, send(), tstrIperfUdpMsg::strUdpClientHdr, tstrIperfUdpMsg::strUdpDatagram, UDP_datagram::tv_sec, UDP_datagram::tv_usec, and u32msTicks.
Referenced by IperfUpdate().
NMI_API void IperfUpdate | ( | void | ) |
References tstrIperfSocketInfo::bIsActive, tstrIperfUdpState::bIsActive, tstrIperfSocketInfo::bIsPaused, tstrIperfUdpMsg::gau8MsgBuffer, IPERF_MAX_UDP_STATE, IPERF_RX_BUFFER_SIZE, IperfPrintStats(), IperfSocketClose(), IperfUDP_SendTestPacket(), IperfUDP_WriteFIN(), M2M_SUCCESS, MAX_SOCKET, NULL, recvfrom(), tstrIperfSocketInfo::s32PktCount, tstrIperfSocketInfo::sockParent, tstrIperfUdpState::sockParent, TCP_SOCK_MAX, TEST_STATE_TCP_RX, TEST_STATE_TCP_TX, TEST_STATE_UDP_RX, TEST_STATE_UDP_TX, tstrIperfSocketInfo::u16MsPeriod, tstrIperfUdpState::u16RxMissingPktsLastPeriod, tstrIperfUdpState::u16RxPktsLastPeriod, tstrIperfSocketInfo::u32BytesLastPeriod, tstrIperfUdpState::u32BytesLastPeriod, u32LastStatsTime, tstrIperfSocketInfo::u32LastTransmission, u32msTicks, tstrIperfSocketInfo::u32TimeStart, tstrIperfUdpState::u32TimeStart, tstrIperfSocketInfo::u8PktsOutstanding, and tstrIperfSocketInfo::u8State.
Referenced by main().
|
static |
Referenced by IperfSocketEventHandler().
uint32 clientIPAddress |
Referenced by IperfSocketEventHandler(), and main().
|
static |
|
static |
|
static |
|
static |
|
static |
uint32 gu32IPAddress |
|
static |
Referenced by IperfDecrementTimerUse(), IperfIncrementTimerUse(), and IperfInit().
app_status iperf_app_stat |
|
static |
SOCKET tcp_client_sock |
Referenced by IperfTCP_Client_SendTestPacket(), and IperfTCP_ClientStart().
uint32_t tcp_serv_pack_recv |
Referenced by IperfPrintStats(), and main().
|
static |
Referenced by IperfIncrementTimerUse(), and IperfUpdate().
|
static |
uint32_t udp_serv_pack_recv |
Referenced by IperfPrintUdpServerStats(), and main().
SOCKET udp_server_sock |
Referenced by IperfSocketEventHandler(), and main().