miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
main.c File Reference

ping — sends 4 ICMP echo requests via SOCK_RAW, measures RTT with clock_gettime(CLOCK_MONOTONIC), and prints per-packet timing + summary. Per D-08 through D-12. More...

#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <time.h>
#include <stdint.h>
Include dependency graph for main.c:

Macros

#define SOCK_RAW   3
#define IPPROTO_ICMP   1
#define PING_COUNT   4
#define ICMP_ECHO_ID   0x1234

Functions

static void rprint (const char *s)
static void rprint_int (long val)
 Convert a signed integer to decimal string and write via rprint.
static unsigned short icmp_checksum (const void *data, int len)
 Compute ones-complement Internet checksum. Verbatim copy from user/rawtest/main.c.
static uint32_t parse_ipv4 (const char *s)
 Parse "A.B.C.D" into the packed IPv4 layout used by miniOS raw sockets.
int main (int argc, char *argv[])

Detailed Description

ping — sends 4 ICMP echo requests via SOCK_RAW, measures RTT with clock_gettime(CLOCK_MONOTONIC), and prints per-packet timing + summary. Per D-08 through D-12.

Macro Definition Documentation

◆ ICMP_ECHO_ID

#define ICMP_ECHO_ID   0x1234

◆ IPPROTO_ICMP

#define IPPROTO_ICMP   1

◆ PING_COUNT

#define PING_COUNT   4

◆ SOCK_RAW

#define SOCK_RAW   3

Function Documentation

◆ icmp_checksum()

unsigned short icmp_checksum ( const void * data,
int len )
static

Compute ones-complement Internet checksum. Verbatim copy from user/rawtest/main.c.

Here is the caller graph for this function:

◆ main()

int main ( int argc,
char * argv[] )
Here is the call graph for this function:

◆ parse_ipv4()

uint32_t parse_ipv4 ( const char * s)
static

Parse "A.B.C.D" into the packed IPv4 layout used by miniOS raw sockets.

Per T-44-02-02: rejects malformed input by returning 0 when any octet exceeds 255 or fewer than 4 octets are present.

Returns
Packed IPv4 uint32 compatible with rawtest/QEMU_GW_ADDR, or 0 on parse failure.

◆ rprint()

void rprint ( const char * s)
static
Here is the call graph for this function:

◆ rprint_int()

void rprint_int ( long val)
static

Convert a signed integer to decimal string and write via rprint.

Here is the call graph for this function:
Here is the caller graph for this function: