程序代写代做 File stopandwait.c of cnet provides an implementation of the alternating bit protocol. The protocol provides bidirectional reliable data transfer between two hosts. So, one host can establish a reliable connection to another host. In more general situations, a host is required to establish multiple independent reliable connections to one, or more, other hosts. To facilitate supporting multiple simultaneous connections, the implementation needs to be revised so as to provide suitable encapsulation of the key parameters of a typical connection.

File stopandwait.c of cnet provides an implementation of the alternating bit protocol. The protocol provides bidirectional reliable data transfer between two hosts. So, one host can establish a reliable connection to another host. In more general situations, a host is required to establish multiple independent reliable connections to one, or more, other hosts. To facilitate supporting multiple simultaneous connections, the implementation needs to be revised so as to provide suitable encapsulation of the key parameters of a typical connection.
Your task in this part is to revise the implementation to achieve this goal (and other useful changes), as detailed below.
1. Call your developed protocol file lab2a.c. You may use stopandwait.c as a starting point.
2. In the revised protocol, frames do not have a kind field that is used to distinguish between data frames and ACK frames. Rather, each frame has two integers, denoted seq and ack, that are used as follows:
– If (seq = 1) the frame carries no data in the msg field. Else (if seq 0), the frame carries a message whose sequence number = seq.
– If (ack = 1) the frame carries no ACK. Else (if ack 0), the frame carries an ACK whose sequence number = ack.
3. Each frame contains the addresses of its source and destination hosts. (Nodes with user assigned addresses are used in Part 3).
4. Connection Encapsulation. The revised implementation has a C-struct type called CONN that encapsulates the important parameters of a typical connection. These parameters in- clude: the address of the other host of the connection, lasttimer, nextframetosend, ackexpected, frameexpected, and a copy of the last transmitted frame. You may include more parameters, as you see appropriate. Thus, using a declaration like “CONN conn[10];” the host can handle up to 10 independent connections.
5. The revised protocol should print the data exchanges over any possible connection using the following (approximate) format


DATA transmitted:(src= 10, dest= 20, seq= 0, ack= -1, msgLen= 2402)
DATA received [delivered]:(src= 20, dest= 10, seq= 0, ack= -1, msgLen= 1458)
ACK sent: (src= 10, dest= 20, seq= -1, ack= 0, msgLen= 0)
BAD frame received: checksums (stored= -33188, computed= 32348)

6. Test your program using only one connection between two adjacent hosts exchanging data packets in both directions over channels that can lose and/or corrupt frames.

Leave a Reply

Your email address will not be published. Required fields are marked *