OSI and TCP/IP models

OSIFive-layerTCP/IP
APDUApplicationApplicationSoftware
PPDUPresentation
SPDUSession
TPDUTransport
(תעבורה, תובלה)
Hardware/Software
(Network) PacketNetworkInternet (or Network)Hardware
FrameData Link
(קו, ערוץ)
Link (or Network Access)
(קשר, ערוץ)
BitPhysical
  • protocol data unit (PDU)

    • “The combination of data from the next higher layer and control information” 1
    • “Another name for a packet or frame”. 2
    • “A PDU at layer is a message sent between protocols at layer . It consists of layer header information and an encapsulated message from layer , which is called both the layer SDU and the layer PDU”. 3
  • service data unit (SDU)

  • (packet)

    • (1) a generic term used to describe unit of data at all levels of the protocol stack. (RFC 1594)
    • (2) a PDU in the Internet (Network) layer
  • (datagram)

    • a synonym with packet
    • connectionless communication, packet-switched network
    • ”A self-contained, independent entity of data carrying sufficient information to be routed from the source to the destination computer without reliance on earlier exchanges between this source and destination computer and the transporting network”. (RFC 1594)
  • Best-effort service

  • circuit switching and packet switching

  • Connection-oriented and Connectionless (service/protocol/communication)

    • Connectionless-mode Network Service (CLNS) (or simply Connectionless Network Service)

Transport layer

  • Transport PDUs (TPDU) are typically called segments 1
    • UDP datagram
    • TCP segment maximum segment size

Internet layer

  • IP supports fragmentation and reassembly.
  • IP datagram = network packet = IP packet

IP Datagram Format

  • (1st word)
    • The “simple” model of best-effort datagram delivery has subtle features.
    • Version field: Current version, IPv4 (version 4).
    • HLen field: header length in (32-bit) words. Typically 5 (words (20 bytes). when no options)
    • TOS (Type of Service)
    • Total Length: 16 bits, length (in bytes) of datagram, including header.
      • theoretical Maximum size of IP datagram: 65,535 bytes.
      • (note: physical network may not support such long packets.)
  • (2nd word)
    • Identification: to identify fragments of a datagram.
    • Flags: (3 bits)
      • (reserved): zero.
      • More Fragments (MF) flag: 1 if more fragments follow.
      • Don’t Fragment (DF) flag: 1 if fragmentation not allowed.
    • Fragment Offset (13 bits):
      • in units of 8-bytes.
      • indicates where in datagram this fragment belongs.
  • (3rd word):
    • TTL: hop count, decremented by 1 per hop. default: 64.
    • Protocol number:
      • Acts as demultiplexing key.
      • Identifies higher-level protocol to pass packet to.
      • Common values:
      • TCP (6)
      • UDP (17)
      • Others in protocol graph above IP
    • Checksum:
      • Calculated using entire header as sequence of 16-bit words.
      • Uses ones’ complement arithmetic.
      • Ones’ complement of sum is checksum.
      • Detects corrupted header bits.
      • Not as strong as CRC, but easier to calculate in software.

The protocol number is the glue that binds the network and transport layers together, whereas the port number is the glue that binds the transport and application layers together. We’ll see in Chapter 6 that the link-layer frame also has a special field that binds the link layer to the network layer. — Kurose, J., & Ross, K. (2025). Computer Networking a Top-Down approach. Pearson.

fragmentation and reassembly

  • fragmentation (פיצול, פרגמנטציה)

  • fragment (רסיס)

  • reassembly (הרכבה)

  • The maximum transmission unit (MTU) of a network is the size of the largest IP datagram that the network can transmit in a single frame.

    • The size of the largest packet that can be sent over a physical network.
  • Maximum Transmission Unit (MTU)

  • Path MTU

  • Path MTU Discovery (PMTUD)

IP address

  • IPv4 is limit to adresses

  • Network address translation (NAT)

Classful network

ClassMSBNetwork prefix length
(bits)
Host identifier length
(bits)
Address range
A08240.0.0.0–127.255.255.255
B101616128.0.0.0–191.255.255.255
C110248192.0.0.0–223.255.255.255
D (multicast)1110224.0.0.0–239.255.255.255
E (reserved)1111240.0.0.0–255.255.255.255

