Commit 7099fa3f authored by Junxing Zhang's avatar Junxing Zhang

add stub.h with the delay list type declaration.

parent d8f8f9b4
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef _STUB_H
#define _STUB_H
......@@ -50,64 +45,60 @@ extern "C"
#define SNIFF_WINSIZE 131071 //from min(net.core.rmem_max, max(net.ipv4.tcp_rmem)) on Plab linux
#define SNIFF_TIMEOUT QUANTA/10 //in msec
//magic numbers
#define CODE_BANDWIDTH 0x00000001
#define CODE_DELAY 0x00000002
#define CODE_LOSS 0x00000003
enum { FAILED_LOOKUP = -1 };
// The int is the index of the connection.
typedef void (*handle_index)(int);
// The first int is the socket of the monitor.
// The second int is the index of the connection.
// This returns 1 for success and 0 for failure.
typedef int (*send_to_monitor)(int, int);
struct connection {
#define CODE_BANDWIDTH 0x00000001
#define CODE_DELAY 0x00000002
#define CODE_LOSS 0x00000003
#define CODE_LIST_SIZE 0x00000004 //indicates the start and size of a list of measurements
#define CODE_LIST_DELAY 0x00000005 //a list member that has a delay value
typedef struct {
short valid;
int sockfd;
unsigned long ip;
unsigned short stub_port;
unsigned short source_port;
unsigned short dest_port;
time_t last_usetime; //last monitor access time
int pending; // How many bytes are pending to this peer?
};
typedef struct connection connection;
struct sniff_record {
} connection;
typedef struct {
struct timeval captime;
unsigned long seq_start;
unsigned long seq_end;
};
typedef struct sniff_record sniff_record;
struct sniff_path {
} sniff_record;
typedef struct {
sniff_record records[SNIFF_WINSIZE];
int start; //circular buffer pointers
int end;
};
typedef struct sniff_path sniff_path;
struct loss_record {
} sniff_path;
typedef struct {
unsigned int loss_counter; //in terms of packet
unsigned int total_counter;
};
typedef struct loss_record loss_record;
} loss_record;
typedef struct delay_sample {
struct delay_sample *next;
unsigned long value;
struct timeval time;
} delay_sample;
typedef struct {
delay_sample *head;
delay_sample *tail;
int sample_number;
} delay_record;
extern short flag_debug;
extern int pcapfd;
extern int maxfd;
extern char sniff_interface[128];
extern connection snddb[CONCURRENT_SENDERS];
extern connection rcvdb[CONCURRENT_RECEIVERS];
extern sniff_path sniff_rcvdb[CONCURRENT_RECEIVERS];
extern unsigned long delays[CONCURRENT_RECEIVERS]; //delay is calculated at the sender side
extern unsigned long last_delays[CONCURRENT_RECEIVERS];
extern loss_record loss_records[CONCURRENT_RECEIVERS]; //loss is calculated at the sender side
extern unsigned long last_loss_rates[CONCURRENT_RECEIVERS]; //loss per billion
extern delay_record delay_records[CONCURRENT_RECEIVERS]; //delay is calculated at the sender side
extern int search_rcvdb(unsigned long indexip);
extern void sniff(void);
extern void init_pcap(int to_ms);
void clean_exit(int);
extern void append_delay_sample(int path_id, long sample_value);
typedef struct
{
......@@ -125,84 +116,14 @@ extern ThroughputAckState throughput[CONCURRENT_RECEIVERS];
// throughputTick() call.
extern unsigned int throughputTick(ThroughputAckState * state);
extern void throughputInit(ThroughputAckState * state, unsigned int sequence);
extern unsigned int bytesThisTick(ThroughputAckState * state);
// Add a potential sender to the pool.
void add_empty_sender(int index);
// Initialize a receiver or sender connection.
void init_connection(struct connection * conn);
// Run function on the index of every valid sender that is readable.
void for_each_readable_sender(handle_index function, fd_set * read_fds_copy);
// Try to find the sender by the IP address and the source port of the
// actual connection being created by the seinding peer. If there is a
// sender, the socket is closed and replaced with the sockfd
// argument. If the sender cannot be found, create a new sender based
// on the sockfd argument.
// Returns FAILED_LOOKUP if the sender cannot be found and there are
// no empty slots.
int replace_sender_by_stub_port(unsigned long ip, unsigned short stub_port,
int sockfd, fd_set * read_fds);
// Remove the index from the database, invalidating it.
void remove_sender_index(int index, fd_set * read_fds);
// Add a potential receiver to the pool.
void add_empty_receiver(int index);
// Run function on the index of each writable receiver which has some
// bytes pending.
void for_each_pending(handle_index function, fd_set * write_fds_copy);
// Run function on each index which will send an update to the
// monitor. Returns 1 for success and 0 for failure.
int for_each_to_monitor(send_to_monitor function, int monitor);
// Find the index of the receiver based on the IP address of the
// receiver, and the source and destination ports of the Emulab
// connection.
// Returns FAILED_LOOKUP on failure or the index of the receiver.
int find_by_address(unsigned long ip, unsigned short source_port,
unsigned short dest_port);
// Find the index of the receiver based on the above criteria. If this
// fails, create a new connection to the IP address.
// Returns FAILED_LOOKUP on failure or the index of the receiver.
// Failure happens when the receiver is not already in the database
// and there are no more empty slots in the database.
int insert_by_address(unsigned long ip, unsigned short source_port,
unsigned short dest_port);
#endif
// Reconnect to a receiver. Resets the socket, the stub_port, and the
// sniff records.
void reconnect_receiver(int index);
// Reset a receiver to point to the ip source_port and dest_port
// specified. Note that this does not change the socket or stub_port
// at all (call reconnect for that). Nor does it change the sniff records.
void reset_receive_records(int index, unsigned long ip,
unsigned short source_port,
unsigned short dest_port);
// Find the index of the receiver based on the IP address and the
// source port number of the stub connection.
// Returns FAILED_LOOKUP on failure.
int find_by_stub_port(unsigned long ip, unsigned short stub_port);
// Put the index into the pending category.
void set_pending(int index, fd_set * write_fds);
// Remove the index from the pending category.
void clear_pending(int index, fd_set * write_fds);
// Remove a receiver from the database, invalidating it.
void remove_index(int index, fd_set * write_fds);
#endif
#ifdef __cplusplus
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment