Microchip® Advanced Software Framework

winc3400/iperf_server_example/iperf.c File Reference

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
 

Functions

static char * inet_ntoa (uint32 in)
 
static void Iperf1msTimerCB (void)
 
static void IperfAddUint64 (tstrIperfUint64 *pstrUint64, uint32 u32Inc)
 
static uint32 IperfCalculateBandwidthKbps (tstrIperfUint64 *pstrUint64, uint32 u32Time)
 
NMI_API sint8 IperfCreate (tstrIperfInit *pstrIperfInit, bool bIsPaused)
 
static void IperfDecrementTimerUse (void)
 
static void IperfIncrementTimerUse (void)
 
NMI_API void IperfInit (void)
 
NMI_API void IperfPrintStats (SOCKET sock)
 
static void IperfPrintUdpServerStats (SOCKET sock, uint8 u8UdpStateIdx)
 
NMI_API sint8 IperfSocketClose (SOCKET sock)
 
void IperfSocketEventHandler (SOCKET sock, uint8 u8Msg, void *pvMsg)
 
static sint8 IperfSocketStop (SOCKET sock)
 
NMI_API sint8 IperfStart (void)
 
NMI_API sint8 IperfStop (SOCKET sock)
 
void IperfTCP_Client_SendTestPacket (void)
 
static sint8 IperfTCP_ClientStart (tstrIperfInit *pstrIperfInit, bool bIsPaused)
 
static sint8 IperfTCP_SendTestPacket (SOCKET sock)
 
static sint8 IperfTCP_ServerStart (tstrIperfInit *pstrIperfInit)
 
static SOCKET IperfUDP_ClientStart (tstrIperfInit *pstrIperfInit, bool bIsPaused)
 
static sint8 IperfUDP_SendTestPacket (SOCKET sock, struct sockaddr_in *paddr)
 
static sint8 IperfUDP_ServerStart (tstrIperfInit *pstrIperfInit)
 
static sint8 IperfUDP_WriteFIN (SOCKET sock)
 
NMI_API void IperfUpdate (void)
 
static uint32_t ntohl (uint32_t n)
 

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

static char* inet_ntoa ( uint32  in)
static

References ptr.

Referenced by IperfSocketEventHandler(), and IperfUDP_SendTestPacket().

static void Iperf1msTimerCB ( void  )
static

References u32msTicks.

Referenced by IperfIncrementTimerUse().

static void IperfAddUint64 ( tstrIperfUint64 pstrUint64,
uint32  u32Inc 
)
static
static uint32 IperfCalculateBandwidthKbps ( tstrIperfUint64 pstrUint64,
uint32  u32Time 
)
static
static void IperfDecrementTimerUse ( void  )
static
void IperfSocketEventHandler ( SOCKET  sock,
uint8  u8Msg,
void *  pvMsg 
)

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, printf, tstrSocketRecvMsg::pu8Buffer, recv(), recvfrom(), ret, 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.

static sint8 IperfSocketStop ( SOCKET  sock)
static
NMI_API sint8 IperfStop ( SOCKET  sock)
void IperfTCP_Client_SendTestPacket ( void  )
static uint32_t ntohl ( uint32_t  n)
static

Referenced by IperfSocketEventHandler().

uint32 clientIPAddress
tstrIperfSocketInfo gastrIperfSocketInfo[MAX_SOCKET]
static
tstrIperfUdpState gastrIperfUdpState[IPERF_MAX_UDP_STATE]
static
tstrIperfUdpMsg gstrRxMsgBuffer
static
tstrIperfUdpMsg gstrTxMsgBuffer
static
tstrIperfUdpServerMsg gstrTxSrvMsg
static
uint32 gu32IPAddress
uint8 gu8NumSockets
static
app_status iperf_app_stat
client_hdr iperf_tcp_serv
static
SOCKET tcp_client_sock
uint32_t tcp_serv_pack_recv
uint32_t u32LastStatsTime
static
uint32_t udp_serv_pack_recv
SOCKET udp_server_sock