Skip to content

0x050f/ft_ping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_ping

Compilation

make

Usage

sudo ./ft_ping [options] <destination>

(ft_ping need sudo to bind socket)

Usage
  ping [options] <destination>

Options:
  <destination>      dns name or ip address
  -f                 flood ping
  -h                 print help and exit
  -n                 no dns name resolution
  -t <ttl>           define time to live
  -w <deadline>      reply wait <deadline> in seconds

Packet

Ping use icmp packet with a payload of 56 bytes by default, this project use this structure (defined in ft_ping.h):

typedef struct		s_icmp_packet
{
	struct iphdr	iphdr;
	struct icmphdr	icmphdr;
	char		payload[PAYLOAD_SIZE];
}			t_icmp_packet;

From wikipedia:

-----------------------------------------------------------------
|IPv4 datagram | Bits 0–7 | Bits 8–15 | Bits 16–23 | Bits 24–31 |
---------------|------------------------------------------------|
|              | Versions |    ToS    |         Length          |
|              |------------------------------------------------|
|              |    Identification    |     flags and offsets   |
|    Header    |------------------------------------------------|
|  (20 bytes)  |    TTL   |  Protocol |     Header checksum     |
|              |------------------------------------------------|
|              |              Source IP Address                 |
|              |------------------------------------------------|
|              |           Destination IP Address               |
|--------------|------------------------------------------------|
|  ICMP Header |   Type   |    Code   |        Checksum         |
|   (8 bytes)  |------------------------------------------------|
|              |                 Header data                    |
|--------------|------------------------------------------------|
| ICMP Payload |                 Payload data                   |
|  (56 bytes)  |                                                |
|----------------------------------------------------------------

Documentation

About

A 42 ping implementation

Topics

Resources

Stars

Watchers

Forks