-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmutils.h
59 lines (48 loc) · 1.56 KB
/
mutils.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
////////////////////////////////////////////////////////////////////////////////
//
// James D. Browne
// Eric
// Distributed Assignment 2
//
// mutils.h
// Header file for functions required by mcast.c
// Date: 2016/10/10
//
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <netdb.h>
#include <errno.h>
#define PORT 11011
#define MAX_MESS_LEN 1400
//header_t holds all header information based on design document
typedef struct __attribute__((packed)) {
int size;
int type;
int id;
} header_t;
//desc_t is the combined header and header and data. This is our packet
//structure.
typedef struct __attribute__((packed)) {
header_t header;
char p_data[MAX_MESS_LEN]; //holds the data
} desc_t;
//send a unicast packet. Takes a packet, a socket, and destination address.
void tx_desc(desc_t* desc, int sr, int addr);
// receive a packet. returns the number of bytes in packet and sets desc to
// received packet. Takes a pointer to a packet to modify and a socket.
int rx_desc_probe(desc_t* desc, int sr);
//process the cli
void get_cli(long *num_packets, int *machine_index, int *num_machines, int *loss_rate, char *argv[], int argc);
////////////////////////////////////////////////////////////////////////////////
//
// Revsion History
//
//
////////////////////////////////////////////////////////////////////////////////