Network 2

Network 2: Fundamentals of computer networks

Transmission Control Protocol / Internet Protocol (TCP/IP) Protocol Suite / DoD Model

  • Is a protocol suite: set of protocols organised in different layers
  • Each upper-level protocol is supported by services provided by 1 or more lower-level protocols
  • Developed prior to OSI model: layers in both do not match
  • Developed using Department of Defense (DoD) reference model

Layering Principle

  • Layered protocols are designed so that layer n at the destination receives exactly the same object sent by layer n at the source

Benefits of Layering

  • Modularity
  • Each layer focus on a specific function (e.g. routing, encryption, data formatting)
  • Makes system easier to design, understand, troubleshoot
  • Interoperability
  • Standardises layer functions and interfaces
  • ⇒ Devices and software from different vendors can work together as long as they follow the same protocols for each layer
  • Flexibility and Abstraction
  • Clearly defined interfaces ⇒ changes or improvements can be made in 1 layer without affecting other layers
  • E.g. upgrading a physical cable or switching encryption algorithms
  • Simplified troubleshooting
  • Network issues can be diagnosed layer by layer
  • E.g. if message received incorrectly, can check if problem lies in transmission, formatting, or routing
  • Standardization
  • OSI model provides a common language and framework for implementing networking protocols

TCP/IP Protocol Suite

  • Data Encapsulation
  • Physical layer
  • TCP / IP does not define any specific protocol for physical layer
  • Supports all standard and proprietary protocols
  • At this level, communication is between 2 nodes, either a computer or router
  • Unit of communication: a single bit
  • When connection is established between the 2 nodes, a stream of bits is flowing between them
  • Data link layer
  • TCP / IP does not define any specific protocol for data link layer
  • Supports all standard and proprietary protocols
  • At this level, communication is between 2 nodes
  • Unit of communication: a frame = a packet that encapsulates data received from network layer with an added header and a trailer (optional)
  • Layer 1 and 21
  • TCP / IP protocol suite designed to work over any underlying network infrastructure
  • Does not tie itself to specific hardware standard ⇒ TCP/IP can run over Ethernet, Wi-Fi, optical fiber, or even legacy systems (e.g. token ring)
  • ⇒ Makes it flexible, encouraging broad adoption across diff. types of networks
  • Network layer
  • Main purpose: select best path for data to travel through from source to destination (i.e. routing)
  • The leading protocol operating here: Internet Protocol (IP)
  • There is a group of supporting protocols that support IP in doing its job, e,g,
  • Internet Control Message Protocol (ICMP)
  • Address Resolution Protocol (ARP)
  • Reverse Address Resolution Protocol (RARP)
  • Transport layer
  • Similar purposes in TCP/IP model and in OSI model
  • Designed to give source and destination the ability to have end-to-end conversation
  • 2 defined protocols that can operate here: Transmission Control Protocol (TCP) and User Datagram Protocol (UDP)
  • Provide connection-oriented and connectionless communication
  • Application layer
  • Main duty: take data from applications and deliver it to transport layer and collect data from transport layer and deliver it to the correct applications
  • Contains a huge group of high-level protocols that cover a wide range of applications
  • Most common: Hyper Text Transfer Protocol (HTTP)
  • Others: File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP), Post Office Protocol 3 (POP3), Telnet, Domain Name Service (DNS)

Modes of Data Transfer (for network layer)

  • Circuit Switching
  • Connection-oriented: connection needs to be established before start of transmitting data from sender to receiver
  • Data moves across the same path through entire communication
  • E.g. Early telephone systems: path established between caller and callee
  • Never implemented at network layer
  • Packet Switching
  • Connection less
  • No connection established before start of transmission of data
  • Data fragmented into packets (smaller, more manageable chunks/units)
  • Each packet is then individually addressed and sent to its intended recipient
  • Each packet finds its own way to the receiver (i.e. can travel same or diff. path)
  • Each packet takes the best route available and travels independently to reach the destination device
  • Packets are assigned a sequential number for reassembly at destination
  • Receiving computer waits for all packets of the message and reassembles packets into original message before delivering message to upper level
  • Network layer in Internet is packet-switched network
  • Routing = process of selecting best path for a packet to reach its destination
  • At network layer, IP responsible for sending packets from Host A to Host B, possibly via 1 or more routers
  • At Host A
  • Packetizing / Packet Creation: encapsulate data into an IP packet
  • Add IP header, including source IP address (Host A) and destination IP address (Host B)
  • Routing decision – consult routing table:
  • If Host B is on the same local network, it sends the packet directly ⇒ direct delivery
  • Otherwise (diff. network), forwards packet to default gateway (usually a router) ⇒ indirect delivery
  • Fragmentation
  • If size of data greater than limitation of the size of data to be carried in a frame
  • Size limit = Maximum Transmission Unit (MTU)
  • Packet will need to be fragmented into smaller units before being passed to data-link layer
  • At the router
  • Router receives packet from Host A
  • Validate (header) of each packet, ensure header not corrupted and packet is delivered to correct router
  • Checks destination IP address in packet
  • Consult routing table to determine the next hop to send the packet toward Host B and forward the packet to the next hop
  • Fragmentation of packet into smaller units before being passed to data-link layer
  • If multiple routers involved, will perform the same steps above
  • At Host B
  • Validate (header) of each packet, extract data from each fragment and store it
  • When all fragments have arrived, reassembly data and deliver data to upper layer (transport layer)
  • Network layer sets a reassembly timer
  • If timer expired, all data fragments are destroyed and an error message is sent and all datagram need to be resent
  • Disadvantages:
  • Packet loss: packet can be lost during transmission due to congestion and errors, which may result in incomplete data at the destination or requires re-transmission
  • Note: Packet switching is NOT the cause of packet loss
  • Packet switching does not cause error or corruption or data loss
  • Latency and Delay: As packets take different routes to reach the destination, they arrive at different times which might cause delays
  • Reassembly required at receiving device – packets may arrive out of order and must be correctly reassembled by the receiving device which requires more time and increases processing complexity
  • (X): Packet arriving out of order
  • This disadvantage is due to more time for reassembling and processing complexity

To research:

  • Differences between circuit switching and packet switching
  • Find out the advantages and disadvantages of circuit switching
  • Find out the advantages and disadvantages of packet switching
  • From chatgpt:
  • Circuit switching: No congestion or variation in packet arrival times
  • vs packet switching: No Guaranteed Bandwidth: Can lead to congestion, especially in high-load scenarios.
  • Packet switching: Efficient Resource Use: Bandwidth is shared across users; ideal for bursty traffic.
  • vs circuit switching: path is reserved even when no data is being sent (wasteful)
  • Advantages
Circuit SwitchingPacket Switching
Provides a consistent and reliable connection with a fixed bandwidthMore efficient use of network resources since packets can be routed based on current network load
Data arrives in order and does not need to be reassembledMore secure as it is harder to intercept data since different packets can take different paths to destination

[Network Layer] Protocol = set of rules, standards, or procedures that govern how data is transmitted, received, and interpreted between devices in a communication network

  • Are standardised to ensure compatibility and interoperability between diff. systems, devices, or software
  • Define how data is formatted and organised during transmission
  • Specifies how devices initiate, maintain, and terminate communication
  • Specify how errors are handled – detecting and correcting errors during transmission
ProtocolsPurpose
Internet Protocol version 4 (IPv4)Responsible for packetizing, forwarding, and delivery of a packet at network layer
Internet Control Message Protocol version 4 (ICMPv4)Supports the unreliable and connectionless IP by handling errors that may occur in network-layer delivery
Internet Group Management Protocol (IGMP)Helps IPv4 in multicasting
Address Resolution Protocol (ARP)Glues network and data-link layers in mapping network-layer addresses to link-layer addresses

[Network layer] IP = an unreliable connectionless protocol responsible for source-to-destination delivery

  • Protocol data unit (PDU) in Network layer: Packets
  • Provide best-effort delivery service
  • Packets can be corrupted, lost, arrive out of order, delayed, or create congestion for the network
  • Each packet handled independently, can follow a diff. route to the destination
  • 2
  • How packet is sent from host to source
  • Source and destination IP addresses are placed in IP header as packet moves down the TCP/IP stack
  • Network layer checks if destination is on the same local network or diff. (remote) network ⇒ decision is based on comparing destination IP address with the subnet mask to the source IP address with the subnet mask
  • If equal, means destination in same subnet ⇒ packet sent directly to destination host ⇒ direct delivery
  • If destination not in same subnet, packet sent via default gateway or router to reach correct network ⇒ indirect delivery
  • If size of packet greater than limitation of size of data to be carried in a frame (size limit = Maximum Transmission Unit [MTU]), packet will need to be fragmented to smaller units before being passed to data-link layer
  • MAC address of the next hop / destination device (host / router) is obtained before passing packet to data link layer
  • MAC address resolution – using destination IP address using ARP 3

