簡介OSI模型

Download Report

Transcript 簡介OSI模型

簡介OSI模型 (OSI model)
•
•
•
•
•
•
•
第七層,應用層 (Application Layer)
第六層,展現層 (Presentation Layer
第五層,會談層 (Session Layer)
第四層,傳輸層 (Transport Layer)
第三層,網路層 (Network Layer)
第二層,資料鏈結層 (Data Link Layer)
第一層,實體層 (Physical Layer)
Crickstudy Authentication Institute
Crickstudy Authentication Institute
PDU
PDU (Protocol Data Unit;通訊協定資料單位): 各層封包最小單位。它會在各層的
封包上加入表頭 (header)。
Crickstudy Authentication Institute
OSI模型封裝 / 解封裝 (Encapsulation
/ Decapsulation)
Crickstudy Authentication Institute
簡介TCP
• TCP (Transmission Control Protocol;傳輸控制定),它最
早是由美國國防部的 DoD model所 (Department Of
Defense) 衍生出來的,主要的功能是為了確保資料的
完整性。
• TCP的特性及功能很大,也很複雜,同學常背不起來,
但只要記得 TCP,的全名中的 Control,它就是整個
TCP的核心了。
Crickstudy Authentication Institute
TCP/IP各層與OSI模型對照如下
Crickstudy Authentication Institute
TCP的特性
•
•
•
•
•
多工 (Multiplexing using ports)
錯誤修正 (Error recovery (reliability))
流量控制 (Flow control using windowing)
連結導向 (Connection establishment and termination)
資料排序 (Ordered data transfer and data segmentation)
Crickstudy Authentication Institute
TCP建立連結
• 建立連線期 (connection phase)
• 資料傳送期 (data transfer phase)
• 終止期 (disconnection phase)
Crickstudy Authentication Institute
TCP / UDP 比較表
• UDP 可提供非連線式的封包服務,此服務提供最有效率的傳送,意思是
UDP 不保證傳送的結果及確認封包的順序。若需要進行可靠的通訊必須
使用 TCP。
Crickstudy Authentication Institute
公開連接埠
(Well-Known Port Numbers)
Crickstudy Authentication Institute
簡介IPv4
• IPv4位址由全長32位元 (bits)的二進位數字表示 (0 or 1),
這32位元經小圓點 (.)又分為4組 (X.X.X.X),每一組包
含8個位元。11111111.11111111.11111111.11111111。
• 但是我們習慣使用十進位表示數字,所以,用十進位
來表示每組8位元的十進位數字,範圍是從0~255
(00000000 to 11111111)。
• 例如:二進位: 11000000. 10101000.00000001.000000010
用十進位表示為192.168.1.2。
Crickstudy Authentication Institute
IPv4組成
• Question ?
Crickstudy Authentication Institute
IPv4組成
• IPv4組成又可分為兩部份組成,前面部份稱網路位址
(network) ,後面部份稱主機位址(host)。網路位址用於
表示此IP所隸屬的網路;主機位址用於表示此網路上
特定的主機位址,必需是唯一的位址。
• 例如:140.116.1.2 (10001100.
1110100.00000001.000000010)。
• 140.116 (10001100. 1110100) 表示network部份 (140 表
示教育單位,116表示成功大學 );0.0.1.2
(00000001.000000010) 表示host部份 (0.0.1表示某一部
門,0.0.0.2表示此部門內特定主機位址)。
Crickstudy Authentication Institute
同一個網段 ??
• Question ?
Crickstudy Authentication Institute
同一個網段 ??
• 常有人問說:這兩個IP位址可不可以直接傳送資料,
表示問你它們是不是在同一個網段內,只要判斷它們
的網路位址都相同就表示位於同一個網段內。
Crickstudy Authentication Institute
IP位址基礎概念及知識
• 每一個主機都具有獨一無二的IP位址
• IP位址是一種虛擬 (logical)的地址並不是實體 (physical)
的地址
• 每一個IP位址被分配在電腦的網路介面 (interface)內,
並不是電腦本身
Crickstudy Authentication Institute
十進位 (decimal)、二進位 (binary) 與
十六進位 (hexadecimal)的轉換及運算
Crickstudy Authentication Institute
二進位轉換成十進位
• 將二進位數字從右到左表示20 到 27。再將二進位中表示為 (1)
的十進位的數字全部加總,即為十進位數字。
Crickstudy Authentication Institute
十進位轉換成二進位
29 >> ???
Crickstudy Authentication Institute
十進位轉換成二進位
Crickstudy Authentication Institute
二進位轉換成十六進位
• 11110000
• 11010110
• 00011100
Crickstudy Authentication Institute
二進位轉換成十六進位
• 將二進位從最右處每四個位元代表十六
進位的一個位數,分成兩組即可轉換。
• 例如:11110000, 11010110, 00011100
Crickstudy Authentication Institute
小測試
• Q1:你想要轉換此二進位數字 (11010011) 變成十進位
及十六進位數字,以下何者為正確答案。
•
•
•
•
•
•
A. 123
B. 0xD3
C. 146
D. 211
E. 0xF9
F. 0x9A
答案:B、D
Crickstudy Authentication Institute
小測試
•
•
•
•
•
•
Q2:請問此二進位數字 (00001111) 的十進位數字為何?
A. 10
B. 12
C. 14
答案:D
D. 15
E. 16
Crickstudy Authentication Institute
小測試
• Q3:下列何者為此十進位數字 (215) 的二進位表示法?
•
•
•
•
•
A. 11011011
B. 11110011
C. 11010111
D. 11111001
E. 11010011
答案:C
Crickstudy Authentication Institute
IPv4 Networks (IPv4分類;class)
Crickstudy Authentication Institute
A, B, C三類在未切割子網路情況下的基
本關係
Crickstudy Authentication Institute
A類網路位址
• 在A類網路中,network內第一個位元 (從右到左) 被設
定為0 (off),最高位元為0。
但network全為 0 的位址是被保留當成廣播位址 (broadcast address) 或當成默認路
由,同時 127 的位址也被保留當成回送位址 (loopback address)。因此實際上A類
位址範圍為1 ~ 126,共126個可用IP位址。每個A類網路中最多可容納2242=16777214台主機。
Crickstudy Authentication Institute
50.22.32.34
• 網路位址(network) >> ?? 50
• 主機位址(host) >> ??
22.32.34
Crickstudy Authentication Institute
如何判斷A類網路位址有效的主機IP
• 所有的主機位元都設為off (0),所得到的位址是網路位
址11.0.0.0。
• 所有的主機位元都設為on (1),所得到的位址是廣播位
址11.255.255.255。
• 則所有合法的主機IP是介於網路位址和廣播位址之問
的IP位址,就是11.0.0.1到11.255.255.254之間的位址。
• 所以要找出合法主機位址的時候,需要注意的是,主
機位元的二進位數字是不可以同時被全部設為off (0)或
全部設為on (1)的。
Crickstudy Authentication Institute
B類網路位址
• 在B類網路中,network內第一個位元 (從右到左)被設定為1
(on),第二個位元被設定為0 (off),最高位元為10。
B類的network的範圍為10000000 ~ 10111111對應到十進位為: 128 ~ 191。每
個B類網路中最多可容納216- 2=65534台主機。
Crickstudy Authentication Institute
172.17.32.34
• 網路位址(network) >> ?? 172.17
• 主機位址(host) >> ??
32.34
Crickstudy Authentication Institute
如何判斷B類網路位址有效的主機IP
• 所有的主機位元都設為off (0),所得到的位址是網路位
址172.16.0.0。
• 所有的主機位元都設為on (1),所得到的位址是廣播位
址172.16.255.255。
• 則所有合法的主機IP是介於網路位址和廣播位址之問
的IP位址,就是172.16.0.1到172.16.255.254之間的位址。
Crickstudy Authentication Institute
C類網路位址
• 在C類網路中,network內前兩個位元 (從右到左)被設定為
1 (on),第三個位元被設定為0 (off),最高位元為110。所
以,C類的network的範圍為11000000 ~ 11011111對應到十
進位為: 192 ~ 223。每個C類網路中最多可容納28- 2= 254
台主機。
Crickstudy Authentication Institute
192.168.32.34
• 網路位址(network) >> ?? 192.168.32
• 主機位址(host) >> ??
34
Crickstudy Authentication Institute
如何判斷C類網路位址有效的主機IP
• 所有的主機位元都設為off (0),所得到的位址是網路位
址192.168.110.0。
• 所有的主機位元都設為on (1),所得到的位址是廣播位
址192.168.110.255。
• 則所有合法的主機IP是介於網路位址和廣播位址之問
的IP位址,就是192.168.110.1到192.168.110.254之間的
位址。
Crickstudy Authentication Institute
IPv4 Networks (IPv4分類;class)
Crickstudy Authentication Institute