PingOptions.Ttl 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定可在資料丟棄前轉發 Ping 的路由節點數量。
public:
property int Ttl { int get(); void set(int value); };
public int Ttl { get; set; }
member this.Ttl : int with get, set
Public Property Ttl As Integer
屬性值
一個 Int32 指定資料封包可轉發次數 Ping 的值。 預設值為 128。
例外狀況
設定的集合運算值小於或等於零。
範例
以下程式碼範例示範如何使用 PingOptions 建構子設定此屬性的值,然後顯示該值。
// Set options for transmission:
// The data can go through 64 gateways or routers
// before it is destroyed, and the data packet
// cannot be fragmented.
PingOptions options = new PingOptions (64, true);
Console.WriteLine ("Time to live: {0}", options.Ttl);
Console.WriteLine ("Don't fragment: {0}", options.DontFragment);
備註
當閘道器和路由器透過網路傳送封包時,會遞減封包標頭中目前的存活時間(TTL)值。 若 TTL 值歸零,封包視為無法投遞並丟棄。 如果你想測試用來傳輸資料的路由器和閘道器數量,這個選項很有用。