[Network layer] Address Resolution Protocol (ARP)

  • Main purpose: map between logical protocol addresses (IP address) and hardware address (MAC address) → the 2 ways that a particular device can be identified on a LAN
  • Resolve IP address to hardware address
  • Steps to resolve hardware address
  • Look in ARP cache, if found – no future resolution – the ip-mac address is stored in the ARP cache for 2 mins (max 10 mins)
  • If not found, an ARP request broadcast is initiated – all nodes in local network received a copy of the ARP request
  • Destination node that has the IP address contained in the destination protocol address field responds with its hardware address

[Network layer] IP address

  • Every host on a TCP/IP network has a unique address to send data from host to host
  • Every packet contains addressing information in the header, and the IP address in the header is used to route packets

IPv4

  • A 32-bit address that uniquely identifies every host on a network
  • = logical address = software assigned address and non-permanent
  • Represented by a 32-bit unsigned binary value which is usually expressed in a dotted-decimal notation (more readable)
  • E.g. 172.16.254.1
  • IP addresses and DNS | Internet 101 | Computer Science | Khan Academy
  • 3 different notations:
  • Note: for e.g. 3 to binary, is 11; then add 0s in front of this to make it 8 digits
  • Note: for hexadecimal, split each binary into groups of 4 then convert
  • E.g. 1000 = 8; 0000 = 0 ⇒ 80
  • Divided into 2 parts
  • Prefix defines the network
  • Length is n bits, suffix length is (32-n) bits
  • Suffix defines the host (connection of a device to the Internet)

IPv6

  • 128-bits addresses ⇒ possible unique addresses
  • Written in hexadecimal form – 32 hex digits
  • 8 groups of 4 hex digits (16 bits)
  • E.g. EFDC:BA62:7654:3312:EFDC:BA72:7653:3210
  • IPv4 can be used within the IPv6 addressing scheme
  • Hexa-decimal IPv4 address is placed in the last 32 bits of the IPv6 address
  • E.g. IPv4 address - 192.168.2.100
    IPv6 address - ::C0A8:0264
  • Zero compression: to shorten IPv6 address many 0s
  • Can drop non-significant and leading 0s
  • E.g. 1080:0000:0000:0000:0008:0800:200C:417A
    ⇒ 1080:0:0:0:8:800:200C:417A
  • Can drop address with consecutive 0s and just push the colons together using double-colon notations → this can only be used once
  • I.e. no 2 double-colon notations in 1 address (can use for any occurrence)
  • E.g. 1080:0:0:0:8:800:200C:417A
  • ⇒ 1080::8:800:200C:417A
  • E.g. 1234:0:1:2:0:0:2:3
  • ⇒ 1234:0:1:2::2:3
  • E.g. 2002:0:0:db8:1:0:0:1a
  • ⇒ 2002::db8:1:0:0:1a OR 2002:0:0:db8:1::1a
  • E.g. 2001:0db8:0000:0000:0000:0000:0000:0001
  • ⇒ 2001:db8::1
