PingOptions.DontFragment 屬性

定義

取得或設定 Boolean 值,控制是否要分割傳送到遠端主機的資料。

C#
public bool DontFragment { get; set; }

屬性值

如果無法以多個封包傳送資料則為 true,否則為 false。 預設為 false

範例

下列程式代碼範例示範如何使用建 PingOptions 構函式設定此屬性的值,然後顯示值。

C#
// 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);

備註

應用程式會使用這個屬性來控制類別傳送至遠端主機 Ping 的數據是否可以分割成多個封包。 如果您想要測試用來傳輸封包之路由器和閘道的最大傳輸單位 (MTU) ,此選項會很有用。 如果這個屬性是 true ,而且傳送至遠端主機的數據較大,則傳送者與遠端主機之間的閘道或路由器 MTU 會失敗,偵測作業會失敗,狀態為 PacketTooBig

適用於

產品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1