6/1/2019
Posted by 
  1. Go Back N Protocol
  2. Sliding Window Protocol Program

Stop & wait protocol using sockets in java; 82. Java program for sliding window protocol. There are sometimes compatibility problems between Java and various browsers, operating systems or computers, and if not written correctly, it can be slow to load.

Permalink

Join GitHub today

GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.

Sign up
Branch:master
Find file Copy path
Cannot retrieve contributors at this time
importjavax.swing.Timer;
importjava.awt.event.*;
/********************************************************************
This class is used to implement the acknowledgement timer that
is used to decide if a separate acknowledgement frame should be
sent if there is no reverse traffic.
*******************************************************************/
publicclassAcknowledgementTimer
{
privateTimer timer;
privateAcknowledgementTimerEventGenerator ateg;//the class to generate the associated timeout events for the SWE.
publicAcknowledgementTimer ( intmsec, SWEswe )
{
ateg =newAcknowledgementTimerEventGenerator (swe);
this.timer =newTimer (msec, ateg);
}
publicvoidstartTimer ( )
{
if ( timer.isRunning() )
//restarting if it is already running.
timer.restart();
else
//if it is not running, starting it.
timer.start();
}
publicvoidstopTimer ( )
{
//stopping the timer
timer.stop();
}
}
  • Copy lines
  • Copy permalink

I am attempting to implement the following Basic Sliding Window algorithm in Java. I get the basic idea of it, but I am a bit confused by some the wording, specifically the sentence in bold:

A sliding window of fixed width w is moved across the file, and at every position k in the file, the fingerprint of its content is computed. Let k be a chunk boundary (i.e., Fk mod n = 0). Instead of taking the hash of the entire chunk, we choose the numerically smallest fingerprint of a sliding window within this chunk. Then we compute a hash of this randomly chosen window within the chunk. Intuitively, this approach would permit small edits within the chunks to have less impact on the similarity computation. This method produces a variable length document signature, where the number of fingerprints in the signature is proportional to the document length.

Sliding

Please see my code/results below. Am I understanding the basic idea of the algorithm? As per the text in bold, what does it mean to 'choose the numerically smallest fingerprint of a sliding window within its chunk'? I am currently just hashing the entire chunk.

code:

results:

littleKlittleK

3 Answers

Go Back N Protocol

The simple answer is NO per my understanding (I once studied sliding window algorithm years ago, so I just remember the principles, while cannot remember some details. Correct me if you have more insightful understanding).

Sliding Window Protocol Program

As the name of the algorithm 'Sliding Window', your window should be sliding not jumping as it says

in your quotes. That is to say the window slides one character each time.

Per my knowledge, the concept of chunks and windows should be distinguished. So should be fingerprint and hash, although they could be the same. Given it too expense to compute hash as fingerprint, I think Rabin fingerprint is a more proper choice. The chunk is a large block of text in the document and a window highlight a small portion in a chunk.IIRC, the sliding windows algorithm works like this:

  1. The text file is chunked at first;
  2. For each chunk, you slide the window (a 15-char block in your running case) and compute their fingerprint for each window of text;
  3. You now have the fingerprint of the chunk, whose length is proportional to the length of chunk.

The next is how you use the fingerprint to compute the similarity between different documents, which is out of my knowledge. Could you please give us the pointer to the article you referred in the OP. As an exchange, I recommend you this paper, which introduce a variance of sliding window algorithm to compute document similarity.

Another application you can refer to is rsync, which is a data synchronisation tool with block-level (corresponding to your chunk) deduplication. See this short article for how it works.

Summer_More_More_TeaSummer_More_More_Tea

That is not a sliding window. All you have done is break up the input into disjoint chunks. An example of a sliding window would be

Jim GarrisonJim Garrison

this program may help you. and please try to make more efficent

umang shuklaumang shukla

Not the answer you're looking for? Browse other questions tagged javaalgorithm or ask your own question.

Omron Plc Cx Programmer Software Crack