Lecture 7 - Network Layer (Part 1)

Updated 4 Oct 2026

Roadmap

  • Network Component
  • Network Architecture
  • Network Layer: Overview
    • Data Plane (Forwarding)
    • Control Plane (Routing)
  • IP: The Internet Protocol
    • Classful IP Address
    • Subnet
    • Network Diagram
    • DHCP

TCP/IP Model (Internet Protocol Stack)

OSI Model LayerUpdated TCP/IP ModelTCP/IP Protocol SuiteRole
Application, Presentation, SessionApplication LayerHTTP, SMTP, Telnet, FTP, DNS, RIP, SNMPCompression, Encryption, Session, Socket
TransportTransport LayerTCP, UDPReliable (or unreliable) transport
Network (L3)Network LayerARP, IP, IGMP, ICMPBest-effort global packet delivery
Data Link (L2)Data Link LayerEthernet, Token Ring, ATM, Frame Relay—
Physical (L1)Physical LayerCopper Cable, Coax, Fiber, Wireless, Radio—

จำได้มั้ย Transport Layer เราก็มีพวก Port, Socket → Link to Process

Analogy: Think of the layers like sending a package internationally. The Application layer is you writing the letter. The Transport layer is the courier service (TCP = reliable, UDP = fast but no guarantee). The Network layer is the postal routing system that decides which country/city to send it to. The Data Link and Physical layers are the actual roads, trucks, and highways the package physically travels on.


TCP/IP and Communication (Web Request)

When a browser requests google.com:

  • Application Layer: Browser sends HTTP request to Google.com
  • Transport Layer (TCP): Src Port: 4546 → Dst Port: 80
  • Network Layer (IP): Src IP: 192.168.0.1 → Dst IP: 203.159.10.11
  • Data Link Layer (MAC): Src MAC: B4-6B-FC-7F-7F-8C → Dst MAC: 8C-16-45-74-32-AA
  • Routers (L3) sit in the middle — they only deal with Network + Data Link + Physical layers
  • The full stack (Application through Physical) exists on both the sending host and receiving host
  • Communication is process-to-process at Application layer, host-to-host at Transport layer

Network Components

Key Devices

DeviceLayerIdentifier Used
HubL1 – Physical only— (broadcasts everything)
SwitchL2 – Data LinkMAC Address
RouterL3 – Network (+ L2, L1)IP Address
  • Hub: Operates only in the physical layer — it floods every packet to all ports
  • Switch: Operates at data-link layer — it learns MAC addresses and forwards smartly
  • Router: Three-layer device — it routes packets based on IP addresses between networks

Analogy: A hub is like shouting in a room (everyone hears). A switch is like whispering directly to the right person. A router is like a post office that directs mail between cities.

  • Server = ปกติแล้วเราจะ Fixed IP, high speed (everybody knows how to connect)
  • Client = IP dynamic
  • Hub (L1) = dump device, don’t know anything, just receive electrical signal, and forward to EVERY port (already obsolete)
    • Why hub is not good?: It forwards to every port, so the data is not secure. แล้วทุก port ถูกใช้ ดังนั้นส่งข้อมูลเพิ่มไม่ได้??
  • Switch (L2) = Switch check whether the destination are available to which port, then it forward to the port (NOT ALL PORT like hub) (Uses MAC address to forward the traffic)

อย่างเวลาอยู่ใน Lab คือ ทุกเครื่องสามารถ Ping หากันได้หมดใช้ป้ะ จะทำแบบนี้ได้ ทุกเครื่องต้องอยู่ใน Network เดียวกัน (Subnet เดียวกัน)

Different Network should be connected using Router!! แล้วใน Router ก็จะมี Routing Table บอกอีกที ว่า IP นี้ ๆ ให้ออกไป Port ไหน!

  • WAN Link can also be considered another network, connected to external network (intranet)

Physical Equipment Examples

  • 2 Port Repeater
  • ADSL Modem with Wi-Fi
  • 8 Port HUB
  • 24 Port Switch
  • Wireless Router
  • Broadband Router
  • Ethernet Card
  • Modem with Fiber Optic