# A possible pseudocode solution for zero compression:
DECLARE ipv6: String
DECLARE ipv6s: String
DECLARE leadingZero: Boolean
DECLARE cnt: Integer
CONSTANT IPV6LEN = 39
ipv6 ← ‘0001:0db8:0000:0000:0001:ff00:0042:8329’
ipv6s ← ” # shorten version of ipv6
leadingZero ← False # leading zero indicator
cnt ← 0 # character count
FOR i ← 1 to IPV6LEN
IF ipv6[i] = ‘0’ AND NOT leadingZero AND cnt < 3
cnt ← cnt + 1 # skip when is leadingZero and ‘0’
ELSE IF ipv6[i] = ’:’ # use : indicator to reset leadingzero and cnt
cnt ← 0
leadingZero ← False
ipv6s ← ipv6s + ipv6[i]
ELSE
leadingZero ← True
ipv6s ← ipv6s + ipv6[i]
END IF
END FOR
Note:
Use ’ ’ for character or string, e.g. ‘0’
Treat string as immutable (i.e. the statement S1[i] ← S2[j] is not valid)
“cnt < 3” condition ensures that max cnt is 3 after the “+1”
So that it only skips max 3 0s, then it falls under the ELSE statement and appends the last digit (even if 0) to ipv6s
Address TypeDescriptionStarts with
UnicastOne-to-one communicationDepends on allocation
MulticastOne-to-many communicationFF00::/8
AnycastOne-to-nearest (in routing terms)Assigned to multiple interfaces
Link-localFor local communication within a networkFE80::/10
Global unicastPublic IPv6 address2000::/3

IPv6 vs IPv4

FeatureIPv4IPv6
Address size32 bits (i.e. shorter)128 bits (i.e. longer)
Address formatDotted decimalHexadecimal colon-separated
No. of addresses~ ~
Header sizeVariableFixed, simplified
BroadcastSupportedReplaced by multicast

[Network Layer] IPv4

  • IPv4 – Classful Addressing Scheme
  • Fixed-length prefix: represents unique network address
  • Note: network address identifies the network segment NOT a device in the network
  • 3 fixed-length prefixes were designed to accommodate both small and large networks. n = 8, 16, and 24
Network portion
No. of bitsFirst bit is always:No. of possible network numbersReserved and used for:No. of usable Class _ host addresses (for each class _ network)
Class A8 (1st octet)0=1280.0.0.0 ⇒ default route or special addressing
127.0.0.0 ⇒ loopback
128-2=126
Class B16=16,384--
Class C24=2097152--
Host portion
No. of bitsNo. of possible combinations hostAll host bits are 0 means it’s for network address, e.g.:All host bits are 1 means it’s for broadcast address, e.g.Usable Class _ host addresses (for each class _ network)
Class A24 =16,777,21610.0.0.010.255.255.2554-2=16,777,214
Class B16
=65,536
172.16.0.0172.16.255.255-2=65,534
Class C8
=256
192.168.1.0192.168.1.255-2=254
Class DClass E
First bits11101111
Address range224.0.0.0 to 239.255.255.255240.0.0.0 to 255.255.255.255
Used for:Multicasting ⇒ send data to a selected group (multicast group) of devices (devices that join the multicast group)Reserved for experimental and future use
Not used for:Regular host addressPublic network
Usage:
Video conferencing
Streaming media
Routing Protocol
Most systems ignore or block these addresses by default
255.255.255.255 is a limited broadcast address used to send to all hosts on local network
  • E.g. what is the class of these IP address:
  • Convert to binary, look at first bit(s)
  • E.g. 8.8.8.8
  • 8 is 1000, but need 8 bits so its 0000 1000 ⇒ first bit is 0 ⇒ class A
  • E.g. 172.16.0.1
  • 172 is 1010 1100 ⇒ first 2 bits is 10 ⇒ class B
  • Types of Address
