CƠ BẢN VỀ MẠNG MÁY TÍNH2 Khái niệm • Tập hợp các máy tính kết nối với...
Transcript of CƠ BẢN VỀ MẠNG MÁY TÍNH2 Khái niệm • Tập hợp các máy tính kết nối với...
CƠ BẢN VỀ MẠNG MÁY TÍNH
2
Khái niệm
• Tập hợp các máy tính kết nối với nhau dựa trên một kiến trúc nào đó để có thể trao đổi dữ liệu • Máy tính: máy trạm, máy chủ, bộ định tuyến
• Kết nối bằng một phương tiện truyền • Theo một kiến trúc mạng
• Các dạng máy tính?
3
Kiến trúc mạng
• Kiến trúc mạng: Hình trạng (topology) và giao thức (protocol)
• Hình trạng mạng • Trục (Bus), Vòng (Ring), Sao (Star)… • Thực tế là sự kết hợp của nhiều hình trạng khác nhau
4
Giao thức là gì?
Giao thức người-người
yêu cầu
trả lời
request
response
Hi
Hi
Anh cho hỏi mấy giờ rồi ạ?
2:00
Thời gian
Giao thức máy-máy
5
Giao thức mạng
• Protocol: Quy tắc để truyền thông • Gửi một yêu cầu hoặc thông tin • Nhận một thông tin hoặc yêu cầu hành động • Các yêu cầu, thông tin được gửi dưới dạng các thông điệp
• Định nghĩa • khuôn dạng dữ liệu, thông điệp • thứ tự truyền, nhận thông điệp giữa các thực thể trên mạng • các hành động tương ứng khi nhận được thông điệp
• Ví dụ về giao thức mạng: TCP, UDP, IP, HTTP, Telnet, SSH, Ethernet, …
OSI and TCP/IP models OSI model TCP/IP model
Session layer
Transport layer
Application layer
Presentation layer
Network layer
Datalink layer
Physical layer
Transport layer
Application
HTTP, FTP, SMTP…
Network layer
Datalink layer
Physical layer
7
Chức năng chung của các tầng • Vật lý: Truyền bits “trên đường truyền” • Liên kết dữ liệu: Truyền dữ liệu giữa các thành
phần nối kết trực tiếp trong một mạng • Mạng: Chọn đường, chuyển tiếp gói tin từ nguồn đến đích
• Giao vận: Xử lý việc truyền-nhận dữ liệu cho các ứng dụng
• Phiên: đồng bộ hóa, check-point, khôi phục quá trình trao đổi
• Trình diễn: cho phép các ứng dụng biểu diễn dữ liệu, e.g., mã hóa, nén, chuyển đổi…
• Ứng dụng: Hỗ trợ các ứng dụng trên mạng.
application
presentation
session
transport
network
data link
physical
OSI and TCP/IP models • OSI model: reference model • TCP model: Internet model
• Transport layer: TCP/UDP • Network layer: IP + routing protocols.
Internet protocols mapping on TCP/IP DNS SMTP DHCP HTTP SNMP FTP
UDP TCP
IP
Ethernet FDDI PPP DSL ARP
Copper Optical Radio PSTN
...
...
...
ICMP RIP OSPF
Aplication
Transport
Network
Data link
Physical
...
OSI and TCP/IP models • Layering Makes it Easier • Application programmer
• Doesn’t need to send IP packets • Doesn’t need to send Ethernet frames • Doesn’t need to know how TCP implements reliability
• Only need a way to pass the data down • Socket is the API to access transport layer functions
IP • IP: Internet Protocol
• Forward data packet between distance network nodes (routers or hosts)
• Using routing table built by routing protocols such as OSPF, RIP …
• IP address • Is assigned to each network interface • IP v4: 32 bits
• 133.113.215.10 • IP v6: 128 bits
• 2001:200:0:8803::53
• A host may have a domain name • Conversion IP <-> domain name: DNS • Ex: soict.hust.edu.vn <--> 202.191.56.65
IP packet
12
ver length
32 bits
data (variable length, typically a TCP
or UDP segment)
16-bit identifier header
checksum time to
live
32 bit source IP address
IP protocol version number
header length (bytes)
max number remaining hops
(decremented at each router)
for fragmentation/ reassembly
total datagram length (words)
upper layer protocol to deliver payload to
head. len DS
QoS support
flgs fragment offset
upper layer
32 bit destination IP address Options (if any) E.g. timestamp,
record route taken, specify list of routers to visit.
Transport layer: Mux/Demux
13
Multiplexing Demultiplexing
Network layer protocol
HTTP FTP Chat HTTP FTP Chat
Transport layer protocol
Application protocol
Transport layer: Mux/Demux • How data from different
applications between two hosts can be delivered to right application? • Each application process is
assigned a transport port (16 bits) • Application sends data to the
transport layer through the port. • Socket:
• Application access point for application
• It is a combination of (Address IP, transportnport)
14
source port # dest port # 32 bits
Application data (message)
other header fields
TCP/UDP segment format
Transport layer: UDP • MUX/DeMUX • Best effort • Connectionless • Send independent datagrams • Drop error datagrams • No congestion control
source port # dest port #
32 bits
Application data (message)
length checksum
Transport layer: TCP
16
source port # dest port #
32 bits
application data (variable length)
sequence number acknowledgement number
Receive window
Urg data pnter checksum F S R P A U head
len not used
Options (variable length)
URG: Urgent data
ACK: ACK #
RST, SYN, FIN packet - For flow control - In Byte
-For reliable transmission - In Byte
Transport layer: TCP • Connection oriented protocol
• 3-step connection opening
• Reliable protocol • Re-transmission on error
• Flow control • Congestion control
A B
SYN
ACK
ACK/SYN
Network application models • Client/Server • Peer-to-peer • Hybrid
18
Client server model • Client
• Request services from Server
• Clients do not contact directly each other
• Server • “Always” online waitng for
requests from Clients • Ex: Web, Mail, …
19
client
client
client
client
Server
Pure Peer to Peer • No central server • Peers have equal role • Peers can communicate directly to each other
• Peers do not need to be always online
• E.g. Gnutella, Emule
20
Peer Peer
Peer
Peer Peer
Peer
Hybrid model
• Central server manages user accounts, authentification, stores data for searching process …
• Clients communicate directly after authentication process.
• E.g. Skype • Server manages login
process. • Messages, voices are
transmitted directly between servers.
21
Server
Client
Client
Client
Client-Server Comm.
P2P Comm.