Network Byte Order Integer Class

Network Byte Order is a standard for the transmission of integers over a network as a series of bytes. In network byteorder, integers are ordered in an intuitive way, with the most significant bytes first (big endian). This is in contrast to the standard used by many modern processors, in which the bytes are transmitted in the opposite order (little endian).

For example, 12345 is 11000000111001 in binary. If stored as a 4-byte integer, this would be
     A          B          C          D
+----------+----------+----------+----------+
| 00000000 | 00000000 | 00110000 | 00111001 |
+----------+----------+----------+----------+
In a big endian system, the bytes would be transmitted in the order A B C D (big end first), while in a little endian system, they would be transmitted in order D C B A (little end first).

The NBO class is a ADT representing an unsigned 4-byte integer as 4 bytes in network byte order. This class has the advantage over traditional unsigned ints that it is read and written to a file in a consistant format on both big endian and little endian machines. It has the disadvantage that NBOs are much slower than unsigned ints.

It is recommended that you use NBOs in your project because it is required that integers on the simulated disk be stored in network byte order. This is to permit output to be checked with the unix diff command.

NBO.h (txt) - The NBO header file
NBO.cpp (txt) - The NBO source file
NBO_test.cpp (txt) - A simple program to test the NBO class
NBO_file_IO.cpp (txt) - An additional test program to demonstrate reading and writing NBOs

Test Results for NBO_test.cpp:
Return to CS330 Project homepage