Implementing stop and wait protocol