Revision cc96298a

View differences:

ml/ml.c
413 413

  
414 414
			sd_data_inf.remote_socketID = &(connectbuf[con_id]->external_socketID);
415 415
#ifdef FEC
416
			if(msg_type==17 && msg_len>1372){
416
			if(msg_type==17 && msg_len>connectbuf[con_id]->pmtusize){
417 417
			   //@add padding bits to msg!
418 418
			   int npaks=0;
419 419
			   int toffset=0;
420
			   int tpkt_len=1372;
421
			   int ipad = (1372-(msg_len%1372));
420
			   int tpkt_len=connectbuf[con_id]->pmtusize;
421
			   int ipad = (connectbuf[con_id]->pmtusize-(msg_len%(connectbuf[con_id]->pmtusize)));
422 422
			   Pmsg = (char*) malloc((msg_len + ipad)*sizeof ( char* ));
423 423
			    for(i=0; i<msg_len; i++){
424 424
				*(Pmsg+i)=*(((char *)msg)+i);
......
430 430
			    }
431 431
			    msg=Pmsg;
432 432
			    msg_len=(msg_len+ipad);
433
			    npaks=(int)(msg_len/1372);
433
			    npaks=(int)(msg_len/connectbuf[con_id]->pmtusize);
434 434
			    npaksX2=2*npaks; //2 times.
435 435
			    src = ( char ** ) malloc ( npaksX2 * sizeof ( char* ));
436 436
			    pkt = ( char ** ) malloc ( npaksX2 * sizeof ( char* ));
......
478 478
#endif
479 479
			iov[3].iov_len = pkt_len;
480 480
#ifdef FEC
481
			if(msg_type==17 && msg_len>1372 && lcnt<((msg_len*2)/1372)){ //&& lcnt<(msg_len/1372)
481
			if(msg_type==17 && msg_len>connectbuf[con_id]->pmtusize && lcnt<((msg_len*2)/connectbuf[con_id]->pmtusize)){ //&& lcnt<(msg_len/connectbuf[con_id]->pmtusize)
482 482
			      iov[3].iov_base = pkt[lcnt];
483 483
			      chk_msg_len=(msg_len*2); //half-rate.
484 484
			} else {
......
499 499
				mon_pkt_inf pkt_info;
500 500
				memset(h_pkt,0,MON_PKT_HEADER_SPACE);
501 501
				pkt_info.remote_socketID = &(connectbuf[con_id]->external_socketID);
502
				if(msg_type==17 && msg_len>1372 && lcnt<((msg_len*2)/1372)){
502
				if(msg_type==17 && msg_len>connectbuf[con_id]->pmtusize && lcnt<((msg_len*2)/connectbuf[con_id]->pmtusize)){
503 503
				    pkt_info.buffer = pkt[lcnt];
504 504
				    chk_msg_len=(msg_len*2);
505 505
				} else {
......
555 555
					//update
556 556
					offset += pkt_len;
557 557
#ifdef FEC
558
					if(msg_type==17 && msg_len>1372 && lcnt<((msg_len*2)/1372)){
558
					if(msg_type==17 && msg_len>connectbuf[con_id]->pmtusize && lcnt<((msg_len*2)/connectbuf[con_id]->pmtusize)){
559 559
					  lcnt++;
560 560
					}
561 561
#endif
......
566 566
			if (break2) break;
567 567
#ifdef FEC
568 568
		} while(offset != chk_msg_len && !truncable);
569
		if(msg_type==MSG_TYPE_CHUNK && msg_len>1372){ //free the pointers.
569
		if(msg_type==17 && msg_len>connectbuf[con_id]->pmtusize){ //free the pointers.
570 570
			free(Pmsg);
571 571
			free(src);
572 572
			for(i=0; i<npaksX2; i++) {
......
999 999
	debug("ML: received packet of size %d with rconID:%d lconID:%d type:%d offset:%d inlength: %d\n",bufsize,msg_h->remote_con_id,msg_h->local_con_id,msg_h->msg_type,msg_h->offset, msg_h->msg_length);
1000 1000

  
1001 1001
	int recv_id, free_recv_id = -1;
1002
	int pmtusize;
1002 1003

  
1003 1004
	if(connectbuf[msg_h->remote_con_id] == NULL) {
1004 1005
		debug("ML: Received a message not related to any opened connection!\n");
1005 1006
		return;
1006 1007
	}
1008
	pmtusize = connectbuf[msg_h->remote_con_id]->pmtusize;
1007 1009

  
1008 1010
#ifdef RTX
1009 1011
	counters.receivedDataPktCounter++;
......
1021 1023

  
1022 1024
#ifdef FEC
1023 1025
	// Consider only first k packets and decline the rest >k packets.
1024
	if((msg_h->msg_type==17) && ((msg_h->msg_length + msg_h->len_mon_data_hdr)>1372) && (chk_complete[msg_h->msg_seq_num]==1)){
1026
	if((msg_h->msg_type==17) && ((msg_h->msg_length + msg_h->len_mon_data_hdr)>pmtusize) && (chk_complete[msg_h->msg_seq_num]==1)){
1025 1027
	  return;
1026 1028
	}
1027 1029
#endif
......
1056 1058
		recvdatabuf[recv_id]->msgtype = msg_h->msg_type;
1057 1059

  
1058 1060
#ifdef FEC
1059
		if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>1372){
1061
		if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>pmtusize){
1060 1062
		  chk_complete[msg_h->msg_seq_num]=0;
1061 1063
		  recvdatabuf[recv_id]->nix=0;
1062
		  recvdatabuf[recv_id]->pix = ( int * ) malloc ( (recvdatabuf[recv_id]->bufsize/1372) * sizeof ( int ));
1063
		  recvdatabuf[recv_id]->pix_chk = ( int * ) malloc ( (recvdatabuf[recv_id]->bufsize/1372) * sizeof ( int ));
1064
		  for(i=0;i<(recvdatabuf[recv_id]->bufsize/1372);i++)
1064
		  recvdatabuf[recv_id]->pix = ( int * ) malloc ( (recvdatabuf[recv_id]->bufsize/pmtusize) * sizeof ( int ));
1065
		  recvdatabuf[recv_id]->pix_chk = ( int * ) malloc ( (recvdatabuf[recv_id]->bufsize/pmtusize) * sizeof ( int ));
1066
		  for(i=0;i<(recvdatabuf[recv_id]->bufsize/pmtusize);i++)
1065 1067
		      recvdatabuf[recv_id]->pix_chk[i] = 0;
1066 1068
		}
1067 1069
#endif
......
1092 1094

  
1093 1095
	// enter the data into the buffer
1094 1096
#ifdef FEC
1095
	if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>1372 && recvdatabuf[recv_id]->pix_chk[recvdatabuf[recv_id]->nix]==0)
1096
	  memcpy(recvdatabuf[recv_id]->recvbuf + msg_h->len_mon_data_hdr + (recvdatabuf[recv_id]->nix)*1372, msgbuf, bufsize);
1097
	if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>pmtusize && recvdatabuf[recv_id]->pix_chk[recvdatabuf[recv_id]->nix]==0)
1098
	  memcpy(recvdatabuf[recv_id]->recvbuf + msg_h->len_mon_data_hdr + (recvdatabuf[recv_id]->nix)*pmtusize, msgbuf, bufsize);
1097 1099
	else
1098 1100
	  memcpy(recvdatabuf[recv_id]->recvbuf + msg_h->len_mon_data_hdr + msg_h->offset, msgbuf, bufsize);
1099 1101
	//TODO very basic checkif all fragments arrived: has to be reviewed
......
1140 1142
	if(recvdatabuf[recv_id]->arrivedBytes == recvdatabuf[recv_id]->bufsize - recvdatabuf[recv_id]->monitoringDataHeaderLen) {
1141 1143
		recvdatabuf[recv_id]->status = COMPLETE; //buffer full -> msg completly arrived
1142 1144
#ifdef FEC
1143
		if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>1372){
1145
		if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>pmtusize){
1144 1146
		  chk_complete[msg_h->msg_seq_num]=1;
1145 1147
		  prev_sqnr=recvdatabuf[recv_id]->seqnr;
1146 1148
		  int npaks=0;
1147 1149
		  int toffset=20;
1148
		  int tpkt_len=1372;
1149
		  npaks=(int)(recvdatabuf[recv_id]->bufsize/1372);
1150
		  int tpkt_len=pmtusize;
1151
		  npaks=(int)(recvdatabuf[recv_id]->bufsize/pmtusize);
1150 1152
		  src = ( char ** )malloc ( npaks * sizeof ( char * ));
1151 1153
		  code = fec_new(npaks,256);
1152 1154
		  for(i=0; i<npaks; i++){
......
1160 1162
		      }
1161 1163
		      toffset += tpkt_len;
1162 1164
		  }
1163
		  recvdatabuf[recv_id]->pix[recvdatabuf[recv_id]->nix]=(int)(msg_h->offset/1372);
1165
		  recvdatabuf[recv_id]->pix[recvdatabuf[recv_id]->nix]=(int)(msg_h->offset/pmtusize);
1164 1166
		  fec_decode(code, src, recvdatabuf[recv_id]->pix, tpkt_len);
1165 1167
		  toffset=20;
1166 1168
		  for(i=0; i<npaks; i++){
......
1185 1187
	} else {
1186 1188
		recvdatabuf[recv_id]->status = ACTIVE;
1187 1189
#ifdef FEC
1188
		if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>1372 && recvdatabuf[recv_id]->pix_chk[recvdatabuf[recv_id]->nix]==0){
1189
		  recvdatabuf[recv_id]->pix[recvdatabuf[recv_id]->nix]=(int)(msg_h->offset/1372);
1190
		if(recvdatabuf[recv_id]->msgtype==17 && recvdatabuf[recv_id]->bufsize>pmtusize && recvdatabuf[recv_id]->pix_chk[recvdatabuf[recv_id]->nix]==0){
1191
		  recvdatabuf[recv_id]->pix[recvdatabuf[recv_id]->nix]=(int)(msg_h->offset/pmtusize);
1190 1192
		  recvdatabuf[recv_id]->pix_chk[recvdatabuf[recv_id]->nix]=1;
1191 1193
		  recvdatabuf[recv_id]->nix++;
1192 1194
		}

Also available in: Unified diff