src/vfer.h File Reference

Header file that is used by multiple sources within the protocol stack. More...

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <signal.h>
#include <sys/select.h>
#include <sys/mman.h>
#include <errno.h>
#include <math.h>
#include <fcntl.h>
#include <sys/time.h>
#include <time.h>
#include "vfer_btree_delay.h"
#include "vfer_accept_queue.h"
#include "vfer_datagram.h"
#include "vfer_packet.h"

Go to the source code of this file.

Data Structures

struct  ccontrol
 congestion control structure maintained for each socket More...
struct  context_t
 context structure used by the reliability functino to evaluate reliability for a frame More...
struct  path_mtu
 Structure holding values related to path MTU discovery. More...
struct  vfer_sock
 vfer socket structure holding everything associated with a single vfer connection More...
struct  vfer_socks
 a sockets array with a protecting mutex, underlying fd sets, and more. More...
struct  vfer_stats
 VFER stats structure maintained for each socket. More...

Defines

#define ALLOC(DST_ADDR, TYPE_POINTER, TYPE, NUM)
#define CALC_UDP_RECV_BUF_SIZE(MAXPACKETS)   ((DATA_LENGTH + INIT_MTU)*MAXPACKETS)
#define CALC_UDP_SEND_BUF_SIZE(MAXPACKETS)   ((DATA_LENGTH + INIT_MTU)*MAXPACKETS)
#define CCONTROL_TARGET   8000
#define CLR_SOCKET_STATS(stats_ptr)   { bzero(stats_ptr, sizeof(struct vfer_stats)); }
#define COMMON_MTU_LIST   { 1024, 1430, 1978, 4282, 8096, 17844, 31030, 65465 }
#define COMMON_MTU_MAX_INDEX   7
#define CONTROLT_SLEEPTIME   1000
#define DEBUG_CC(COND, FILE, FUNC, SOCKET,)
#define DEBUG_ERR
#define DEBUG_OUT
#define DEBUG_PACK(COND, FILE, FUNC, PACKET,)
#define DEBUG_PMTUD_PRINT(COND, FILE, FUNC,)
#define DEBUG_PRINT(COND, FILE, FUNC,)
#define DEFAULT_CONNECT_TIMEOUT   60000000
#define DEFAULT_RECV_BUF_MAXPACKETS   3000
#define DEFAULT_SEND_BUF_MAXPACKETS   3000
#define DEST_UNREACHABLE   3
#define ERROR_PRINT(FILE, FUNC,)
#define FRAG_NEEDED   4
#define FRAME_WINDOW   5
#define GET_TIME_OF_DAY(TV_PTR)   gettimeofday(TV_PTR, NULL);
#define HANDSHAKE_ACK_WAIT_INTERVAL   1000000
#define INIT_MTU   1024
#define MAX_CWND_INCREASE_PACKETS_PER_RTT   8
#define MAX_FRAME_SIZE   65535
#define MAX_REQUEST_TRIES   5
#define MAX_RESPONSE_TRIES   5
#define MAX_SEND_WINDOW   1024*8000
#define MAX_SOCKETS   64
#define MMAP_CHUNK_SIZE   50000000
#define MTU_FOUND   2
#define NO_PMTUD   3
#define NO_PROBE_SENT   0
#define PMTUD_TIME_INTERVAL   600
#define PRINT_MEM   printf("MEMORY USED [%d bytes]\n", (int)ReqMem);
#define PROBE_SENT   1
#define RELEASE(POINTER_TO_BLOCK, SIZE)
#define RELEASE_IOV(IOV, LEN)
#define RELEASE_PACK(PACK)
#define REQUEST_RETRY_INTERVAL   1000000
#define RTT(SOCK_PTR, TV)   abs(SOCK_PTR->ccontrol.delay - Tree_Min(&(SOCK_PTR->ccontrol.rev_path_curr_delayhist), TV))
#define SEQ_WINDOW   5
#define SET_ERROR_RETURN(sock, error_type, ret)
#define SET_ERROR_UNLOCK_RETURN(sock, error_type, mutex_ptr, ret)
#define SOCK_OPT_ISSET(socket, opt)   (socket->opts & opt)
#define TIMEVAL_MS(TV)   ((unsigned int)(((TV).tv_sec * 1000) + ((TV).tv_usec / 1000)))
#define TIMEVAL_MS_DIFF(TV1, TV2)   (TIMEVAL_MS(TV2) - TIMEVAL_MS(TV1))
#define TIMEVAL_US(TV)   ((unsigned int)(((TV).tv_sec * 1000000) + ((TV).tv_usec)))
#define TIMEVAL_US_DIFF(TV1, TV2)   (TIMEVAL_US(TV2) - TIMEVAL_US(TV1))
#define TREE_INIT(TREE_PTR, INIT_VAL, TV)
#define UNACKED_THRESH   4
#define UNLOCK_AND_RETURN_ERROR(mutex, err)
#define URGENCY_THRESHOLD   1
#define VFER_VERSION   1

