Question: Using C + + , Write a program to ask user to enter 2 0 bytes of Hexadecimal number. - Your program should run multiple

Using C++,Write a program to ask user to enter 20 bytes of Hexadecimal number. - Your program should run multiple time.
- Your program should have error checking for non-hexadecimal number, illegal version, and illegal header size. Extract the input and display the following information in decimal:
1. Version
2. Header Length (how many bytes)
3. Total Length (how many bytes)
4. The size of Data (how many bytes)
5. Protocol
6. Source IP address
7. Destination IP address
For Example: An IP datagram has arrived with the following information in the header (in hexadecimal):
4500005400030000200600007C4E0302B40E0F02
The answer should be
Version: 4
Header Length: 20
Total Length: 84
The size of Data: 64
Protocol: 6
Source IP address: 124.78.3.2(7C 4E 0302)
Destination IP address: 180.14.15.2(B40E 0F 02)
45H1005400030000200600007C4E0302B40E0F02
The answer should be
Error: illegal digit for hexadecimal
3500005400030000200600007C4E0302B40E0F02
The answer should be
Error: Wrong version (should be 4 or 6)
4400005400030000200600007C4E0302B40E0F02
The answer should be
Error: Illegal header size

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!