Collision Domain คือ — คู่มือเครือข่ายคอมพิวเตอร์ 2026
Collision Domain คือพื้นที่ในเครือข่ายคอมพิวเตอร์ที่ data frames จากอุปกรณ์ต่างๆ สามารถชนกัน (collision) ได้ เมื่อมีอุปกรณ์ 2 ตัวขึ้นไปส่งข้อมูลพร้อมกันบน shared medium จะเกิด collision ทำให้ข้อมูลเสียหายต้องส่งใหม่ การเข้าใจ Collision Domain เป็นพื้นฐานสำคัญของ networking ที่ช่วยออกแบบเครือข่ายให้มีประสิทธิภาพ ลด collisions และเพิ่ม throughput บทความนี้อธิบาย Collision Domain พร้อม Broadcast Domain เปรียบเทียบอุปกรณ์เครือข่าย และ Python tools สำหรับวิเคราะห์
Collision Domain คืออะไร
# collision_domain.py — Collision domain explained
import json
class CollisionDomain:
DEFINITION = {
"what": "พื้นที่ในเครือข่ายที่ data frames สามารถชนกันได้",
"when": "เมื่อ 2+ อุปกรณ์ส่งข้อมูลพร้อมกันบน shared medium (เช่น hub, coaxial cable)",
"effect": "ข้อมูลเสียหาย → ต้องส่งใหม่ (retransmission) → performance ลดลง",
"protocol": "CSMA/CD (Carrier Sense Multiple Access with Collision Detection) จัดการ collision",
}
CSMA_CD = {
"step1": "Listen — ฟังว่า medium ว่างหรือไม่",
"step2": "Transmit — ถ้าว่าง ส่งข้อมูล",
"step3": "Detect — ตรวจจับ collision ขณะส่ง",
"step4": "Jam — ถ้าชน ส่ง jam signal แจ้งทุกอุปกรณ์",
"step5": "Backoff — รอ random time แล้วลองส่งใหม่ (exponential backoff)",
}
DEVICES = {
"hub": {
"name": "Hub",
"collision_domains": "1 (ทุก port อยู่ใน collision domain เดียวกัน)",
"broadcast_domains": "1",
"layer": "Layer 1 (Physical)",
"effect": "ยิ่งมีอุปกรณ์เยอะ → collision เยอะ → ช้า",
},
"switch": {
"name": "Switch",
"collision_domains": "N (แต่ละ port เป็น collision domain แยก)",
"broadcast_domains": "1 (ทุก port อยู่ใน broadcast domain เดียวกัน)",
"layer": "Layer 2 (Data Link)",
"effect": "ลด collision มหาศาล — แต่ละ port มี dedicated bandwidth",
},
"router": {
"name": "Router",
"collision_domains": "N (แต่ละ port แยก)",
"broadcast_domains": "N (แต่ละ port เป็น broadcast domain แยก)",
"layer": "Layer 3 (Network)",
"effect": "แยกทั้ง collision และ broadcast domain",
},
"bridge": {
"name": "Bridge",
"collision_domains": "N (แต่ละ port แยก)",
"broadcast_domains": "1",
"layer": "Layer 2",
"effect": "เหมือน switch แต่ port น้อยกว่า (2-4 ports)",
},
}
def show_definition(self):
print("=== Collision Domain คือ ===\n")
for key, val in self.DEFINITION.items():
print(f" [{key}] {val}")
def show_csma_cd(self):
print(f"\n=== CSMA/CD Process ===")
for key, step in self.CSMA_CD.items():
print(f" {step}")
def show_devices(self):
print(f"\n=== อุปกรณ์เครือข่าย ===")
for key, dev in self.DEVICES.items():
print(f"\n[{dev['name']}] ({dev['layer']})")
print(f" Collision Domains: {dev['collision_domains']}")
print(f" Broadcast Domains: {dev['broadcast_domains']}")
cd = CollisionDomain()
cd.show_definition()
cd.show_csma_cd()
cd.show_devices()
Broadcast Domain
# broadcast_domain.py — Broadcast domain explained
import json
class BroadcastDomain:
DEFINITION = {
"what": "พื้นที่ที่ broadcast frame (destination FF:FF:FF:FF:FF:FF) ไปถึงได้",
"effect": "Broadcast มากเกินไป = broadcast storm → network ช้า/ล่ม",
"separator": "Router แยก broadcast domain — switch ไม่แยก (ยกเว้น VLAN)",
}
COMPARISON = {
"collision": {
"name": "Collision Domain",
"scope": "อุปกรณ์ที่ data frames ชนกันได้",
"separated_by": "Switch, Bridge, Router",
"problem": "Collision → retransmission → ช้า",
"modern": "แทบไม่มีปัญหาแล้ว — switch แยก collision domain ต่อ port",
},
"broadcast": {
"name": "Broadcast Domain",
"scope": "อุปกรณ์ที่ broadcast frame ไปถึง",
"separated_by": "Router, VLAN",
"problem": "Broadcast storm → network congestion",
"modern": "ยังเป็นปัญหา — ต้อง design VLAN ให้ดี",
},
}
EXAMPLES = {
"ex1": {
"topology": "5 PCs → 1 Hub",
"collision_domains": 1,
"broadcast_domains": 1,
"explanation": "Hub = 1 collision domain, 1 broadcast domain",
},
"ex2": {
"topology": "5 PCs → 1 Switch",
"collision_domains": 5,
"broadcast_domains": 1,
"explanation": "Switch = 5 collision domains (1 ต่อ port), 1 broadcast domain",
},
"ex3": {
"topology": "Switch A (3 PCs) → Router → Switch B (3 PCs)",
"collision_domains": 8,
"broadcast_domains": 2,
"explanation": "3+1 + 3+1 = 8 collision domains, Router แยก 2 broadcast domains",
},
"ex4": {
"topology": "Hub A (3 PCs) → Switch → Hub B (3 PCs)",
"collision_domains": 3,
"broadcast_domains": 1,
"explanation": "Hub A = 1 CD (4 devices), Switch port = 1 CD, Hub B = 1 CD → 3 CDs total",
},
}
def show_comparison(self):
print("=== Collision vs Broadcast Domain ===\n")
for key, domain in self.COMPARISON.items():
print(f"[{domain['name']}]")
print(f" Scope: {domain['scope']}")
print(f" Separated by: {domain['separated_by']}")
print(f" Problem: {domain['problem']}")
print()
def show_examples(self):
print("=== Examples ===")
for key, ex in self.EXAMPLES.items():
print(f"\n[{ex['topology']}]")
print(f" Collision Domains: {ex['collision_domains']}")
print(f" Broadcast Domains: {ex['broadcast_domains']}")
print(f" {ex['explanation']}")
bd = BroadcastDomain()
bd.show_comparison()
bd.show_examples()
Python Network Analyzer
# analyzer.py — Python network domain analyzer
import json
class NetworkAnalyzer:
CODE = """
# network_analyzer.py — Analyze collision and broadcast domains
import json
class DomainAnalyzer:
DEVICE_PROPERTIES = {
'hub': {
'collision_domain_per_port': False, # All ports share 1 CD
'broadcast_domain_per_port': False, # All ports share 1 BD
'layer': 1,
},
'switch': {
'collision_domain_per_port': True, # Each port = 1 CD
'broadcast_domain_per_port': False, # All ports share 1 BD
'layer': 2,
},
'router': {
'collision_domain_per_port': True, # Each port = 1 CD
'broadcast_domain_per_port': True, # Each port = 1 BD
'layer': 3,
},
'bridge': {
'collision_domain_per_port': True,
'broadcast_domain_per_port': False,
'layer': 2,
},
}
def __init__(self):
self.topology = []
def add_device(self, name, device_type, connected_hosts=0, uplinks=0):
'''Add a device to topology'''
self.topology.append({
'name': name,
'type': device_type,
'hosts': connected_hosts,
'uplinks': uplinks,
'total_ports': connected_hosts + uplinks,
})
def analyze(self):
'''Analyze collision and broadcast domains'''
total_cd = 0
total_bd = 0
details = []
for device in self.topology:
props = self.DEVICE_PROPERTIES.get(device['type'], {})
if props.get('collision_domain_per_port'):
cd = device['total_ports']
else:
cd = 1 # Hub: all ports = 1 CD
if props.get('broadcast_domain_per_port'):
bd = device['total_ports']
else:
bd = 0 # Counted at network level
total_cd += cd
total_bd += bd
details.append({
'device': device['name'],
'type': device['type'],
'collision_domains': cd,
'broadcast_domains': bd,
})
# Minimum 1 broadcast domain if no routers
if total_bd == 0:
total_bd = 1
return {
'total_collision_domains': total_cd,
'total_broadcast_domains': total_bd,
'devices': details,
}
# analyzer = DomainAnalyzer()
# analyzer.add_device('Switch1', 'switch', connected_hosts=5, uplinks=1)
# analyzer.add_device('Router1', 'router', connected_hosts=0, uplinks=2)
# analyzer.add_device('Switch2', 'switch', connected_hosts=3, uplinks=1)
# result = analyzer.analyze()
# print(json.dumps(result, indent=2))
"""
def show_code(self):
print("=== Network Analyzer ===")
print(self.CODE[:600])
analyzer = NetworkAnalyzer()
analyzer.show_code()
VLAN & Modern Networks
# vlan.py — VLAN and modern network design
import json
class VLANDesign:
VLAN_INFO = {
"what": "VLAN (Virtual LAN) แบ่ง broadcast domain บน switch เดียวกัน — ไม่ต้องใช้ router แยก",
"benefit": "ลด broadcast traffic, เพิ่ม security, จัด segment ตาม department/function",
"how": "กำหนด VLAN ID (1-4094) ให้แต่ละ port — อุปกรณ์ต่าง VLAN คุยกันไม่ได้ (ต้องผ่าน Router)",
}
MODERN = {
"full_duplex": {
"name": "Full-Duplex",
"description": "Switch ทุกตัวใช้ full-duplex — ส่งและรับพร้อมกันได้ → ไม่มี collision",
"impact": "Collision domain แทบไม่มีความหมายแล้วใน modern networks",
},
"vlan": {
"name": "VLAN",
"description": "แบ่ง broadcast domain บน switch — ไม่ต้อง physical router",
"impact": "ลด broadcast traffic 60-80%",
},
"stp": {
"name": "STP (Spanning Tree Protocol)",
"description": "ป้องกัน loop ใน Layer 2 — ปิด redundant links",
"impact": "ป้องกัน broadcast storm",
},
"sdn": {
"name": "SDN (Software-Defined Networking)",
"description": "ควบคุม network ด้วย software — flexible, programmable",
"impact": "จัดการ domain ได้ dynamic ไม่ต้อง recable",
},
}
EXAM_TIPS = {
"counting_cd": "นับ collision domain: แต่ละ port ของ switch/router = 1 CD, hub ทั้งตัว = 1 CD",
"counting_bd": "นับ broadcast domain: router แต่ละ port แยก BD, switch/hub ไม่แยก (ยกเว้น VLAN)",
"rule": "Hub = ไม่แยกอะไรเลย, Switch = แยก CD, Router = แยกทั้ง CD และ BD",
}
def show_vlan(self):
print("=== VLAN ===\n")
for key, val in self.VLAN_INFO.items():
print(f" [{key}] {val}")
def show_modern(self):
print(f"\n=== Modern Networks ===")
for key, tech in self.MODERN.items():
print(f"\n[{tech['name']}]")
print(f" {tech['description']}")
def show_exam_tips(self):
print(f"\n=== Exam Tips ===")
for key, tip in self.EXAM_TIPS.items():
print(f" [{key}] {tip}")
vlan = VLANDesign()
vlan.show_vlan()
vlan.show_modern()
vlan.show_exam_tips()
แบบฝึกหัด
# exercises.py — Practice problems
import json
class Exercises:
PROBLEMS = {
"p1": {
"question": "Hub มี 8 ports เชื่อม PC 8 ตัว → มีกี่ collision domain?",
"answer": "1 collision domain (Hub = ทุก port share 1 CD)",
},
"p2": {
"question": "Switch 24 ports เชื่อม PC 20 ตัว + 4 uplinks → มีกี่ collision domain?",
"answer": "24 collision domains (Switch = แต่ละ port เป็น 1 CD)",
},
"p3": {
"question": "Switch A (10 PCs) → Router → Switch B (15 PCs) → Router → Switch C (5 PCs) มีกี่ CD และ BD?",
"answer": "CD: 10+1 + 15+2 + 5+1 = 34 CDs, BD: 3 broadcast domains (Router แยก)",
},
"p4": {
"question": "Hub A (5 PCs) → Switch → Hub B (3 PCs) → Switch → Router → Switch → PC มีกี่ BD?",
"answer": "2 broadcast domains (Router แยก 1 ฝั่ง)",
},
"p5": {
"question": "Switch มี 3 VLANs (VLAN 10, 20, 30) แต่ละ VLAN มี 10 PCs → กี่ BD?",
"answer": "3 broadcast domains (VLAN แยก broadcast domain)",
},
}
def show_problems(self):
print("=== แบบฝึกหัด ===\n")
for key, p in self.PROBLEMS.items():
print(f"[{key}] {p['question']}")
print(f" Answer: {p['answer']}")
print()
exercises = Exercises()
exercises.show_problems()
FAQ - คำถามที่พบบ่อย
Q: Collision Domain ยังสำคัญอยู่ไหมในปัจจุบัน?
A: ในทางปฏิบัติ: แทบไม่สำคัญแล้ว เพราะ switch + full-duplex ทำให้ไม่มี collision ในทางทฤษฎี: ยังสำคัญสำหรับ CCNA, CompTIA Network+ exams กรณีที่ยังเกี่ยวข้อง: WiFi (802.11) ยังใช้ shared medium → มี collision domain (CSMA/CA)
Q: Switch กับ Hub ต่างกันอย่างไร?
A: Hub: Layer 1, ส่ง frame ไปทุก port (flooding), 1 collision domain → ช้าเมื่อเครื่องเยอะ Switch: Layer 2, ส่ง frame เฉพาะ port ปลายทาง (MAC address table), แต่ละ port แยก collision domain → เร็วกว่ามาก ปัจจุบัน: Hub แทบไม่มีขายแล้ว — Switch ราคาถูกมาก
Q: WiFi มี Collision Domain ไหม?
A: มี — WiFi ใช้ shared medium (อากาศ) → อุปกรณ์ทุกตัวใน SSID เดียวกันอยู่ใน collision domain เดียวกัน ใช้ CSMA/CA (Collision Avoidance) แทน CSMA/CD — เพราะตรวจจับ collision ไม่ได้ทาง wireless วิธีลด: ใช้ 5 GHz/6 GHz (คนน้อยกว่า), AP isolation, channel planning ยิ่งมีอุปกรณ์เยอะบน AP → ยิ่งช้า (contention)
Q: นับ Collision Domain และ Broadcast Domain อย่างไร?
A: กฎง่ายๆ: Hub = ไม่แยกอะไรเลย (ทุก port = 1 CD, 1 BD) Switch = แยก CD (แต่ละ port = 1 CD) แต่ไม่แยก BD Router = แยกทั้ง CD และ BD (แต่ละ port = 1 CD + 1 BD) VLAN = แยก BD บน switch (เหมือน router แต่ไม่ต้อง physical port) วิธีนับ: นับ port ทั้งหมดของ switch/router = CD, นับ interface ของ router = BD
