-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_packet.h
27 lines (23 loc) · 904 Bytes
/
send_packet.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
#ifndef SEND_PACKET_H
#define SEND_PACKET_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/time.h>
#include <arpa/inet.h>
/* This function is used to set the probability (a value between 0 and 1) for
* dropping a packet in the send_packet function. You call set_loss_probability
* once in your program, and send_packet will drop packets after that.
*/
void set_loss_probability( float x );
/* This is a lossy replacement for the sendto function. It uses a random
* number generator to drop packets with the probability chosen with
* set_loss_probability. If it doesn't drop the packet, it calls sendto.
*/
ssize_t send_packet( int sock, const char* buffer, size_t size, int flags, const struct sockaddr* addr, socklen_t addrlen );
#endif /* SEND_PACKET_H */