#include "seg.h" //SRT process uses this function to send a segment and its destination node ID in a sendseg_arg_t structure to SNP process to send out. //Parameter network_conn is the TCP descriptor of the connection between the SRT process and the SNP process. //Return 1 if a sendseg_arg_t is succefully sent, otherwise return -1. int snp_sendseg(int network_conn, int dest_nodeID, seg_t* segPtr) { return 0; } //SRT process uses this function to receive a sendseg_arg_t structure which contains a segment and its src node ID from the SNP process. //Parameter network_conn is the TCP descriptor of the connection between the SRT process and the SNP process. //When a segment is received, use seglost to determine if the segment should be discarded, also check the checksum. //Return 1 if a sendseg_arg_t is succefully received, otherwise return -1. int snp_recvseg(int network_conn, int* src_nodeID, seg_t* segPtr) { return 0; } //SNP process uses this function to receive a sendseg_arg_t structure which contains a segment and its destination node ID from the SRT process. //Parameter tran_conn is the TCP descriptor of the connection between the SRT process and the SNP process. //Return 1 if a sendseg_arg_t is succefully received, otherwise return -1. int getsegToSend(int tran_conn, int* dest_nodeID, seg_t* segPtr) { return 0; } //SNP process uses this function to send a sendseg_arg_t structure which contains a segment and its src node ID to the SRT process. //Parameter tran_conn is the TCP descriptor of the connection between the SRT process and the SNP process. //Return 1 if a sendseg_arg_t is succefully sent, otherwise return -1. int forwardsegToSRT(int tran_conn, int src_nodeID, seg_t* segPtr) { return 0; } // for seglost(seg_t* segment): // a segment has PKT_LOST_RATE probability to be lost or invalid checksum // with PKT_LOST_RATE/2 probability, the segment is lost, this function returns 1 // If the segment is not lost, return 0. // Even the segment is not lost, the packet has PKT_LOST_RATE/2 probability to have invalid checksum // We flip a random bit in the segment to create invalid checksum int seglost(seg_t* segPtr) { return 0; } // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //This function calculates checksum over the given segment. //The checksum is calculated over the segment header and segment data. //You should first clear the checksum field in segment header to be 0. //If the data has odd number of octets, add an 0 octets to calculate checksum. //Use 1s complement for checksum calculation. unsigned short checksum(seg_t* segment) { return 0; } //Check the checksum in the segment, //return 1 if the checksum is valid, //return -1 if the checksum is invalid int checkchecksum(seg_t* segment) { return 0; }