finished TCP algorithm: put it altogether