Network Packet Capture: tcpdump, Wireshark และ Packet Analysis

Network Packet Capture: tcpdump, Wireshark และ Packet Analysis

Packet Capture เป็นเทคนิคพื้นฐานที่สำคัญที่สุดในการ troubleshoot network problems โดยการจับ packets ที่วิ่งผ่าน network interface แล้ววิเคราะห์ content ของแต่ละ packet tcpdump เป็น command-line tool สำหรับ capture บน Linux/Unix ส่วน Wireshark เป็น GUI tool ที่ powerful ที่สุดสำหรับ packet analysis

Network engineers หลายคน troubleshoot โดยการเดา แทนที่จะดูข้อมูลจริง Packet capture ให้ “ความจริง” ว่าเกิดอะไรขึ้นบน wire ไม่ว่าจะเป็น TCP retransmission, DNS failure, TLS handshake error หรือ application-level issues ทุกอย่างเห็นได้จาก packets

Capture Tools

Tool Type Platform จุดเด่น
tcpdump CLI Linux/macOS/Unix Lightweight, ใช้ได้ทุก server, scriptable
Wireshark GUI Windows/Linux/macOS Powerful analysis, protocol dissectors, display filters
tshark CLI Windows/Linux/macOS Wireshark CLI version, same dissectors
dumpcap CLI Windows/Linux Lightweight capture only (no analysis)
ngrep CLI Linux grep for network packets (pattern matching)
Packet Capture (Android) App Android Capture on mobile devices

tcpdump Basics

Command ใช้ทำอะไร
tcpdump -i eth0 Capture บน interface eth0
tcpdump -i any Capture บนทุก interface
tcpdump -w capture.pcap Save capture เป็นไฟล์ .pcap
tcpdump -r capture.pcap อ่านไฟล์ capture
tcpdump -c 100 จับแค่ 100 packets แล้วหยุด
tcpdump -n ไม่ resolve DNS names (เร็วกว่า)
tcpdump -v / -vv / -vvv Verbose output (level 1/2/3)
tcpdump -s 0 Capture full packet (snaplen = unlimited)

tcpdump Filters (BPF)

Filter ตัวอย่าง จับอะไร
host tcpdump host 192.168.1.1 Traffic ไป/จาก IP นี้
src/dst tcpdump src 10.0.0.1 Traffic จาก source IP นี้
port tcpdump port 443 Traffic ที่ port 443
net tcpdump net 10.0.0.0/24 Traffic ใน subnet นี้
protocol tcpdump tcp / udp / icmp เฉพาะ protocol ที่ระบุ
and/or/not tcpdump host 10.0.0.1 and port 80 Combine filters
tcp flags tcpdump ‘tcp[tcpflags] & tcp-syn != 0’ TCP SYN packets

Wireshark Display Filters

Filter จับอะไร
ip.addr == 10.0.0.1 Traffic ไป/จาก IP
tcp.port == 443 TCP port 443
http.request.method == “GET” HTTP GET requests
dns.qry.name contains “google” DNS queries ที่มี “google”
tcp.analysis.retransmission TCP retransmissions (ปัญหา!)
tcp.analysis.zero_window TCP zero window (receiver full)
tls.handshake.type == 1 TLS Client Hello
frame.time_delta > 1 Packets ที่ห่างกัน > 1 วินาที
tcp.flags.reset == 1 TCP RST packets (connection reset)

Common Analysis Scenarios

Problem สิ่งที่ดูใน Capture Wireshark Filter
Connection timeout SYN ไม่มี SYN-ACK กลับ tcp.flags.syn == 1 && tcp.flags.ack == 0
Slow application TCP retransmissions, high latency tcp.analysis.retransmission
DNS failure DNS query ไม่มี response หรือ NXDOMAIN dns
TLS error TLS alert messages, handshake failure tls.alert_message
Packet loss TCP retransmissions + duplicate ACKs tcp.analysis.lost_segment
MTU issues ICMP “need to frag” + large packets icmp.type == 3 && icmp.code == 4

TCP Analysis

TCP Event ความหมาย ปัญหาหรือไม่
Retransmission Packet ถูกส่งซ้ำ (original หาย) มาก = packet loss / network congestion
Duplicate ACK Receiver ACK packet เดิมซ้ำ บอก sender ว่า packet หาย
Zero Window Receiver buffer เต็ม Application อ่าน data ช้า
Window Update Receiver บอกว่ามี buffer ว่างแล้ว ปกติ (หลัง zero window)
RST Connection reset อาจปกติ (close) หรือ error (firewall block)
Out-of-Order Packets มาไม่ตามลำดับ เล็กน้อย = ปกติ, มาก = network issue

Capture Best Practices

Practice รายละเอียด
Capture ใกล้ปัญหา Capture ที่ server/client ที่มีปัญหา (ไม่ใช่ที่อื่น)
ใช้ capture filter Filter ที่ tcpdump level เพื่อลดขนาดไฟล์
Full packet capture ใช้ -s 0 จับ full packet (ไม่ truncate)
Save เป็น .pcap Save ไฟล์แล้วเปิดใน Wireshark วิเคราะห์ทีหลัง
Capture ทั้ง 2 ฝั่ง Capture ที่ client + server พร้อมกัน เพื่อเปรียบเทียบ
ระวังเรื่อง sensitive data Packet capture อาจมี passwords, PII → เก็บ/ลบอย่างปลอดภัย
Ring buffer ใช้ -W + -C สำหรับ continuous capture (rotate files)

ทิ้งท้าย: Packet Capture = Network Truth

Packet Capture = ดูความจริงของ network (ไม่ต้องเดา) tcpdump = CLI (lightweight, ใช้บน server) + Wireshark = GUI (powerful analysis) BPF filter (tcpdump) vs Display filter (Wireshark) TCP retransmission + zero window + RST = สิ่งที่ต้องดูเสมอ Capture ใกล้ปัญหา + full packet + save .pcap

อ่านเพิ่มเติมเกี่ยวกับ Network Troubleshooting Methodology และ NetFlow sFlow Analysis ที่ siamlancard.com หรือจาก icafeforex.com และ siam2r.com

จัดส่งรวดเร็วส่งด่วนทั่วประเทศ
รับประกันสินค้าเคลมง่าย มีใบรับประกัน
ผ่อนชำระได้บัตรเครดิต 0% สูงสุด 10 เดือน
สะสมแต้ม รับส่วนลดส่วนลดและคะแนนสะสม

© 2026 SiamLancard — จำหน่ายการ์ดแลน อุปกรณ์ Server และเครื่องพิมพ์ใบเสร็จ

SiamLancard
Logo
Free Forex EA Download — XM Signal · EA Forex ฟรี
iCafeForex.com - สอนเทรด Forex | SiamCafe.net
Shopping cart