Network addressIdentifies the entire network segment
Is not assigned to any device
Used by routers / devices to determine where to route packets (routing table)
First address in any subnet
Broadcast addressTo send a message to all hosts on the network at once
Is the last address in a subnet
MulticastingSends data to a selected group (multicast group) of devices (devices that join the multicast group)
  • Classful Addressing Scheme
  • Given any IP address (in classful address), able to find:
  • Class of IP address and value of n
  • No. of addresses in the block (a range of addresses)
  • No. of addresses in block N =
  • First and last address in the block
  • 1st: keep the n leftmost bits & set the (32-n) rightmost bits all to 0s
  • Last: keep the n leftmost bits & set (32-n) rightmost bits all to 1s
  • netid = network id; hostid = host id
  • Network Mask
  • A 32-bit number with the n leftmost bits set to 1 and the rest of the (32-n) set to 0s
  • Used to extract network address from IP address by using AND operation
  • E.g. to find network address of IP address: 201.24.67.32:
  • Find class of IP address: class C
  • Network mask of class C is 255.255.255.0
  • Network address is 201.24.67.32 AND 255.255.255.0 ⇒ 201.24.0.0
  • Convert IP and network mask to binary
  • IP:
    11001001.00011000.01000011.00100000
  • Network Mask:
    11111111.11111111.00000000.00000000
  • Take AND; only the first 24 bits matter
    11001001.000110001.01000011.00000000
    (0 takes precedence over 1 (?))
    = 201.24.0.0
  • E.g. Calculate Network and Broadcast Addresses for a given IP address : 192.168.10.10 and network mask: 255.255.255.0. Find the number of usable host IP address
  • Step 1: Convert IP and network mask to binary
  • IP: 11000000.10101000.00001010.00001010
  • Network mask: 11111111.11111111.11111111.00000000
  • Step 2: Logical AND IP and network mask to get network address
  • Only first 24 bits matter → 192.168.10.0
  • Step 3: Set last 8 bits to all 1s for broadcast
  • Broadcast = 192.168.10.255
  • Number of usable host IP address = – 2 = 254
  • Limitations
  • IP address in fixed sizes (Class A, B, C) is either too large or too small for most organisations ⇒ IP address wastage and issues with scaling
  • Routing tables grew large and inefficient
  • Rapid IPv4 exhaustion ⇒ classful structure wasted address space speeds up the exhaustion
  • Not flexible and could not tailor address block size to network size
  • Strategies to overcome limitations
  • Subnetting / Subnet Addressing
  • = process of dividing a larger network into smaller, more manageable subnetworks
  • Resolves issue of insufficient network address in classful addressing scheme (esp class B)5 without abandoning the classful addressing scheme
  • Allows a single network prefix to be used for multiple physical networks
  • Helps organise networks and reduces broadcast traffic
  • 32-bit IPv4 address:
  • Internet portion: identifies a site
  • Local portion: identifies a physical network and host at that site
  • Allocates IP addresses more efficiently by reducing wastage, esp in large networks
  • Reduces congestion and minimises excessive broadcast traffic, leading to better network performance
  • Isolate certain parts of network ⇒ reduce risk of unauthorised access and containing security threats
  • Imposes a form of hierarchical addressing that leads to hierarchical routing
  • Routers (Internet) use the top level of the hierarchy to forward a packet to the correct site
  • Once packet enters site, local routers use physical network octet to select correct network
  • When packet reaches correct network, a router uses host portion to identify a particular host
  • Fixed-length subnetting: a site that choose a division for local portion of its address, then using the division throughout the site
  • Variable-length subnetting: each network will select a subnet partition. Once a partition has been selected for a particular network, it does not vary over time
  • Advantages
  • Flexibility of having a mixture of large & small network
  • Achieve higher utilisation of the address space
  • Disadvantage
  • Difficult to administer – partition for each subset and the values chosen for subnet numbers must be assigned carefully to avoid address ambiguity – an address is interpreted differently on 2 physical networks
  • Variable-length Subnet Masking (VLSM)
  • Network Address Translation (NAT)
  • = method used in routers to translate private IP addresses used inside a local network into public addresses used on internet and vice versa
  • Enables multiple devices on a private network to share 1 public IP address
  • Private IP Address Range
  • Classless Inter-Domain Routing (CIDR) (see Classless Addressing Scheme below)
  • Transition to IPv6 (long term strategy)
  • Subnet Mask
  • A no. of that looks like an IP address (32 bits)
  • Shows how many bits are used for network portion and host portion
  • Mask covers internet portion and physical network part of local portion
  • Bits in subnet mask are set to 1 for subnet prefix and 0 for host identifier
  • The network devices and routers used the subnet mask to understand which part of an IP address identifies the network and which part identifies the host
  • Classless Addressing Scheme
  • Classless Inter-Domain Routing (CIDR): an IP addressing scheme
  • Developed after classful addressing scheme
  • Prevents IP address exhaustion of IPv4
  • More flexible allocation of IP address
  • Support route aggregation ⇒ reducing routing table sizes
  • CIDR addressing still represents IP address in the dotted decimal notation but highlights the network portion with a slash then a no.
  • E.g. 167.199.170.82**/27**, where 27 = prefix length
  • 10100111 11000111 10101010 01010010
  • First 27 bits (bit 0 to bit 26) represents network portion of IP address
  • No. of usable host IP addresses = - 2 = - 2 = 30
  • The number after the slash = no. of bits that represent the network portion of the IP address
  • First address: keep the n leftmost bits and set the (32-n) rightmost bits all to 0s
  • Last address: keep the n leftmost bits and set the (32-n) rightmost bits all to 1s
  • E.g. address: 167.199.170.82/27
  • 10100111 11000111 10101010 01010010
  • First / Network Address: 167.199.170.64/27

