Hiểu TCP / IP Networking 385
cùng một thời gian (giống như hai người nói chuyện trên điện thoại). Hubs cho phép chỉ một nửa-duplex
truyền, trong đó hai máy tính phải thay phiên nhau (giống như hai người sử dụng
máy bộ đàm). Kết quả là công tắc cho hai cặp của máy tính tham gia vào toàn dữ liệu tốc độ
chuyển với nhau; với một trung tâm, hai chuyển những sẽ can thiệp với nhau.
Máy vi tính với Wi-Fi adapter có thể gured confi để giao tiếp trực tiếp với
nhau, nhưng nó phổ biến hơn để sử dụng một bộ định tuyến không dây, trong đó liên kết với nhau cả hai
thiết bị không dây và Ethernet. Định tuyến như vậy cũng cung cấp kết nối đến một bên ngoài
mạng thường là Internet, đôi khi thông qua một kết nối băng thông rộng.
Hiểu Mạng gói
mạng hiện đại hoạt động trên những phần rời rạc của các dữ liệu được gọi là các gói tin. Giả sử bạn muốn
gửi một 100KiB fi le từ máy này sang máy khác. Thay vì gửi các fi le trong một vụ nổ
của dữ liệu, máy tính của bạn phá vỡ nó xuống thành những phần nhỏ hơn. Hệ thống này có thể gửi 100
gói 1KiB nhau, ví dụ. Bằng cách này, nếu có một lỗi gửi một gói tin, các
máy tính có thể gửi lại chỉ là một gói tin thay vì toàn bộ fi le. (Nhiều mạng
giao thức bao gồm các thủ tục báo lỗi phát hiện.)
Khi hệ thống người nhận nhận được gói tin, nó phải giữ cho họ và sắp xếp chúng lại
theo thứ tự chính xác để tái tạo các luồng dữ liệu hoàn chỉnh. Nó không phải là hiếm đối với các gói tin
bị trì hoãn hoặc thậm chí bị mất trong truyền tải, do vậy các quy phục hồi lỗi rất quan trọng cho
các giao thức xử lý các giao dịch chuyển lớn. Một số loại khôi lỗi được xử lý một cách minh bạch
của các phần cứng mạng.
Có một số loại của các gói tin, và chúng có thể được lưu trữ trong mỗi khác. Ví
dụ, Ethernet bao gồm các loại của riêng mình gói (được biết đến như một khung hình), và các gói
được tạo ra bởi các giao thức chạy trên Ethernet, như được mô tả trong các mạng
phần tiếp theo, được lưu trữ trong khung Ethernet. Tất cả đã nói, một truyền dữ liệu có liên quan đến nhiều
lớp của gói dữ liệu và unwrapping. Với mỗi lớp, các gói dữ liệu từ các lớp kế cận
có thể sáp nhập hoặc chia tay.
Hiểu Network Protocol Stacks
Có thể suy nghĩ của dữ liệu mạng ở các cấp khác nhau của trừu tượng. Ví dụ, ở một
mức độ, một mạng mang các gói dữ liệu cho một loại mạng c specifi (như Ethernet); các dữ liệu
gói tin được gửi đến máy tính c specifi trên một mạng cục bộ. Một mô tả như vậy, trong khi
hữu ích cho sự hiểu biết một mạng cục bộ, không phải là rất hữu ích cho sự hiểu biết cấp trên
giao thức mạng, chẳng hạn như những người có thể xử lý chuyển email. Những giao thức cấp cao
thường được mô tả bằng các lệnh được gửi qua lại giữa các máy tính,
thường xuyên mà không tham chiếu đến các gói tin. Các địa chỉ được sử dụng ở các cấp độ khác nhau cũng khác nhau, như
đã giải thích trong phần sắp tới "Sử dụng địa chỉ mạng."
Một giao thức ngăn xếp là một tập hợp các phần mềm có thể chuyển đổi và đóng gói dữ liệu giữa các lớp
trừu tượng. Ví dụ, các ngăn xếp có thể mất các lệnh của giao thức chuyển thư điện tử,
và các tin nhắn email được chuyển giao, và gói chúng thành các gói. Một lớp
của ngăn xếp có thể có những gói dữ liệu và đóng gói chúng thành các khung Ethernet. Có
c08.indd 385 11/12/12 12:12
386 Chương 8 ■ Cấu hình mạng cơ bản
nhiều lớp vào bất kỳ giao thức ngăn xếp, và chúng tương tác trong cách ed cao specifi. Nó thường
có thể trao đổi trên một phần cho người khác ở bất kỳ lớp nào. Ví dụ, ở đầu
của mỗi ngăn xếp là một chương trình sử dụng stack, chẳng hạn như một máy khách email. Bạn có thể chuyển đổi
từ một ứng dụng email khác mà không cần quá nhiều gặp khó diffi; cả hai lại bên trên cùng
stack. Tương tự như vậy, nếu bạn thay đổi một card mạng, bạn phải thay đổi các trình điều khiển cho card,
tạo thành một lớp rất thấp trong ngăn xếp. Ứng dụng trên trình điều khiển mà có thể vẫn
giống nhau.
Mỗi máy tính trong một giao dịch đòi hỏi một giao thức ngăn xếp tương thích. Khi họ giao tiếp,
các máy tính truyền dữ liệu xuống ngăn xếp tương ứng của họ và sau đó gửi dữ liệu đến các
hệ thống đối tác, trong đó chuyển dữ liệu lên stack của nó. Mỗi lớp trên hệ thống nhận thấy
các dữ liệu như được đóng gói bởi đối tác của mình trên máy tính gửi đi.
Chồng giao thức thường được biểu diễn bằng đồ thị trong sơ đồ như hình 8.2, trong đó
cho thấy các guration confi của chồng giao thức TCP / IP mà thống trị Internet ngày nay. Như
thể hiện trong hình 8.2, khách hàng chương trình ở lớp ứng dụng khởi truyền dữ liệu. Những
yêu cầu đi qua các phương tiện giao thông, internet, và các lớp liên kết trên các máy tính của khách hàng,
và rồi họ rời khỏi hệ thống của khách hàng và chuyển cho các hệ thống máy chủ. (Chuyển giao này có thể
liên quan đến rất nhiều phức tạp không được mô tả trong hình 8.2.) Trên máy chủ, quá trình đảo ngược
bản thân, với chương trình máy chủ chạy ở lớp ứng dụng trả lời cho khách hàng
chương trình. Trả lời này đảo ngược hành trình, đi du lịch xuống các máy chủ máy tính của chồng, qua
mạng, và lên stack trên máy khách. A full-fl lưỡi kết nối mạng có thể liên quan đến
nhiều back-và-ra chuyển dữ liệu.
HÌNH 8.2 Thông tin đi "xuống" và "lên" ngăn xếp giao thức, được kiểm tra và
tái đóng gói tại mỗi bước của con đường.
Application
Transport
Internet
Liên kết
khách hàng
Trả lời
yêu cầu
ứng dụng
Giao thông vận tải
Internet
liên kết
máy chủ
c08.indd 386 11/12/12 12:12
Hiểu TCP / IP Networking 387
Khi viết với chữ viết hoa I, Internet từ đề cập đến các
mạng toàn cầu hạn các mạng mà bạn đang Không nghi ngờ gì quen thuộc.
Khi viết với một chữ thường tôi, tuy nhiên, internet từ đề cập đến bất kỳ
bộ sưu tập của các mạng. An internet theo nghĩa này có thể là một cặp vợ chồng của
các mạng nhỏ trong tầng hầm của ai đó không có kết nối bên ngoài.
Giao thức mạng Internet như TCP / IP có thể làm việc trên bất kỳ internet, lên
đến và bao gồm cả Internet.
Mỗi lớp thành phần của hệ thống gửi là tương đương để một lớp trên tiếp nhận
hệ thống, nhưng các lớp không cần phải hoàn toàn giống hệt nhau. Ví dụ, bạn có thể có khác nhau
mô hình của card mạng ở tầng liên kết, hoặc thậm chí bạn có thể sử dụng mạng hoàn toàn khác nhau
các loại phần cứng, chẳng hạn như Ethernet và Token Ring, nếu một số hệ thống can thiệp dịch
giữa chúng. Các máy tính có thể chạy các HĐH khác nhau và do đó sử dụng khác nhau, nhưng một cách hợp lý
ngăn xếp tương đương với giao thức. Điều quan trọng là các ngăn xếp hoạt động theo cách tương thích.
Linux được thiết kế với giao thức TCP / IP trong tâm trí, và Internet được xây dựng trên đỉnh TCP / IP. Khác
ngăn xếp giao thức có sẵn, mặc dù, và bạn có thể thỉnh thoảng chạy vào chúng. Đặc biệt,
NetBEUI là bản gốc của Microsoft và IBM chồng giao thức cho Windows, AppleTalk
là của Apple ban đầu giao thức ngăn xếp, và / giải mã trình tự Packet Internet Packet Trao đổi
Exchange (IPX / SPX) là Novell ưa thích giao thức ngăn xếp. Tất cả ba đang mờ dần trong
tầm quan trọng, nhưng bạn vẫn có thể cần phải sử dụng chúng trong một số môi trường. Linux hỗ trợ
AppleTalk và IPX / SPX nhưng không NetBEUI.
Biết TCP / IP Giao thức loại
Trong TCP / IP, các giao thức khác nhau tồn tại. Mỗi một trong các giao thức có thể được ed classifi
như rơi vào một trong bốn lớp của TCP / IP stack, như thể hiện trong hình 8.2. Nhất
quan trọng của trên internet và lớp vận chuyển giao thức là các khối xây dựng cho các
giao thức tầng ứng dụng mà bạn tương tác trực tiếp hơn. Những quan trọng
trên internet và lớp vận chuyển giao thức bao gồm những điều sau đây:
IP Internet Protocol (IP) là giao thức cốt lõi trong mạng TCP / IP. Đề cập đến
hình 8.2, IP là một lớp internet (aka một lớp mạng hoặc lớp 2) giao thức. IP cung cấp
một "nỗ lực tốt nhất" phương pháp để chuyển các gói dữ liệu giữa các máy tính, nghĩa là, các gói tin
không được đảm bảo để đạt được điểm đến của họ. Các gói tin cũng có thể đến không theo thứ tự hoặc
bị hỏng. Các thành phần khác của giao thức TCP / IP stack phải đối phó với những vấn đề này và có
cách riêng để làm như vậy. IP cũng là một phần của TCP / IP với các địa chỉ IP được
kết hợp. (The Real World Scenario sidebar "The Coming of IPv6" mô tả một sự thay đổi trong
phần IP của TCP / IP đó là tiến hành.)
ICMP Internet Control Message Protocol (ICMP) là một giao thức đơn giản để giao tiếp
dữ liệu. ICMP được sử dụng nhiều nhất để gửi các thông báo lỗi giữa các máy tính-ví dụ, để
báo hiệu rằng một dịch vụ yêu cầu không có sẵn. Điều này thường được thực hiện bằng cách thay đổi một gói tin IP
và trả lại cho người gửi, có nghĩa là ICMP là kỹ thuật một lớp internet
c08.indd 387 11/12/12 12:12
388 Chương 8 ■ Cấu hình mạng cơ bản
giao thức, mặc dù nó dựa trên IP. Trong hầu hết các trường hợp, bạn sẽ không sử dụng chương trình mà tạo ra
các gói tin ICMP theo yêu cầu; họ đang tạo ra đằng sau hậu trường khi bạn sử dụng các giao thức khác.
Một ngoại lệ là các chương trình ping, được mô tả chi tiết hơn trong "Thử nghiệm cơ bản
kết nối."
UDP Các User Datagram Protocol (UDP) là đơn giản nhất của việc vận chuyển lớp phổ biến
(aka lớp 3) giao thức TCP / IP. Nó không cung cấp các thủ tục phức tạp để sửa chữa cho
out-of-order gói, đảm bảo giao hàng, hoặc nếu không cải thiện những hạn chế của IP. Điều này
thực tế có thể là một vấn đề, nhưng nó cũng có nghĩa là UDP có thể được nhanh hơn phức tạp hơn
công cụ cung cấp những cải tiến đó để IP. Các giao thức tầng ứng dụng phổ biến được
xây dựng trên đỉnh UDP bao gồm các hệ thống tên miền (DNS), các Network File System (NFS),
và nhiều tuyến giao thức truyền thông.
TCP The Transmission Control Protocol (TCP) có thể là transportlayer sử dụng rộng rãi nhất
giao thức trong giao thức TCP / IP stack. Không giống như UDP, TCP tạo ra các kết nối đầy đủ với lỗi
kiểm tra và điều chỉnh cũng như tính năng khác. Những tính năng đơn giản hóa việc tạo ra các
giao thức mạng mà phải trao đổi một lượng lớn dữ liệu, nhưng các tính năng đến tại một
chi phí: TCP áp đặt một hình phạt hiệu quả nhỏ. Hầu hết các giao thức lớp ứng dụng
mà bạn có thể đã quen thuộc, bao gồm các Simple Mail Transfer Nghị định thư
(SMTP), Hypertext Transfer Protocol (HTTP), và File Transfer Protocol (FTP),
được xây dựng trên đỉnh TCP.
Bạn có thể nhận thấy rằng tên của giao thức TCP / IP phải được xây dựng của hai trong ngăn xếp của
tên giao thức: TCP và IP. Điều này là bởi vì hai giao thức này
đang được dịch, vui lòng đợi..