Monday, June 4, 2007

簡介ICMP

資料來源:http://www.ipv6.org.tw/rfc/chineseRFC2001-2500/2463.htm

1.Introduction
RFC 793和RFC 2463主要為制定ICMP(Internet Control Message Protocol)的Message format,RFC793適用於IPv4,RFC 2463適用於IPv6,ICMP是用來讓gateway或destination host能和source host通訊,如欲傳回資料處理發生錯誤的訊息,ICMP為架構在IP上為較高階層的protocol,而且和IP一樣,並不保證一定能無誤的傳送接收,它的作用為feedback problems給source host。同ICMP作用的ICMPv6,則是在IPv6上所使用。

2.Message format
2.1 ICMP
ICMP前八個bit為型態欄位,決定資料的格式,其他欄位內容如標示為unused,則為保留做近一步擴充使用,在傳送時需設為0,一般而言,header fields應包含下列幾項欄位。

-1. version 4
-2. IHL
Internet header length in 32-bit words.
-3. Type of Service 0
-4. Total Length
標頭和資料的長度(以byte為單位)
-5. Identification, Flags, Fragment Offset
-6. Time to Live
在每個機器處理資料時,將其值(單位為秒)減少,
所以其值至少須大於gateway的個數,資
料才能順
利通過
-7. Protocol 1
-8. Header Checksum
將header內所有的16 bit words取一的補數加總,
再取一的補數後置於此欄位,計算
checksum時,
本身欄位視為0。
-9. Source Address
組成ICMP的gateway or host的address
-10. Destination Address
訊息欲送往的gateway or host的address


以下將簡介ICMP包含幾種訊息

1. Destination Unreachable Message

Code:
0Net無法達到
1Host無法達到
2Protocol無法達到
3Port無法達到
4Fragmentation needed and DF set5Source route失敗

用法:
Ex1.
如network的distance趨近無限大,使資料的destination address無法送達,此時gateway可送destination unreachable message給source host.
Ex2.
如在destination host因indicated protocol module或process port無法動作,此時可送destination unreachable message給source host.

Ex3.
當datagram須分割傳送時,但Don’t Fragment flat is on,此時gateway必須忽略此datagram並傳回destination unreachable message.

2. Time Exceeded Message

Code:
0傳送時間超過time to live的時間
1超過分段集合的時間

用法:
Ex1.
當gateway發覺datagram的time to live欄位其值為0,此時須忽略此datagram,並傳送time exceeded message給source host.
Ex2.
當host由於missing fragments無法完成集合fragmented datagram,此時time exceeded message

3. Parameter Problem Message

Code: 0 = 由pointer表示錯誤所在

Pointer:
If code=0, 表示那個byte發生錯誤
用法:
Ex1.
當gateway或host處理datagram時,發現header parameters有問題,無法完成處理程序,此時須忽略此datagram,並傳送parameter problem message給source host.


4. Source Quench Message

用法:
Ex1.
當datagram到達速度比處理還快,destination host送出source quench message給source host
Ex2.
若gateway沒有buffer來queue the datagram,送出source quench message給source host
註.
source host收到source quench message即降低傳送速率,直到沒有再收到source quench message為止

5. Redirect Message

Code:
0Redirect datagram for the Network
1Redirect datagram for the Host
2Redirect datagram for the Type of Service and Network
3Redirect datagram for the Type of Service and Host

Gateway Internet Address :
Datagram欲傳送至Gateway的位址

用法:
Ex1.
gateway(G1)接收到由host傳送過來的datagram,由自身的routing table建立下一個gateway(G2)的位址,若G2和host的source address位於相同的網路上,即傳redirect message給host,通知host傳送datagram至destination network,G2是最短的路徑。

6. Echo or Echo Reply Message


Type:
0Echo replay message
8Echo message

Identifier:
幫助matching request and replies

Sequence Number:
幫助matching request and replies

用法:
當接收到echo message時,須回傳echo reply message

註:
1.the identifier might be used like a port in TCP to identify a session
2.the sequence number might be incremented on each echo request sent.
the echoer returns these same values in the echo reply.

7. Timestamp or Timestamp Reply Message

Type:
13timestamp message
14timestamp reply message

Identifier:
幫助matching timestamp and replies
Sequence Number:
幫助matching timestamp and replies
註:
Originate Timestamp: sender在傳送前最後touch message的時間
Receive Timestamp: echoer在接收時首先touch message的時間
Transmit Timestamp: echoer在傳送前最後touch message的時間
用法:
If the time is not available in milliseconds or cannot be provided with respect to
midnight UT then any time can be inserted in a timestamp.

8. Information Request or Information Reply Message

Type:
15information request message
16information reply message
用法:
This message may be sent with the source network in the IP header source and
destination address fields zero.The reply IP module should send the reply with
the address fully specified.

2.2 ICMPv6
general format:

Type: 表示訊息的型別,決定其他資料的格式
Code: 根據Type,為Message的附加階層
Checksum: 偵測ICMPv6 message或IPv6 header是否有損壞

以下將簡介ICMPv6包含幾種訊息

1.Destination Unreachable Message(Error Message)

Code:
0沒有路線到目的地
1目的地管理上的停止通訊
2無指定
3address無法達到
4port無法達到

用法:
Ex1.
假如無法傳送的原因是在forwarding node’s routing table缺少matching entry
Code=0

Ex2.
假如無法傳送的原因是administrative prohibition
Code=1

2.Packet Too Big Message (Error Message)

MTU: The Maximum Transmission Unit of the next-hop link.

用法:
Ex1.
當router的packet大小大於MTU時,以致無法繼續傳送,此時送出Packet
Too Big Message

3.Time Exceeded Message


Code:
0hop limit exceed in transmit
1fragment reassembly time exceeded

用法:
Ex1.
當router收到Hop Limit of zero的packet,須忽略此packet,並送出Time Exceeded Message,表示initial Hop Limit value太小或routing loop.

4.Parameter Problem Message (Error Message)

Code:
0erroneous header field encountered
1unrecognized Next Header type encountered
2unrecognized IPv6 option encountered

Pointer: 表示packet的那個byte發生錯誤

用法:
Ex1.當IPv6 node處理packet時,在IPv6 header or extension headers發現錯誤,即忽略此packet,並送出Parameter Problem Message,表示錯誤的位置和型別


5.Echo Request Message (Information Message)

Identifier: 幫助matching Echo Replies to this Echo Request
Sequence Number: 幫助matching Echo Replies to this Echo Request

用法:
node 實行Echo responder function,即收到Echo Requests,送出對應的Echo Replies

No comments: