Skip to content

Commit 7d68f5f

Browse files
committed
All giants except giant 1 work
1 parent 1b21644 commit 7d68f5f

File tree

7 files changed

+5
-2
lines changed

7 files changed

+5
-2
lines changed

go-back-n/gbn.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ ssize_t gbn_send(int sockfd, const void *buf, size_t len, int flags){
6767
alarm(1.5);
6868
reset_alrm=false;
6969
}
70-
71-
data_packet->checksum = checksum(data_packet, sizeof(*data_packet) / sizeof(uint16_t));
70+
if(state.seq_curr-1 == packet_num && len%DATALEN > 0){
71+
data_packet->checksum = checksum(data_packet, (len%DATALEN + sizeof(data_packet->type)+ sizeof(data_packet->seqnum)+ sizeof(data_packet->checksum) )/ sizeof(uint16_t));
72+
}else{
73+
data_packet->checksum = checksum(data_packet, sizeof(*data_packet) / sizeof(uint16_t));
74+
}
7275
printf("INFO: Checksum of packet: %d\n",data_packet->checksum);
7376

7477
if(state.seq_curr-1==packet_num){

go-back-n/gbn.o

120 Bytes
Binary file not shown.

go-back-n/ouput

Whitespace-only changes.

go-back-n/output

11 MB
Binary file not shown.

go-back-n/r.test

-2.91 MB
Binary file not shown.

go-back-n/receiver

4 KB
Binary file not shown.

go-back-n/sender

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)