Data travels over a network in the form of packets and packets are composed of bytes. Assuming that size of each packet is 8 bytes. For example, if data has 3 packets and starting byte number of packet 1 is 800 than packet 2 will have starting byte number 808 and packet 3 will have starting byte number 816. All the packet numbers have difference of 8, since each packet is 8 bytes. Write C++ functions to handle the following scenario. You are supposed to input number of packets data is divided into (i.e. number packets data has). Declare an array for storing starting byte number of each packet. Input in array the starting byte numbers of each packet in data. After input display one of the following messages. No packet is loss. All received but are not in order. Data corrupted. For example: If data is divided into 4 packets. No packet is loss All received but are not in order. Data corrupted. 812 820 828 836 By looking at above data we can say all the packets for data is in order and no packet is loss. As each cell has the value that has difference of 8 with other cell and are in order 820 812 828 836 By looking at above data we can say all packets are received but the packet number 812 and 820 are not in order. 812 824 836 828 As each packet consist of 8 byte, there must be difference of 8 in packet number we can see difference between 812 and 824 is of 12 it means data is corrupted. Note: User can enter any number for packets data is divided into, and any data in array. Assuming that minimum value is for the starting packet number.
Q.No.9.
Data travels over a network in the form of packets and packets are composed of bytes. Assuming that size of each packet is 8 bytes. For example, if data has 3 packets and starting byte number of packet 1 is 800 than packet 2 will have starting byte number 808 and packet 3 will have starting byte number 816. All the packet numbers have difference of 8, since each packet is 8 bytes.
Write C++ functions to handle the following scenario. You are supposed to input number of packets data is divided into (i.e. number packets data has). Declare an array for storing starting byte number of each packet. Input in array the starting byte numbers of each packet in data. After input display one of the following messages.
- No packet is loss.
- All received but are not in order.
- Data corrupted.
For example:
If data is divided into 4 packets.
No packet is loss |
All received but are not in order.
|
Data corrupted.
|
||||||||||||
By looking at above data we can say all the packets for data is in order and no packet is loss. As each cell has the value that has difference of 8 with other cell and are in order |
By looking at above data we can say all packets are received but the packet number 812 and 820 are not in order.
|
As each packet consist of 8 byte, there must be difference of 8 in packet number we can see difference between 812 and 824 is of 12 it means data is corrupted.
|
Note: User can enter any number for packets data is divided into, and any data in array. Assuming that minimum value is for the starting packet number.
Step by step
Solved in 3 steps with 2 images