Chapter 7: Problem 5
Use XDR and htonl to encode a 1000 -element array of integers. Measure and compare the performance of each. How do these compare to a simple loop that reads and writes a 1000-element array of integers? Perform the experiment on a computer for which the native byte order is the same as the network byte order, as well as on a computer for which the native byte order and the network byte order are different.
Short Answer
Step by step solution
- Understand XDR and htonl
- Create a 1000-element array of integers
- Measure performance using XDR
- Measure performance using htonl
- Measure performance using simple loop
- Compare performances
- Test on different byte orders
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
XDR
Byte Order
htonl
Performance Measurement
- With XDR, measure the time for the entire serialization process.
- With `htonl`, measure the time to loop through the array and convert each element.
- For a simple loop, measure the time to read and write the array without any conversion.