Need an explanation of sliding window for networking

  • Thread starter serp777
  • Start date
  • #1
117
6
So I have a school project that requires me to use a sliding window in order to transmit a file to a server, but I'm having trouble understanding how sliding window works.

I don't really understand how rejects are done and how the program knows to send a new packet and then move onto the next window. Can someone explain it to me please? I've tried googling it several times but I just can't seem to grasp it entirely. Thanks for your help.
 

Answers and Replies

  • #2
196
42
Worst wikipedia article ever. Read this:
http://searchnetworking.techtarget.com/definition/sliding-windows
Basically it seems tcp has a built in buffer, so a reciever can read ahead of whatever application is reading it. Since tcp sends "confirmations" of transmissions recieved, it can get better performance by asking for more chunks of data at a time, or increasing the size of the "window.
 
Last edited:
  • #3
12,525
6,317
TCP will also use hash codes to verify that the data got sent correctly. As an example, if you sent the string hello world then a hash code of the string as well as its length would be sent. The receiver would rehash the data and if the new hash doesn't match the old it will request a retransmission of the block.
 
  • #4
Svein
Science Advisor
Insights Author
2,129
687
There are several ways of sending data and confirming that the data has been received (not received correctly, that is another theme).
  1. Every transfer chops the data into smaller chunks, called "packets" or "frames".
  2. There is a finite probability that a packet is lost in transmission. If so, it needs to be retransmitted.
  3. The simplest way is to send one packet and require a receipt (an "acknowledge") for that packet before the next packet is sent. If no acknowledge is received inside a specific time limit, the packet is retransmitted.
  4. In order to ensure that the retransmitted packet is not confused with the next packet (the packet may have been received, but the acknowledge may have been lost), all packets are identified with a packet number.
  5. If few packets are lost, waiting for an acknowledge after every packet wastes time and bandwidth. You may then decide to send a number of packets before requiring an acknowledge. This is the basic "sliding window" principle.
  • The number of packets sent before an acknowledge is required is called the "window".
  • The window size must be negotiated between the sender and the receiver before starting the transfer
  • After transmitting the number of packets that the window size specifies, the sender stops and waits for an acknowledge.
  • The acknowledge from the receiver contains the packet number of the next expected packet (or the last received packet, it depends on the protocol)
  • If no acknowledge if forthcoming, the sender usually sends a control packet requesting an acknowledge.
Different protocols use slightly different variations here. A special case is TCP, which dynamically adjusts the size of the window depending on whether packets are lost or not.

Note: This is just a short summary of the subject!
 
  • #5
chiro
Science Advisor
4,790
132
Hey serp777.

What network protocol are you thinking of using and what network library are you thinking of using?
 

Related Threads on Need an explanation of sliding window for networking

  • Last Post
Replies
2
Views
2K
Replies
2
Views
3K
Replies
2
Views
2K
  • Last Post
Replies
2
Views
2K
Replies
1
Views
4K
  • Last Post
Replies
3
Views
2K
Replies
19
Views
795
  • Last Post
Replies
3
Views
3K
  • Last Post
Replies
5
Views
2K
Top