บางอันมี Uplink Port ที่สามารถไปต่อกับ Equipment อื่นให้ได้ Bandwidth มากขึ้น???

สมมติ Switch มี 24 ports, ถ้าอยากต่อ 24 PCs ใน Lab จะพอป้ะ?


อาจจะไม่พอนะ อาจจะมี 25 + 3 อาจจะยังได้ เพราะว่าแต่ละเครื่องต้องต่อ Internet ด้วย
หรืออาจจะมีสำรองไว้ เผื่อบางวัน Port ใด เสียขึ้นมา เป็นสำรองไว้


Network Architecture

Home Network

  • Cable/Fiber modem → connects to ISP
  • Modem Router (with Wi-Fi) → distributes to devices via LAN or wireless
  • Devices: Desktop PC, Laptop, Smartphone, Printer, IP Camera, etc.

Home Network (ADSL)

  • Phone Jack → Phone Cable → ADSL Splitter → Modem Router
  • Phone (optional) can still be connected alongside internet

100 People มี 100 IP พอป่าว?


ก็อาจจะยังนะ แต่ละคนมีกี่ Devices ล่ะ? iPhone, iPad, Apple Watch โอ้โห คูณไปเลย 3 IP ที่ต้องมี

Office Network

  • Internet → Firewall → Router → Switches → PCs, IP Phones, Printers, Servers
  • WiFi Router for wireless clients (Laptops, Smartphones)

Interface

  • Interface: The connection point between a host/router and a physical link
  • Routers typically have multiple interfaces
  • Hosts typically have one or two interfaces (e.g., wired Ethernet eth0, wireless wlan0)
  • Each interface has a unique name (e.g., eth0, eth1, eth2) and an IP address

Analogy: An interface is like a door of a building — each door connects to a different street (network). A router has many doors; your laptop usually just has one or two.

Extending Network Connectivity

  • Wired: Ethernet interfaces connected via Ethernet switches
  • Wireless: WiFi interfaces connected via WiFi base station (Access Point)

Network Layer: Services and Protocols

Core Function

Transport segments from sending host to receiving host:

  • Sender: Encapsulates segments into datagrams, passes to link layer
  • Receiver: Delivers segments to transport layer protocol

Network Layer is in Every Internet Device

  • Hosts and Routers all implement the network layer
  • Routers:
    • Examine header fields in all IP datagrams passing through
    • Move datagrams from input ports → output ports along end-to-end path

Two Key Network-Layer Functions

FunctionScopeAnalogy
ForwardingLocal, per-routerGetting through a single interchange
RoutingNetwork-widePlanning the trip from source to destination
  • Forwarding: Move packets from a router's input link to the appropriate output link
  • Routing: Determine the route taken by packets from source to destination using routing algorithms


Network Layer: Data Plane vs Control Plane

Data Plane (Forwarding)

  • Local, per-router function
  • Determines how datagrams arriving on router input port are forwarded to output port
  • Works by looking up values in arriving packet header against a local forwarding table

Control Plane (Routing)

  • Network-wide logic
  • Determines how datagrams are routed among routers along end-to-end path

Two Control Plane Approaches

  1. Traditional (Per-Router) Routing Algorithms
  • Individual routing algorithm in each and every router
  • Routers exchange info with each other to build forwarding tables
  • Protocols: OSPF, BGP

ตัว Header จริง ๆ แล้วจะเป็น Destination Address

  1. Software-Defined Networking (SDN)
  • A remote controller computes and installs forwarding tables in routers
  • Each router has a Local Control Agent (CA) that communicates with the remote controller
  • More centralized, flexible, and programmable

The router itself don’t have to do the calculation, it will be done by the server of the network or something, แต่ละ router ก็ต้องรัน CA Agent เพื่อคุย/ส่งข้อมูลกับ Remote Controller


Network Layer: Internet Protocols

Host/Router Network Layer Functions

transport layer: TCP, UDP
        ↓
