src/mrt_ds.c
// send size bytes of data starting from buf
// all data packets have to be zero-terminated
// make sure that size <= MSS
send size bytes of data starting from buf
all data packets have to be zero-terminated
make sure that size <= MSS
send size bytes of data starting from buf all data packets have to be zero - terminated make sure that size < = MSS
void send_data_pkt(int sockfd, const struct sockaddr_in * addr, int seq, int rcvwnd, char * buf, int size) {
  mrt_packet * pkt = (mrt_packet *)malloc(sizeof(mrt_packet));
  memset(pkt, 0, sizeof(mrt_packet));
  memcpy(&pkt->data, buf, size);
  strcpy(pkt->header.chksum, get_md5(pkt->data));
  pkt->header.seq = seq;
  pkt->header.rcvwnd = rcvwnd;
  sendto(sockfd, (const char *)pkt, sizeof(mrt_header) + strlen(pkt->data) + 1,
              0, (const struct sockaddr *)addr, sizeof(struct sockaddr_in)); 
  free(pkt);
  return ;
}
void send_data_pkt ( int sockfd , const struct sockaddr_in * addr , int seq , int rcvwnd , char * buf , int size ) { mrt_packet * pkt = ( mrt_packet * ) malloc ( sizeof ( mrt_packet ) ) ; memset ( pkt , 0 , sizeof ( mrt_packet ) ) ; memcpy ( & pkt -> data , buf , size ) ; strcpy ( pkt -> header . chksum , get_md5 ( pkt -> data ) ) ; pkt -> header . seq = seq ; pkt -> header . rcvwnd = rcvwnd ; sendto ( sockfd , ( const char * ) pkt , sizeof ( mrt_header ) + strlen ( pkt -> data ) + 1 , 0 , ( const struct sockaddr * ) addr , sizeof ( struct sockaddr_in ) ) ; free ( pkt ) ; return ; }
send size bytes of data starting from buf
all data packets have to be zero-terminated
make sure that size <= MSS
send size bytes of data starting from buf all data packets have to be zero - terminated make sure that size < = MSS