-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.h
74 lines (64 loc) · 1.7 KB
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef UTIL_H_
#define UTIL_H_
#define MAX_HOPS 30 /* This is the default for traceroute */
#define MAX_STR_LEN 120
#define MAX_PACKETS 1000
#include <sys/types.h>
struct protocol {
int id;
char *name;
};
struct packet {
int id; /* This is the original packet # in the trace file for debugging */
u_short ip_id;
u_short src_id;
long time; /* Time in milliseconds */
char ip_src[MAX_STR_LEN]; /* source IP */
char ip_dst[MAX_STR_LEN]; /* destination IP */
u_int8_t t_udp:1;
u_int8_t t_icmp:1;
u_int8_t mf:1;
u_int8_t df:1;
u_short offset;
u_int8_t ttl;
u_int8_t icmp_type;
u_int8_t icmp_code;
u_int16_t seq;
u_short ip_p;
};
struct node {
char ip[MAX_STR_LEN]; /* IP of this node */
int dist; /* Number of hops from source */
};
struct fragment {
u_short id;
int count;
u_short offset;
};
struct rtt {
char ip_dst[MAX_STR_LEN]; /* IP of the destination node */
double mean; /* Average RTT across all packets sent */
double dev; /* Standard deviation */
};
struct result {
char ip_src[MAX_STR_LEN];
char ip_dst[MAX_STR_LEN]; /* destination ip */
struct packet pkts[MAX_PACKETS]; /* Internal representation of packets */
int pkt_c; /* Packet count (how many packets we have) */
struct node hops[MAX_HOPS];
int hops_c; /* number of intermediate hosts */
struct protocol protocols[MAX_HOPS];
int prot_c;
struct fragment fragments[MAX_PACKETS];
int frag_c;
struct rtt rtts[MAX_HOPS];
int rtt_c;
};
struct packet initialize_packet(int);
void print_results(struct result);
void find_hops(struct result*);
void find_dest(struct result*);
void find_protocols(struct result*);
void find_fragments(struct result*);
void find_rtts(struct result*);
#endif