Typedefs

typedef uint32_t bool_t
typedef ccontrol ccontrol_t
 congestion control structure maintained for each socket
typedef bool_t(*) relfun_t (context_t *)
typedef sockaddr SA
typedef enum sock_mark sock_mark_t
typedef int vfer_fd
typedef vfer_socks vfer_socks_t
 a sockets array with a protecting mutex, underlying fd sets, and more.

Enumerations

enum  sock_mark { VFER_READABLE = 1, VFER_WRITABLE = 2, VFER_EXCEPTION = 4 }
enum  sock_opt {
  VFERSO_QTTL = 1, VFERSO_SNDSIZE = 3, VFERSO_RELFUN = 5, VFERSO_CONNECTTIMEOUT = 6,
  VFERSO_CLOSETIMEOUT = 7, VFERSO_ACCEPTTIMEOUT = 9, VFERSO_SNDTIMEOUT = 10, VFERSO_RCVTIMEOUT = 11,
  VFERSO_NOPMTUD = 2, VFERSO_NONBLOCK = 4, VFERSO_CLIENT_SOCK = 8
}
enum  sock_state {
  CONN_ACQUIRED, CONN_BOUND, CONN_LISTENING, CONN_ACCEPTING,
  CONN_CONNECTING, CONN_CONNECTED, CONN_DISCONNECTING, CONN_DISCONNECTED,
  CONN_ERR
}
enum  vfer_error {
  VFER_BADTYPE = -40, VFER_IMPL, VFER_BADSOCK, VFER_TIMEOUT,
  VFER_REFUSED, VFER_NOCONN, VFER_NOBIND, VFER_BADADDR,
  VFER_NOLISTEN, VFER_NOACCEPT, VFER_NOTSTREAM, VFER_WOULDBLOCK,
  VFER_BADOPT, VFER_BADFD, VFER_INVAL, VFER_UNCONN,
  VFER_INPROGRESS
}
 vfer_error type More...

Variables

char DEBUG_ACCEPTQ
char DEBUG_API
char DEBUG_CCTL
char DEBUG_CTL
FILE * debug_out
char DEBUG_PACKET
char DEBUG_PMTUD
FILE * error_out
long int ReqMem
vfer_socks_t sockets


Detailed Description

Header file that is used by multiple sources within the protocol stack.

Author:
Ivan Beschastnikh
This header file includes many useful macros & functions for error processing, memory allocation and more.

Definition in file vfer.h.


Define Documentation

#define ALLOC ( DST_ADDR,
TYPE_POINTER,
TYPE,
NUM   ) 

Value:

({ \
        DST_ADDR=NULL; \
        if ((DST_ADDR = (TYPE_POINTER) calloc(NUM, sizeof( TYPE )))) \
             ReqMem += (sizeof(TYPE) * NUM); \
        /* printf("ALLOC[%d]\n", ReqMem); */ \
        DST_ADDR; })

Definition at line 162 of file vfer.h.

#define CALC_UDP_RECV_BUF_SIZE ( MAXPACKETS   )     ((DATA_LENGTH + INIT_MTU)*MAXPACKETS)

Definition at line 248 of file vfer.h.

#define CALC_UDP_SEND_BUF_SIZE ( MAXPACKETS   )     ((DATA_LENGTH + INIT_MTU)*MAXPACKETS)

Definition at line 249 of file vfer.h.

#define CCONTROL_TARGET   8000

Definition at line 267 of file vfer.h.

#define CLR_SOCKET_STATS ( stats_ptr   )     { bzero(stats_ptr, sizeof(struct vfer_stats)); }

Definition at line 209 of file vfer.h.

#define COMMON_MTU_LIST   { 1024, 1430, 1978, 4282, 8096, 17844, 31030, 65465 }

Definition at line 231 of file vfer.h.

#define COMMON_MTU_MAX_INDEX   7

Definition at line 232 of file vfer.h.

#define CONTROLT_SLEEPTIME   1000

Definition at line 256 of file vfer.h.

#define DEBUG_CC ( COND,
FILE,
FUNC,
SOCKET   ) 

Value:

if (COND && debug_out != NULL) { \
                    struct timeval tv; \
                    GET_TIME_OF_DAY(&tv); \
                    fprintf(debug_out, "%-13s [ %-20s ] ", #COND, FUNC); \
                    fprintf(debug_out, "rtt[%u] sendw[%u,%u] cwnd[%d] inflight[%u] recvw[%u,%u] rlost[%u] delay[dlta %d]\n", \
                            (RTT(SOCKET,tv) == 0 ? 1 : RTT(SOCKET,tv)), SOCKET->ccontrol.s_first_seq, SOCKET->ccontrol.s_last_seq, SOCKET->ccontrol.s_cwnd, \
                            SOCKET->ccontrol.s_inflight, SOCKET->ccontrol.r_first_seq, SOCKET->ccontrol.r_last_seq, SOCKET->ccontrol.r_packets_lost, \
                            SOCKET->ccontrol.delay_delta); \
                    fflush(debug_out);   \
                }

Definition at line 114 of file vfer.h.

#define DEBUG_ERR

Definition at line 76 of file vfer.h.

#define DEBUG_OUT

Definition at line 78 of file vfer.h.

#define DEBUG_PACK ( COND,
FILE,
FUNC,
PACKET   ) 

Value:

if (COND && debug_out != NULL) {fprintf(debug_out, "%-13s [ %-20s ] ", #COND, FUNC); \
                fprintf(debug_out, __VA_ARGS__); \
                fprintf(debug_out, "\n%-50s %s\n", " ", Packet_Str(PACKET)); \
                /* fprintf(debug_out, "%s\n", Packet_Str(PACKET)); */ \
                fflush(debug_out); }

Definition at line 108 of file vfer.h.

#define DEBUG_PMTUD_PRINT ( COND,
FILE,
FUNC   ) 

Value:

if (COND && debug_out != NULL) {fprintf(debug_out, "%-13s [ %-20s ] ", #COND, FUNC); \
                        fprintf(debug_out, __VA_ARGS__); \
                        fprintf(debug_out, "\n"); \
                        fflush(debug_out);}

Definition at line 125 of file vfer.h.

#define DEBUG_PRINT ( COND,
FILE,
FUNC   ) 

Value:

if (COND && debug_out != NULL) {fprintf(debug_out, "%-13s [ %-20s ] ", #COND, FUNC); \
                fprintf(debug_out, __VA_ARGS__); \
                fprintf(debug_out, "\n"); \
                fflush(debug_out); }

Definition at line 103 of file vfer.h.

#define DEFAULT_CONNECT_TIMEOUT   60000000

Definition at line 262 of file vfer.h.

#define DEFAULT_RECV_BUF_MAXPACKETS   3000

Definition at line 244 of file vfer.h.

#define DEFAULT_SEND_BUF_MAXPACKETS   3000

Definition at line 245 of file vfer.h.

#define DEST_UNREACHABLE   3

Definition at line 240 of file vfer.h.

#define ERROR_PRINT ( FILE,
FUNC   ) 

Value:

{ \
                fprintf(error_out, "ERROR [%s :: %s] ", FILE, FUNC); \
                fprintf(error_out, __VA_ARGS__); \
                fprintf(error_out, "\n"); \
                fflush(error_out); }

Definition at line 93 of file vfer.h.

#define FRAG_NEEDED   4

Definition at line 241 of file vfer.h.

#define FRAME_WINDOW   5

Definition at line 253 of file vfer.h.

#define GET_TIME_OF_DAY ( TV_PTR   )     gettimeofday(TV_PTR, NULL);

Definition at line 146 of file vfer.h.