Classless Inter-Domain Routing (CIDR)

#run
INPUT = '194.25.0.0/21'
 
ip_str, p_len_str = INPUT.split('/')
p_len = int(p_len_str)
h_bits = 32 - p_len
 
ip_parts = [int(p) for p in ip_str.split('.')]
ip_int = (ip_parts[0] << 24) | \
         (ip_parts[1] << 16) | \
         (ip_parts[2] << 8) | \
         ip_parts[3]
 
total_ips = 1 << h_bits 
usable_ips = total_ips - 2
 
mask_int = (0xFFFFFFFF << h_bits) & 0xFFFFFFFF
net_int = ip_int & mask_int
 
host_bits_mask = total_ips - 1 
bcast_int = net_int | host_bits_mask
 
first_host_int = net_int + 1
last_host_int = bcast_int - 1
 
def int_to_ip(ip_val):
    return f"{ip_val >> 24 & 0xFF}.{ip_val >> 16 & 0xFF}.{ip_val >> 8 & 0xFF}.{ip_val & 0xFF}"
 
binary_mask_full = f"{mask_int:032b}"
binary_mask_dotted = f"{binary_mask_full[:8]}.{binary_mask_full[8:16]}.{binary_mask_full[16:24]}.{binary_mask_full[24:]}"
 
def dot_to_binary_ip(ip_str):
    parts = [int(p) for p in ip_str.split('.')]
    return '.'.join(f"{part:08b}" for part in parts)
 
res = {
    "INPUT": INPUT,
    "-------": "-------",
    "IP Address": f"{dot_to_binary_ip(ip_str)} = {ip_str}",
    f"Subnet Mask /{p_len}": f"{binary_mask_dotted} = {int_to_ip(mask_int)}",
    "Network": f"{dot_to_binary_ip(int_to_ip(net_int))} = {int_to_ip(net_int)} \t (" +
             ("Class A" if ip_parts[0] < 128 else
              "Class B" if ip_parts[0] < 192 else
              "Class C" if ip_parts[0] < 224 else
              "Class D" if ip_parts[0] < 240 else
              "Class E") + ")",
    "Broadcast": f"{dot_to_binary_ip(int_to_ip(bcast_int))} = {int_to_ip(bcast_int)}",
    "Host Bits": f"32 - {p_len} = {h_bits}",
    "#IPs": f"2^{h_bits} = {total_ips}",
    "#Hosts": f"{total_ips} - 2 = {usable_ips}",
    "Host Range:": "",
    "   Min Host": f"{dot_to_binary_ip(int_to_ip(first_host_int))} = {int_to_ip(first_host_int)}" if usable_ips > 0 else "N/A",
    "   Max Host": f"{dot_to_binary_ip(int_to_ip(last_host_int))} = {int_to_ip(last_host_int)}" if usable_ips > 0 else "N/A"
}
 
for key, value in res.items():
    print(f"{key:{max(len(key) for key in res.keys())}}\t{value}")

Address Resolution Protocol (ARP)

Dynamic Host Configuration Protocol (DHCP)

  • DORA
    • Discover
    • Offer
    • Request
    • ACK

DHCP Relay

Internet Control Message Protocol (ICMP)

  • Defines a collection of error messages that are sent back to the source host whenever a router or host is unable to process an IP datagram successfully • Destination host unreachable due to link /node failure • Reassembly process failed • TTL had reached 0 • IP header checksum failed ICMP-Redirect

ICMP-Redirect

virtual networks

  • virtual private network (VPN)
  • virutal circuit
  • tunnels

Footnotes

  1. Stallings, W. (2013). Data and computer communications. 2

  2. Peterson, L. L., & Davie, B. (2020). Computer networks: A Systems Approach. Morgan Kaufmann Publishers.

  3. Kozierok, C. M. (2005). The TCP/IP guide: A Comprehensive, Illustrated Internet Protocols Reference. No Starch Press.