# Important Formulas - Computer Networks
## Subnetting Formulas
Number of subnets = 2 raised to the power of n
where n = number of bits borrowed from host portion
Number of usable hosts per subnet = 2 raised to the power of h minus 2
where h = number of host bits remaining
Block size = 256 minus the value of subnet mask octet
Subnet address = IP address AND subnet mask (bitwise)
Broadcast address = subnet address OR inverse of subnet mask (bitwise)
First usable host = subnet address plus 1
Last usable host = broadcast address minus 1
## CIDR Prefix to Subnet Mask
Slash 8 = 255.0.0.0
Slash 16 = 255.255.0.0
Slash 24 = 255.255.255.0
Slash 25 = 255.255.255.128
Slash 26 = 255.255.255.192
Slash 27 = 255.255.255.224
Slash 28 = 255.255.255.240
Slash 29 = 255.255.255.248
Slash 30 = 255.255.255.252
## Usable Hosts Quick Reference
Slash 24 = 254 hosts
Slash 25 = 126 hosts
Slash 26 = 62 hosts
Slash 27 = 30 hosts
Slash 28 = 14 hosts
Slash 29 = 6 hosts
Slash 30 = 2 hosts
## Bandwidth and Performance Formulas
Transmission time = File size divided by bandwidth
Propagation delay = Distance divided by propagation speed
Total delay = Transmission time plus propagation delay
Throughput = Amount of data successfully transmitted divided by time
Efficiency of Stop-and-Wait = Transmission time divided by (transmission time plus 2 times propagation delay)
Bandwidth delay product = Bandwidth multiplied by round trip time
This gives the amount of data in transit in the network at any time
## CRC Calculation
Append r zeros to message where r is degree of generator polynomial
Divide augmented message by generator using modulo-2 division
Remainder is the CRC
Transmit original message plus CRC
## Hamming Code
Number of parity bits r needed for data bits d: r satisfies 2 raised to r is greater than or equal to d plus r plus 1
Parity bit positions are powers of 2: positions 1, 2, 4, 8, 16
## TCP Window and Throughput
Maximum throughput = Window size divided by round trip time
Bandwidth utilization = Throughput divided by link bandwidth times 100 percent
## Efficiency of Protocols
Stop and Wait efficiency = 1 divided by (1 plus 2a) where a = propagation delay divided by transmission time
Sliding Window efficiency = W divided by (1 plus 2a) when W is less than 1 plus 2a
where W is window size
## Binary Octet Values
Bit 8 = 128
Bit 7 = 64
Bit 6 = 32
Bit 5 = 16
Bit 4 = 8
Bit 3 = 4
Bit 2 = 2
Bit 1 = 1
Sum = 255 when all bits are 1
Sum = 0 when all bits are 0Back to Subject