Really Understand Binary by Rex A. Barzee

Really Understand Binary by Rex A. Barzee

Author:Rex A. Barzee [Barzee, Rex A.]
Language: eng
Format: azw3
Tags: COMPUTERS / Programming / General, MATHEMATICS / Number Systems
ISBN: 9780983384083
Publisher: Maia LLC
Published: 2014-10-09T16:00:00+00:00


Network Mask

A router is a computer networking device that routes (sends to another router) packets of data from a source host in its network to the router in the destination host’s network. An internet protocol (IP) network address, which is simply a large number, has two parts: a network prefix and a host number. The network prefix occupies the most significant bits of the address, and is the same for all hosts on the same network. Because a router receives all packets sent from hosts in its network but routes only those packets whose destination network is different from its network, a router must have a fast method to determine if a packet is destined for a host on its network or another network. To determine this, a router uses its own network prefix and the bitwise and operator.

Internet protocol version 4 (IPv4) addresses are written in dot-decimal notation which is a group of four bytes in decimal separated by periods. For example, 192.168.54.15 is an IPv4 address which can be converted to hexadecimal (c0a8030f) and binary (1100 0000 1010 1000 0000 0011 0000 1111).

The network prefix of a network is written as the first address of the network followed by a slash character (/) and the number of bits in the prefix. For example, 192.168.48.0/20 is the network prefix for the network starting at 192.168.48.0 and having a 20 bit network prefix. The corresponding network prefix mask is a 32‑bit number with the 20 most significant bits set to 1 and the remaining 12 bits cleared to 0: (1111 1111 1111 1111 1111 0000 0000 0000). From this mask it is easy to see how many unique addresses are in this network. The network mask has 12 zeros, so there are 212 = 4,096 unique addresses in this network. However, some of the addresses are reserved and cannot be assigned to a host.

When a router receives a packet, it quickly determines if it needs to route the packet or not by extracting the network prefix from the source address and then extracting the network prefix from the destination address and comparing the two network prefixes. If the two network prefixes are different, the router will route the packet. If the two prefixes are the same, the router will ignore the packet because it does not need to be routed to a different network. Extracting and comparing the network prefixes can be done with the code in the next example.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.