0

I´m trying to create a Client in java to transfer files over UDP using a Go-back-N sliding window. I'm using a TftpPacket, but that's not relevant for the question. My problem its how am I able to make the acknowledge control. Example:

Have a file that is divided into 15 segments, window with length 10. So first it will send 10 segm, but package 2 its lost so the client sends 10 segm and the the server only acknowledged the first one, so client sends segm 11 and stops. After the timeout the client send again but the window this time will be defined from segm 2 to segm 11 (10 segm window) and so on.

My problem its that I'm not able to understand how to control the window so it blocks on segm 11 if the last ack received was 1 and resend the whole window after the timeout.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Vitor Mexia
  • 69
  • 2
  • 10

1 Answers1

0

I think you are thinking in a wrong way in terms of OOP. You should have a Window class where you can set its length as an attribute in the constructor and have two methods, one for reducing the remaining segments when the Sender class sends a packet, and one for extending the remaining segments when the Receiver sends an ackowledgment.

In your main class, you send packets, checking each time if you have space left in your window. Every time you send a packet, you call the method of the Window object that reduces its remainingSegments attribute. In case you receive an acknowledgment from the receiving class, you call the method of the Window object that extends its remainingSegments attribute.

interboy
  • 856
  • 1
  • 11
  • 25