┌───────────────────────────────────────────────────────┐
│  Path-selection    →  forwarding  →  IP protocol      │
│  algorithms              table       - datagram format │
│  (OSPF, BGP,                         - addressing      │
│   SDN controller)                    - packet handling │
│                                                        │
│                                      ICMP protocol     │
│                                      - error reporting │
│                                      - router signal   │
└───────────────────────────────────────────────────────┘
        ↓
link layer → physical layer


IP Datagram Format

The structure of every IP packet (32 bits wide):

Field Descriptions

FieldDescription
verIP protocol version number (IPv4 = 4)
head.lenHeader length in bytes
type of serviceDiffserv / ECN — quality of service hints
lengthTotal datagram length (bytes). Max: 64K bytes, typically ≤ 1500 bytes
16-bit identifierUsed for fragmentation/reassembly
flgs + fragment offsetFragmentation control
time to live (TTL)Remaining max hops — decremented at each router
upper layerProtocol above IP (e.g., TCP = 6, UDP = 17)
header checksumError detection for header
source IP address32-bit source address
destination IP address32-bit destination address
optionse.g., timestamp, record route taken
payload dataTypically a TCP or UDP segment

Overhead

TCP + IP overhead=20 bytes (TCP)+20 bytes (IP)=40 bytes\boxed{\text{TCP + IP overhead} = 20 \text{ bytes (TCP)} + 20 \text{ bytes (IP)} = 40 \text{ bytes}}


Network-Layer Service Model

Network ArchitectureService ModelBandwidthLossOrderTiming
InternetBest effortNoneNoNoNo
ATMConstant Bit Rate (CBR)Constant rateYesYesYes
ATMAvailable Bit Rate (ABR)Guaranteed minNoYesNo
InternetIntserv Guaranteed (RFC 1633)YesYesYesYes
InternetDiffserv (RFC 2475)PossiblePossiblyPossiblyNo

Internet "Best Effort"

  • No guarantees on:
    1. Successful datagram delivery to destination
    2. Timing or order of delivery
    3. Bandwidth available to end-to-end flow

Analogy: Internet best-effort is like dropping a letter in a public mailbox with no tracking — it usually arrives, but there's no promise of when or in what order.


IP Address

IP Address vs Home Address

Postal Address: Apartment 1, Building 1, ABC Road, Bangkok, Thailand

Address: TCP Port 1, IP Address, Network, ISP AIS Fiber, ISP CAT Telecom (Thailand)

Address: TCP 80, IP 192.168.100.10, 192.168.10.0/24, ISP AIS Fiber, ISP CAT Telecom (Thailand)

ถ้าเป็น Network เล็กแบบนี้นะ อย่าง Router ตัวแรก ใน Routing Table ก็ต้องมี Address ของ Net A, B, C
แต่ถ้าเป็นชีวิตจริง Net ใหญ่มาก ถ้าเป็น 0.0.0.0 ก็ให้ไป S2 ก็ได้

Structure

  • IP address: 32-bit identifier associated with each host or router interface
  • Written in dotted-decimal notation: 4 octets separated by dots

192.168.32.152=11000000⏟192.10101000⏟168.00100000⏟32.10011000⏟152\boxed{192.168.32.152 = \underbrace{11000000}_{192}.\underbrace{10101000}_{168}.\underbrace{00100000}_{32}.\underbrace{10011000}_{152}}

Binary Calculation Reference

Bit position76543210
Binary exponential272^7262^6252^5242^4232^3222^2212^1202^0
Value if bit = 11286432168421
  • Each octet = 8 bits → value range: 0 – 255

Three Notations for IPv4

NotationExample
Binary10000000 00001011 00000011 00011111
Dotted Decimal128.11.3.31
Hexadecimal80 0B 03 1F

IP Address: Network / Subnet

Why Subnets?

  • Total IP range: 232≈4.32^{32} \approx 4.3 billion IPs
  • Having one flat range for the entire world causes:
    • Broadcast issues (floods entire network)
    • Difficult to manage
    • Security issues
    • Cannot separate traffic by area

  • Solution: Split IP range into multiple subnets

