//FILE: network/network.h // //Description: this file defines the data structures and functions for SNP process // //Date: April 29,2008 #ifndef NETWORK_H #define NETWORK_H //This function is used to for the SNP process to connect to the local ON process on port OVERLAY_PORT. //TCP descriptor is returned if success, otherwise return -1. int connectToOverlay(); //This thread sends out route update packets every ROUTEUPDATE_INTERVAL time //The route update packet contains this node's distance vector. //Broadcasting is done by set the dest_nodeID in packet header as BROADCAST_NODEID //and use overlay_sendpkt() to send the packet out using BROADCAST_NODEID address. void* routeupdate_daemon(void* arg); //This thread handles incoming packets from the ON process. //It receives packets from the ON process by calling overlay_recvpkt(). //If the packet is a SNP packet and the destination node is this node, forward the packet to the SRT process. //If the packet is a SNP packet and the destination node is not this node, forward the packet to the next hop according to the routing table. //If this packet is an Route Update packet, update the distance vector table and the routing table. void* pkthandler(void* arg); //This function stops the SNP process. //Tt closes all the connections and frees all the dynamically allocated memory. //Tt is called when the SNP process receives a signal SIGINT. void network_stop(); //This function opens a port on NETWORK_PORT and waits for the TCP connection from local SRT process. //After the local SRT process is connected, this function keeps receiving sendseg_arg_ts which contains the segments and their destination node addresses from the SRT process. The received segments are then encapsulated into packets (one segment in one packet), and sent to the next hop using overlay_sendpkt. The next hop is retrieved from routing table. //When a local SRT process is disconnected, this function waits for the next SRT process to connect. void waitTranport(); #endif