#define HANDSHAKE_ACK_WAIT_INTERVAL   1000000

Definition at line 219 of file vfer.h.

#define INIT_MTU   1024

Definition at line 226 of file vfer.h.

#define MAX_CWND_INCREASE_PACKETS_PER_RTT   8

Definition at line 266 of file vfer.h.

#define MAX_FRAME_SIZE   65535

Definition at line 227 of file vfer.h.

#define MAX_REQUEST_TRIES   5

Definition at line 222 of file vfer.h.

#define MAX_RESPONSE_TRIES   5

Definition at line 218 of file vfer.h.

#define MAX_SEND_WINDOW   1024*8000

Definition at line 259 of file vfer.h.

#define MAX_SOCKETS   64

Definition at line 495 of file vfer.h.

#define MMAP_CHUNK_SIZE   50000000

Definition at line 251 of file vfer.h.

#define MTU_FOUND   2

Definition at line 235 of file vfer.h.

#define NO_PMTUD   3

Definition at line 236 of file vfer.h.

#define NO_PROBE_SENT   0

Definition at line 233 of file vfer.h.

#define PMTUD_TIME_INTERVAL   600

Definition at line 237 of file vfer.h.

#define PRINT_MEM   printf("MEMORY USED [%d bytes]\n", (int)ReqMem);

Definition at line 138 of file vfer.h.

#define PROBE_SENT   1

Definition at line 234 of file vfer.h.

#define RELEASE ( POINTER_TO_BLOCK,
SIZE   ) 

Value:

{ \
        free(POINTER_TO_BLOCK); \
        ReqMem -= SIZE; \
        /* printf("FREE[%d]\n", ReqMem); */ }\

Definition at line 169 of file vfer.h.

#define RELEASE_IOV ( IOV,
LEN   ) 

Value:

{ \
        int release_iov_itter; \
        for(release_iov_itter = 0; release_iov_itter < LEN; release_iov_itter++) { \
                /* printf(" : iov[%d] len[%d] : ", release_iov_itter, IOV[release_iov_itter].iov_len); */ \
                RELEASE(IOV[release_iov_itter].iov_base, IOV[release_iov_itter].iov_len); } \
        RELEASE(IOV, sizeof(struct iovec));}

Definition at line 174 of file vfer.h.

#define RELEASE_PACK ( PACK   ) 

Value:

{ \
        /* printf("releasing pack with iovlen[%d] : ", PACK->iovlen); */ \
        RELEASE_IOV(PACK->iov, PACK->iovlen); \
        RELEASE(PACK, sizeof(struct packet));}

Definition at line 181 of file vfer.h.

#define REQUEST_RETRY_INTERVAL   1000000

Definition at line 223 of file vfer.h.

#define RTT ( SOCK_PTR,
TV   )     abs(SOCK_PTR->ccontrol.delay - Tree_Min(&(SOCK_PTR->ccontrol.rev_path_curr_delayhist), TV))

Definition at line 160 of file vfer.h.

#define SEQ_WINDOW   5

Definition at line 252 of file vfer.h.

#define SET_ERROR_RETURN ( sock,
error_type,
ret   ) 

Value:

{ \
        if (sock != NULL) sock->err = error_type; \
        return ret; }

Definition at line 190 of file vfer.h.

#define SET_ERROR_UNLOCK_RETURN ( sock,
error_type,
mutex_ptr,
ret   ) 

Value:

{ \
        if (sock != NULL) sock->err = error_type; \
        pthread_mutex_lock(mutex_ptr); \
        return ret; }

Definition at line 194 of file vfer.h.

#define SOCK_OPT_ISSET ( socket,
opt   )     (socket->opts & opt)

Definition at line 212 of file vfer.h.

#define TIMEVAL_MS ( TV   )     ((unsigned int)(((TV).tv_sec * 1000) + ((TV).tv_usec / 1000)))

Definition at line 150 of file vfer.h.

#define TIMEVAL_MS_DIFF ( TV1,
TV2   )     (TIMEVAL_MS(TV2) - TIMEVAL_MS(TV1))

Definition at line 154 of file vfer.h.

#define TIMEVAL_US ( TV   )     ((unsigned int)(((TV).tv_sec * 1000000) + ((TV).tv_usec)))

Definition at line 151 of file vfer.h.

