PROB2: IP ADDRESS ANALYSIS

Version 4 of the Internet Protocol (IP) defines class A, class B, and class C addresses. The following table shows an example of each of the three classes of addresses. In the familiar "dotted decimal" notation, each of the four numerical fields of the address is a non-negative integer not exceeding 255. In the binary form, each field of the address is expressed in base 2 as an 8-bit "octet". For example, the number 200, written as a sum of powers of 2, equals 128+64+8 = 2^7 + 2^6 + 2^3 = 11001000 binary.

Definitions:

Components of a Class A address:

The leftmost bit is used only to identify the type of address, therefore it is not part of the actual address. The remaining bits of the leftmost field (in the above example, 1000000) constitute the network prefix (which identifies a particular subnet within the Internet). The remaining fields (11001000.10000000.00000011) are concatenated to form the host suffix (which identifies a particular computer within a subnet).

Therefore, in the above example,

Components of a Class B address:

The leftmost two bits are used only to identify the type of address, therefore they are not part of the actual address. The remaining bits of the leftmost field (in the above example, 100000), concatenated with the second-leftmost field (11001000) constitute the network prefix. The remaining fields (10000000.00000011) are concatenated to form the host suffix.

Therefore, in the above example,

Components of a Class C address:

The leftmost three bits are used only to identify the type of address, therefore they are not part of the actual address. The remaining bits of the leftmost field (in the above example, 01010), concatenated with the second- and third-leftmost fields (11001000.10000000) constitute the network prefix. The remaining field (00000011) forms the host suffix.

Therefore, in the above example,

INPUT: prob2.dat

One or more IP-addresses in dotted decimal form, for example,

OUTPUT: prob2.out

Each line of input will give rise to one line of output, containing the network prefix and host suffix, in the format illustrated by the following example (which comes from the above input example): Note, in particular, that each numerical quantity is right-justified in a field of width 9 following the equals sign. Each equals sign is also preceded by one blank space, and the word "suffix" is preceded by two blank spaces.