Analogy: Subnetting is like dividing a city into neighbourhoods. Instead of delivering every message to every house in the city, you only broadcast within your own neighbourhood (subnet).

Broadcast Domain

  • Broadcast messages are scoped within the subnet — they do NOT pass through routers
  • Examples: ARP broadcast, ping to broadcast address
  • Subnets help limit and contain broadcast traffic


คืออะไรวBroadcast packet คือ packet ที่ส่งไปหา ทุกเครื่องใน network เดียวกัน เช่น
ARP Request → “ใครมี IP นี้?”
Ping broadcast address
DHCP discovery
ตัวอย่าง
ถ้าเครื่อง A ส่ง broadcast:
Who has 192.168.1.5?
ทุกเครื่องใน subnet นั้นจะได้รับ
A → Switch → ทุกเครื่องใน subnet
แต่ router จะไม่ส่ง broadcast ต่อไป subnet อื่น

Subnet Mask

  • IP address is split into two parts: Network (Prefix) and Host (Suffix)

IP Address=Network Portion (n bits)⏟Prefix+Host Portion (32-n bits)⏟Suffix\boxed{\text{IP Address} = \underbrace{\text{Network Portion (n bits)}}_{\text{Prefix}} + \underbrace{\text{Host Portion (32-n bits)}}_{\text{Suffix}}}

  • Subnet Mask: A 32-bit number where:
    • Set of 1s = network portion
    • Set of 0s = host portion

Example: 192.168.10.10/24

Octet 1Octet 2Octet 3Octet 4
IPv4 Address1921681010
Binary11000000101010000000101000001010
Subnet Mask2552552550
Mask Binary11111111111111111111111100000000
  • /24 means 24 bits are network → 8 bits for hosts → 28=2562^8 = 256 total IPs

3 Parts of an IP Address in a Subnet

PartDescriptionExample (192.168.30.0/24)
Network AddressFirst IP — identifies the subnet192.168.30.0
Host AddressesAll IPs excluding first and last192.168.30.1 – 192.168.30.254
Broadcast AddressLast IP — sends to all hosts in subnet192.168.30.255
Usable Hosts=2host bits−2\boxed{\text{Usable Hosts} = 2^{\text{host bits}} - 2}

Subtract 2 because: 1 for Network Address + 1 for Broadcast Address

Example: 192.168.30.0/24

  • Network: 192.168.30.0
  • HostMin: 192.168.30.1
  • HostMax: 192.168.30.254
  • Broadcast: 192.168.30.255
  • Hosts/Net: 28−2=2542^8 - 2 = 254
  • Subnet Mask: 255.255.255.0 (/24)

Example: 192.168.5.10/24

  • Network: 192.168.5.0
  • HostMin: 192.168.5.1
  • HostMax: 192.168.5.254
  • Broadcast: 192.168.5.255
  • Hosts/Net: 254

CIDR Notation Examples

  • 12.24.76.8/8
  • 23.14.67.92/12
  • 220.8.24.255/25

How many subnet do we need?
How many hosts?

IP Address: Classful Addressing

4 Main Techniques to Split IP Range

  1. IP Address Classful (A, B, C) ← this lecture
  2. Public/Private IP ← this lecture
  3. Classless Inter-Domain Routing (CIDR)
  4. Variable Length Subnet Mask (VLSM)

Stop here March 5

IP Address Classes

ClassFirst Octet RangeNetwork MaskPrefixNumber of NetworksNumber of Hosts
A1 – 127255.0.0.0/8128 (272^7)16,777,214
B128 – 191255.255.0.0/1616,384 (2142^{14})65,534
C192 – 223255.255.255.0/242,097,152 (2212^{21})254
D224 – 239——Multicast addresses—
E240 – 254——Restricted/Experimental—

Formulas