#define TIMEVAL_US_DIFF ( TV1,
TV2   )     (TIMEVAL_US(TV2) - TIMEVAL_US(TV1))

Definition at line 157 of file vfer.h.

#define TREE_INIT ( TREE_PTR,
INIT_VAL,
TV   ) 

Value:

{ \
                if (INIT_VAL >= 1000000) { \
                        TV.tv_sec = (int)(INIT_VAL / 1000000.0); \
                } else { \
                        TV.tv_sec = 0; \
                } \
                TV.tv_usec = (INIT_VAL - TV.tv_sec * 1000000); \
                Tree_Init(TREE_PTR, TV); }

Definition at line 200 of file vfer.h.

#define UNACKED_THRESH   4

Definition at line 265 of file vfer.h.

#define UNLOCK_AND_RETURN_ERROR ( mutex,
err   ) 

Value:

{ \
        pthread_mutex_unlock(&mutex); \
        return err; }

Definition at line 186 of file vfer.h.

#define URGENCY_THRESHOLD   1

Definition at line 228 of file vfer.h.

#define VFER_VERSION   1

Definition at line 66 of file vfer.h.


Typedef Documentation

typedef uint32_t bool_t

Definition at line 346 of file vfer.h.

typedef struct ccontrol ccontrol_t

congestion control structure maintained for each socket

typedef bool_t(*) relfun_t(context_t *)

Definition at line 347 of file vfer.h.

typedef struct sockaddr SA

Definition at line 273 of file vfer.h.

typedef enum sock_mark sock_mark_t

typedef int vfer_fd

Definition at line 509 of file vfer.h.

typedef struct vfer_socks vfer_socks_t

a sockets array with a protecting mutex, underlying fd sets, and more.


Enumeration Type Documentation

enum sock_mark

Enumerator:
VFER_READABLE 
VFER_WRITABLE 
VFER_EXCEPTION 

Definition at line 372 of file vfer.h.

enum sock_opt

Enumerator:
VFERSO_QTTL 
VFERSO_SNDSIZE 
VFERSO_RELFUN 
VFERSO_CONNECTTIMEOUT 
VFERSO_CLOSETIMEOUT 
VFERSO_ACCEPTTIMEOUT 
VFERSO_SNDTIMEOUT 
VFERSO_RCVTIMEOUT 
VFERSO_NOPMTUD 
VFERSO_NONBLOCK 
VFERSO_CLIENT_SOCK 

Definition at line 395 of file vfer.h.

enum sock_state

Enumerator:
CONN_ACQUIRED 
CONN_BOUND 
CONN_LISTENING 
CONN_ACCEPTING 
CONN_CONNECTING 
CONN_CONNECTED 
CONN_DISCONNECTING 
CONN_DISCONNECTED 
CONN_ERR 

Definition at line 378 of file vfer.h.

enum vfer_error

vfer_error type

Enumerator:
VFER_BADTYPE 
VFER_IMPL 
VFER_BADSOCK 
VFER_TIMEOUT 
VFER_REFUSED 
VFER_NOCONN 
VFER_NOBIND 
VFER_BADADDR 
VFER_NOLISTEN 
VFER_NOACCEPT 
VFER_NOTSTREAM 
VFER_WOULDBLOCK 
VFER_BADOPT 
VFER_BADFD 
VFER_INVAL 
VFER_UNCONN 
VFER_INPROGRESS 

Definition at line 352 of file vfer.h.


Variable Documentation

char DEBUG_ACCEPTQ

Definition at line 84 of file vfer.h.

char DEBUG_API

Definition at line 85 of file vfer.h.

char DEBUG_CCTL

Definition at line 87 of file vfer.h.

char DEBUG_CTL

Definition at line 86 of file vfer.h.

FILE* debug_out

Definition at line 72 of file vfer.h.

char DEBUG_PACKET

Definition at line 88 of file vfer.h.

char DEBUG_PMTUD

Definition at line 89 of file vfer.h.

FILE* error_out

Definition at line 73 of file vfer.h.

long int ReqMem

Definition at line 516 of file vfer.h.

vfer_socks_t sockets

Definition at line 515 of file vfer.h.


Generated on Tue Aug 8 16:07:20 2006 for VFER by  doxygen 1.4.7