stop-and-wait-send( input-data )
{
seqno ++; // use next sequence number
msg.seqno = seqno; // label message with the seqno
msg.data = input-data // put inpute data inside msg
send msg; // send message to receive (use sendto( ) !)
ack_recv = false;
while ( ! ack_recv )
{
wait for acknowledgement;
if ( timeout while waiting for ACK )
{
send msg (again); // retransmit message
}
else
{
if ( ACK.seqno = seqno )
ack_recv = true;
}
}
}
|
|
|
Most UNIX systems nowadays provide both system calls.