Total Networks=2remaining net ID bits\boxed{\text{Total Networks} = 2^{\text{remaining net ID bits}}} Total Hosts=2host bits−2\boxed{\text{Total Hosts} = 2^{\text{host bits}} - 2}

  • Class A prefix: Fixed bit 0 → 7 bits for net ID → 24 bits for host
  • Class B prefix: Fixed bits 10 → 14 bits for net ID → 16 bits for host
  • Class C prefix: Fixed bits 110 → 21 bits for net ID → 8 bits for host

Analogy: Class A is like a country (few, but enormous networks). Class B is like a state/province. Class C is like a neighbourhood (many small networks).

Class Usage

  • Class A: Huge networks — used by ISPs
  • Class B: Medium/large — enterprises and organizations
  • Class C: Most common — small businesses and home networks

Reserved Addresses

  • Class A: 127.0.0.1 — Loopback (refers to yourself)
  • Class B: 169.254.0.0/16 — Link-local / APIPA (auto-assigned when no DHCP server found)

Class B: Detail


Fixed prefix bits: 10
10000000⏟=128to10111111⏟=19110\underbrace{000000}_{} = 128 \quad \text{to} \quad 10\underbrace{111111}_{} = 191
Valid subnets: 128.0.X.X through 191.255.X.X
Number of Networks=216−2=16,384\text{Number of Networks} = 2^{16-2} = 16{,}384 Hosts per Network=216−2=65,534\text{Hosts per Network} = 2^{16} - 2 = 65{,}534
Example: 128.2.0.0/16

  • Network: 128.2.0.0
  • HostMin: 128.2.0.1
  • HostMax: 128.2.255.254
  • Broadcast: 128.2.255.255
  • Mask: 255.255.0.0 (/16)

Class A, B, C Summary Examples

Class A (10.2.1.1/8): Usable: 224−2=16,777,214 hosts\boxed{\text{Usable: } 2^{24} - 2 = 16{,}777{,}214 \text{ hosts}}

  • Network: 10.0.0.0 | Broadcast: 10.255.255.255 | Mask: 255.0.0.0

Class B (172.16.1.5/16): Usable: 216−2=65,534 hosts\boxed{\text{Usable: } 2^{16} - 2 = 65{,}534 \text{ hosts}}

  • Network: 172.16.0.0 | Broadcast: 172.16.255.255 | Mask: 255.255.0.0

Class C (192.168.1.1/24): Usable: 28−2=254 hosts\boxed{\text{Usable: } 2^{8} - 2 = 254 \text{ hosts}}

  • Network: 192.168.1.0 | Broadcast: 192.168.1.255 | Mask: 255.255.255.0

AIT มี/ได้ Internet full Class C (255) (หมายถึง Public IP??) - SIIT มี 4 แล้วการที่มีเยอะ ๆ นี่มันได้อะไรขึ้นมา ทำไมบริษัทจำเป็นต้องมี Public IP


Contents


Public and Private IP Addresses

Comparison

FeaturePublic IPPrivate IP (Intranet)
UsagePublic Network (WAN, Internet)Private network (LAN)
Internet recognitionRecognizedNot recognized
UniquenessGlobally uniqueUnique only within the network
CostPaidFree
Assigned byISP / IANA (under ICANN)Network Administrator
RangeMuch biggerLimited per class

Private Address Ranges

ClassPrivate Address Range
A10.0.0.0 to 10.255.255.255
B172.16.0.0 to 172.31.255.255
C192.168.0.0 to 192.168.255.255

Public Address Ranges

ClassPublic IP Ranges
A1.0.0.0 – 9.255.255.255 and 11.0.0.0 – 126.255.255.255
B128.0.0.0 – 171.255.255.255 and 173.0.0.0 – 191.255.255.255
C192.0.0.0 – 195.255.255.255 and 197.0.0.0 – 223.255.255.255
D224.0.0.0 – 247.255.255.255 — Multicast
E248.0.0.0 – 255.255.255.254 — Experimental

Key insight: Two homes can have the same private IP (e.g., 192.168.1.1) but different public IPs. Private IPs are like apartment numbers — the same number can exist in different buildings, but each building (public IP) is unique on the street (internet).