10100111 11000111 10101010 01000000

(convert back to binary __.__.__.__)

  • Last / Broadcast Address: 167.199.170.95/27

10100111 11000111 10101010 01011111

  • E.g. 196.168.10.75/27
  • 1100 0000.1010 1000.0000 1010. 0100 1011
    (note 10 is 1010 in binary but add 0000 in front)
    1111.1111.1111 1111.1111 1111.1110 0000
  • 1100 0000.1010 1000.0000 1010.0100 0000
    Network address for this IP: 196.168.10.64
  • 1100 0000.1010 1000.0000 1010.0101 1111
    Broadcast address: 196.168.10.95
  • Usable IP range: 196.168.10.65 to 196.168.10.946
  • Usable host IP addresses : – 2 = 30
  • Because /27 means total IP addresses left, but 1 each (total 2) used for network address and broadcast address
  • CIDR blocks are reserved for private network and not routable on public internet
  • If a packet containing 1 of the private addresses is accidentally forwarded onto the global Internet, a router will detect the problem and discard the packet
  • To access the internet, NAT translates private IP to a public IP
  • The CIDR block 169.2657.0.0/16 is a link-local address. Device will assign itself an address in the block if it fails to connect to a DHCP server to obtain an IP address automatically8

Network devices

  • Hub
  • = a hardware device that operates at physical layer (layer 1) of OSI model and connects multiple devices in a local area network (LAN)
  • Receives incoming data signals on 1 port and broadcasts them to all other ports, regardless of destination
  • Hubs do not filter traffic or use any addressing ⇒ shared bandwidth; potential data collisions
  • (Network) Switch
  • = a networking device that operates at data link layer (layer 2) of OSI model
  • Connects devices within a LAN and uses MAC addresses to forward data only to intended recipient port (within the same network), reducing unnecessary traffic
  • Switch keeps a MAC address table
  • Support full-duplex communication, and each connected device has a dedicated collision domain, improving network efficiency and performance
  • Router
  • = a network device that operates at network layer (layer 3) of OSI model
  • Connects multiple networks together (e.g. LAN to WAN) and forwards data packets based on IP addresses
  • Routers keep a routing table
  • Determine the most important path for data transmission, manage traffic between networks, and often provide additional functions e.g. Network Address Translation (NAT), Dynamic Host Configuration Protocol (DHCP), and firewall capabilities
FeatureHubSwitchRouter
OSI Layer123
Data forwardingBroadcasts to allForwards to 1 deviceRoutes between networks
MAC/IP useNoMAC addressIP address
Collision Domain1 shared domain1 per port1 per interface
Broadcast Domain11Each interface is separate
Speed & EfficiencyLowHighHigh
Use CaseLegacy LANsModern LANsInternet and network gateway
  • Collision domain = a network segment where data packets can collide with one another during transmission if multiple devices attempt to send data at the same time
  • Broadcast domain = a portion of a network where a broadcast sent by 1 device is received by all other devices within the same network segment

Comments from the Word document

Footnotes

  1. Comment by ANDREA TAN KAI XUAN HCI: does this refer to physical and data link layers

  2. Comment by ANDREA TAN KAI XUAN HCI: WHAT’S THIS..

  3. Comment by ANDREA TAN KAI XUAN HCI: ???

  4. Comment by ANDREA TAN KAI XUAN HCI: Cos 11111111 in binary is 255 (?)

  5. Comment by ANDREA TAN KAI XUAN HCI: why B

  6. Comment by ANDREA TAN KAI XUAN HCI: ASK: why slides say .95

  7. Comment by ANDREA TAN KAI XUAN HCI: 254?

  8. Comment by ANDREA TAN KAI XUAN HCI: ??