bwping  1.17
About: BWPing is a tool to measure bandwidth and response times between two hosts using Internet Control Message Protocol (ICMP) echo request/echo reply mechanism.
  Fossies Dox: bwping-1.17.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

bwping.c File Reference
#include "../include/features.h"
#include <sys/time.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <inttypes.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sysexits.h>
#include <time.h>
#include <errno.h>
#include <string.h>
#include <libgen.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/ip_icmp.h>
#include <netdb.h>
Include dependency graph for bwping.c:

Go to the source code of this file.

Functions

static void get_time (struct timespec *ts)
 
static int64_t ts_sub (const struct timespec *ts1, const struct timespec *ts2)
 
static uint16_t cksum (const void *packet, size_t pkt_size)
 
static int64_t calibrate_timer (void)
 
static void send_ping4 (int sock, const struct addrinfo *to_ai, size_t pkt_size, uint16_t ident, bool first_in_burst, uint32_t *transmitted_number, uint64_t *transmitted_volume)
 
static void send_ping6 (int sock, const struct addrinfo *to_ai, size_t pkt_size, uint16_t ident, bool first_in_burst, uint32_t *transmitted_number, uint64_t *transmitted_volume)
 
static bool recv_ping4 (int sock, uint16_t ident, uint32_t *received_number, uint64_t *received_volume, int64_t *min_rtt, int64_t *max_rtt, int64_t *average_rtt)
 
static bool recv_ping6 (int sock, uint16_t ident, uint32_t *received_number, uint64_t *received_volume, int64_t *min_rtt, int64_t *max_rtt, int64_t *average_rtt)
 
static bool resolve_name (bool ipv4_mode, const char *name, struct addrinfo **addr_info)
 
int main (int argc, char *argv[])
 

Variables

static const size_t MAX_IPV4_HDR_SIZE = 60
 
static const uint32_t CALIBRATION_CYCLES = 100
 
static const uint32_t PKT_BURST_PRECISION = 1000
 
static const uint32_t BUF_SIZE_RESERVE_FACTOR = 10
 
static char * prog_name
 

Function Documentation

◆ calibrate_timer()

static int64_t calibrate_timer ( void  )
static

Definition at line 104 of file bwping.c.

References CALIBRATION_CYCLES, get_time(), and ts_sub().

Referenced by main().

◆ cksum()

static uint16_t cksum ( const void *  packet,
size_t  pkt_size 
)
static

Definition at line 86 of file bwping.c.

Referenced by send_ping4().

◆ get_time()

static void get_time ( struct timespec *  ts)
static

Definition at line 47 of file bwping.c.

References prog_name.

Referenced by calibrate_timer(), main(), recv_ping4(), recv_ping6(), send_ping4(), and send_ping6().

◆ main()

◆ recv_ping4()

static bool recv_ping4 ( int  sock,
uint16_t  ident,
uint32_t *  received_number,
uint64_t *  received_volume,
int64_t *  min_rtt,
int64_t *  max_rtt,
int64_t *  average_rtt 
)
static

Definition at line 192 of file bwping.c.

References get_time(), ICMP_ECHOREPLY, icmp::icmp_type, and ts_sub().

Referenced by main().

◆ recv_ping6()

static bool recv_ping6 ( int  sock,
uint16_t  ident,
uint32_t *  received_number,
uint64_t *  received_volume,
int64_t *  min_rtt,
int64_t *  max_rtt,
int64_t *  average_rtt 
)
static

Definition at line 249 of file bwping.c.

References get_time(), ICMP6_ECHO_REPLY, icmp6_hdr::icmp6_type, and ts_sub().

Referenced by main().

◆ resolve_name()

static bool resolve_name ( bool  ipv4_mode,
const char *  name,
struct addrinfo **  addr_info 
)
static

Definition at line 298 of file bwping.c.

References prog_name.

Referenced by main().

◆ send_ping4()

static void send_ping4 ( int  sock,
const struct addrinfo *  to_ai,
size_t  pkt_size,
uint16_t  ident,
bool  first_in_burst,
uint32_t *  transmitted_number,
uint64_t *  transmitted_volume 
)
static

Definition at line 132 of file bwping.c.

References cksum(), get_time(), icmp::icmp_cksum, ICMP_ECHO, icmp::icmp_type, and prog_name.

Referenced by main().

◆ send_ping6()

static void send_ping6 ( int  sock,
const struct addrinfo *  to_ai,
size_t  pkt_size,
uint16_t  ident,
bool  first_in_burst,
uint32_t *  transmitted_number,
uint64_t *  transmitted_volume 
)
static

Definition at line 164 of file bwping.c.

References get_time(), ICMP6_ECHO_REQUEST, icmp6_hdr::icmp6_type, and prog_name.

Referenced by main().

◆ ts_sub()

static int64_t ts_sub ( const struct timespec *  ts1,
const struct timespec *  ts2 
)
static

Definition at line 81 of file bwping.c.

Referenced by calibrate_timer(), main(), recv_ping4(), and recv_ping6().

Variable Documentation

◆ BUF_SIZE_RESERVE_FACTOR

const uint32_t BUF_SIZE_RESERVE_FACTOR = 10
static

Definition at line 43 of file bwping.c.

Referenced by main().

◆ CALIBRATION_CYCLES

const uint32_t CALIBRATION_CYCLES = 100
static

Definition at line 41 of file bwping.c.

Referenced by calibrate_timer().

◆ MAX_IPV4_HDR_SIZE

const size_t MAX_IPV4_HDR_SIZE = 60
static

Definition at line 40 of file bwping.c.

Referenced by main().

◆ PKT_BURST_PRECISION

const uint32_t PKT_BURST_PRECISION = 1000
static

Definition at line 42 of file bwping.c.

Referenced by main().

◆ prog_name

char* prog_name
static

Definition at line 45 of file bwping.c.

Referenced by get_time(), main(), resolve_name(), send_ping4(), and send_ping6().