Class B Private Range — Detail

Valid private Class B networks: 172.16.X.X through 172.31.X.X

Number of subnets=216−12=16 subnets\text{Number of subnets} = 2^{16-12} = 16 \text{ subnets}

Example: 172.18.0.0/16

  • Network: 172.18.0.0
  • Usable: 172.18.0.1 – 172.18.255.254
  • Broadcast: 172.18.255.255
  • Mask: 255.255.0.0 (/16)

  • 192.168.1.1 คนละ Network ซ้ำกันได้เห็นมะ
  • แต่พวก 82.129.80.111 กับ 49.228.234.12 เป็น Public IP แล้ว - ซ้ำไม่ได้
  • NAT protocol เอาไว้ใช้ convert (Public IP → Private IP)

ถ้าเชื่อม WiFi เดียวกันกับอาจารย์ Public IP จะเป็นอันเดียวกันมั้ย?

IP Camera ที่เป็น 1 subnet ไปเลยเนี่ย แล้วการที่ต้องตั้งค่าให้คอมใน Computer center ในห้องเข้าถึงได้ เราต้องไปตั้งที่ Router ใช่ป่าว ว่าคอมนี้อยู่ใน Subnet นี้ หรือว่าทำยังไง?


How to Design a Network / Create Subnets

Steps

  1. Determine the number of required Network IDs:
    • One for each subnet
    • One for each WAN connection
    • How many departments?
  2. Determine the number of required Host IDs per subnet:
    • One for each TCP/IP host
    • One for each router interface
  3. Based on requirements, create:
    • One subnet mask for the entire network
    • A unique subnet ID for each physical segment
    • A range of host IDs for each subnet

Subnetting Examples

Example 1: 4 Subnets from Class C

#FinalExam asking you the design for the internal network, we are network admin

Network: 192.168.100.0/24
Need: 4 networks/subnets
Areas: 100 users, 60 users, 200 users + WAN link

AreaSubnetDetails
Area 1192.168.1.0/24100 users
Area 2192.168.2.0/2460 users
Area 3192.168.3.0/24200 users
Each Class C subnet: 28−2=2542^8 - 2 = 254 hosts max

Example 2: Mixed Class B and C

Areas: 5000 users, 1000 users, 200 users

จากรูป เรามีทั้งหมด 4 networks นะ, อย่าลืมระหว่าง Router

AreaSubnetClassMax Hosts
Area 1 (5000 users)172.17.0.0/16B65,534
Area 2 (1000 users)172.16.0.0/16B65,534
Area 3 (200 users)192.168.100.0/24C254

Network Diagram

Two Types

Logical Network Diagram

  • Shows how information flows through a network
  • Displays: subnets, network devices, routing protocols
  • Uses cloud shapes for subnets, router symbols, with IP addresses labeled on interfaces

Physical Network Diagram

  • Shows the actual physical topology — all devices and their connections
  • Labels interface names (eth0, eth1, eth2) and their IP addresses

For physical network diagram, we have to specify ถึง Interface นะ (สำคัญมากกก ออกสอบแน่นอน #FinalExam) MOST COMMON MISTAKE

Example

  • Logical: Router R1 and R2 connected, each with labeled interface IPs and subnet clouds
  • Physical: Linear layout showing A → (Network A) → R1 → (Network B) → R2 → (Network C) → B, with all ethXinterface IPs labeled

How Does a Host Get an IP Address?

Two Ways

  1. Static (Hard-coded): Sysadmin manually sets IP in config (e.g., /etc/rc.config in UNIX)
  2. DHCP — Dynamic Host Configuration Protocol: Host automatically gets an IP from a server (“plug-and-play”)
    • Automatically allocate the IP when new client join the network.
    • DHCP makes sure that there is no conflict!

เวลาเขียน IP Address ต้องเป็น CIDR Prefix เสมอนะ (ถ้าไม่บอกก็ไม่รู้ว่าเป็นของ Network ไหน)

How Does a Network Get Its IP?

  • Private Network: Allocated by Network Admin from private ranges
  • Public IP: Purchased from ISP

DHCP: Dynamic Host Configuration Protocol

Every router in your home have this protocol enabled!

Purpose

  • Host dynamically obtains IP address from network server when it joins the network
  • Supports address reuse (only holds address while connected)
  • Supports mobile users (join/leave network dynamically)
  • Can renew lease on address currently in use

มันจะหมดเวลาเมื่อไหร่นะ ที่ Client ต้องขอใหม่? มันมี timestamp อะไรหรอ

DHCP Process (4 Steps)

StepMessageDirectionDescription
1DHCP DiscoverClient → Broadcast"Is there a DHCP server out there?"
2DHCP OfferServer → Broadcast"I'm a DHCP server! Here's an IP you can use"
3DHCP RequestClient → Broadcast"OK, I would like to use this IP!"
4DHCP ACKServer → Broadcast"OK, you've got that IP address!"

Steps 1 and 2 can be skipped if a client remembers and wishes to reuse a previously allocated address [RFC 2131]

Packet Details


DHCP Discover:

  • src: 0.0.0.0, port 68 → dest: 255.255.255.255, port 67
  • yiaddr: 0.0.0.0, transaction ID: 654

DHCP Offer:

  • src: 223.1.2.5, port 67 → dest: 255.255.255.255, port 68
  • yiaddr: 223.1.2.4, transaction ID: 654, lifetime: 3600 secs

DHCP Request:

  • src: 0.0.0.0, port 68 → dest: 255.255.255.255, port 67
  • yiaddr: 223.1.2.4, transaction ID: 655, lifetime: 3600 secs

DHCP ACK:

  • src: 223.1.2.5, port 67 → dest: 255.255.255.255, port 68
  • yiaddr: 223.1.2.4, transaction ID: 655, lifetime: 3600 secs

Why broadcast? The client doesn't have an IP yet, so it can't send unicast. And the server's reply is also broadcast because the client isn't officially on the network yet.

บน Router เราก็สามารถ Specify ได้ว่า MAC Address นี้ให้ใช้ IP Address นี้ตลอดนะ

DHCP Returns More Than Just an IP

DHCP also provides:

  • Default Gateway: Address of first-hop router
  • DNS Server: Name and IP of DNS server (for domain name lookups)
  • Subnet Mask: To determine network vs host portion

DHCP Encapsulation

  • DHCP message → encapsulated in UDP → in IP → in Ethernet
  • Ethernet frame is broadcast (dest: FF:FF:FF:FF:FF:FF) on LAN
  • Router running DHCP server receives it, processes it, and replies

DHCP in Practice (Home Network Example)

ISP Modem (10.10.10.26)
       ↓
  Router (192.168.1.1) ← DHCP server lives here
       ↓
  Switch (192.168.1.2)
   ↙    ↓    ↘
Desktop  Game  Network Printer (192.168.1.100 — static)
(DHCP)  Console  Mobile Phone (DHCP)
              Laptop (DHCP)

The DHCP server is typically co-located in the router, serving all subnets the router is attached to.


Summary

TopicKey Points
Network ComponentsHub (L1), Switch (L2), Router (L3)
Network ArchitectureHome, Office, Enterprise setups
Data PlaneLocal, per-router forwarding
Control PlaneNetwork-wide routing (Per-Router or SDN)
IP Address32-bit, dotted-decimal, network + host parts
Classful IPClass A (/8), B (/16), C (/24) + D, E
Public/Private IPPublic = globally unique, paid; Private = free, LAN-only
SubnetDivides IP range; uses subnet mask
Network DiagramLogical (flow) vs Physical (topology)
DHCPDiscover → Offer → Request → ACK; provides IP, gateway, DNS, mask

Random MAC Address ทำได้ไงอะ มันไม่ได้ฝังมาชิปหรือว่าอะไรแล้วหรอ


Contents

IoT ที่บ้าน


Contents

ดูข้อสอบ