<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FNetwork%2FNet_Mask</id>
		<title>Csharp/C Sharp/Network/Net Mask - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FNetwork%2FNet_Mask"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Net_Mask&amp;action=history"/>
		<updated>2026-04-29T17:48:27Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Net_Mask&amp;diff=1481&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Net_Mask&amp;diff=1481&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Net_Mask&amp;diff=1482&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Net_Mask&amp;diff=1482&amp;oldid=prev"/>
				<updated>2010-05-26T11:47:08Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Find net Mask==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Network Programming &lt;br /&gt;
by Richard Blum&lt;br /&gt;
Publisher: Sybex &lt;br /&gt;
ISBN: 0782141765&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Net;&lt;br /&gt;
using System.Net.Sockets;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class FindMask&lt;br /&gt;
{&lt;br /&gt;
   public static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      byte[] data = new byte[1024];&lt;br /&gt;
      int recv;&lt;br /&gt;
      Socket host = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Icmp);&lt;br /&gt;
      IPEndPoint iep = new IPEndPoint(IPAddress.Broadcast, 0);&lt;br /&gt;
      EndPoint ep = (EndPoint)iep;&lt;br /&gt;
      ICMP packet = new ICMP();&lt;br /&gt;
      packet.Type = 0x11;&lt;br /&gt;
      packet.Code = 0x00;&lt;br /&gt;
      packet.Checksum = 0;&lt;br /&gt;
      Buffer.BlockCopy(BitConverter.GetBytes(1), 0, packet.Message, 0, 2);&lt;br /&gt;
      Buffer.BlockCopy(BitConverter.GetBytes(1), 0, packet.Message, 2, 2);&lt;br /&gt;
      Buffer.BlockCopy(BitConverter.GetBytes(0), 0, packet.Message, 4, 4);&lt;br /&gt;
      packet.MessageSize = 8;&lt;br /&gt;
      int packetsize = packet.MessageSize + 4;&lt;br /&gt;
      UInt16 chksm = packet.getChecksum();&lt;br /&gt;
      packet.Checksum = chksm;&lt;br /&gt;
      host.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 3000);&lt;br /&gt;
      host.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, 1);&lt;br /&gt;
      host.SendTo(packet.getBytes(), packetsize, SocketFlags.None, iep);&lt;br /&gt;
      try&lt;br /&gt;
      {&lt;br /&gt;
         data = new byte[1024];&lt;br /&gt;
         recv = host.ReceiveFrom(data, ref ep);&lt;br /&gt;
      } catch (SocketException)&lt;br /&gt;
      {&lt;br /&gt;
         Console.WriteLine(&amp;quot;Unable to determine subnet mask for this subnet&amp;quot;);&lt;br /&gt;
         return;&lt;br /&gt;
      }&lt;br /&gt;
      ICMP response = new ICMP(data, recv);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Received ICMP Type {0} packet&amp;quot;, response.Type);&lt;br /&gt;
      long answer = BitConverter.ToUInt32(response.Message, 4);&lt;br /&gt;
      IPAddress netmask = new IPAddress(answer);&lt;br /&gt;
      Console.WriteLine(&amp;quot;The subnet mask for this subnet is: {0}&amp;quot;, netmask.ToString());&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
class ICMP&lt;br /&gt;
{&lt;br /&gt;
   public byte Type;&lt;br /&gt;
   public byte Code;&lt;br /&gt;
   public UInt16 Checksum;&lt;br /&gt;
   public int MessageSize;&lt;br /&gt;
   public byte[] Message = new byte[1024];&lt;br /&gt;
   public ICMP()&lt;br /&gt;
   {&lt;br /&gt;
   }&lt;br /&gt;
   public ICMP(byte[] data, int size)&lt;br /&gt;
   {&lt;br /&gt;
      Type = data[20];&lt;br /&gt;
      Code = data[21];&lt;br /&gt;
      Checksum = BitConverter.ToUInt16(data, 22);&lt;br /&gt;
      MessageSize = size - 24;&lt;br /&gt;
      Buffer.BlockCopy(data, 24, Message, 0, MessageSize);&lt;br /&gt;
   }&lt;br /&gt;
   public byte[] getBytes()&lt;br /&gt;
   {&lt;br /&gt;
      byte[] data = new byte[MessageSize + 9];&lt;br /&gt;
      Buffer.BlockCopy(BitConverter.GetBytes(Type), 0, data, 0, 1);&lt;br /&gt;
      Buffer.BlockCopy(BitConverter.GetBytes(Code), 0, data, 1, 1);&lt;br /&gt;
      Buffer.BlockCopy(BitConverter.GetBytes(Checksum), 0, data, 2, 2);&lt;br /&gt;
      Buffer.BlockCopy(Message, 0, data, 4, MessageSize);&lt;br /&gt;
      return data;&lt;br /&gt;
   }&lt;br /&gt;
   public UInt16 getChecksum()&lt;br /&gt;
   {&lt;br /&gt;
      UInt32 chcksm = 0;&lt;br /&gt;
      byte[] data = getBytes();&lt;br /&gt;
      int packetsize = MessageSize + 8;&lt;br /&gt;
      int index = 0;&lt;br /&gt;
      while ( index &amp;lt; packetsize)&lt;br /&gt;
      {&lt;br /&gt;
         chcksm += Convert.ToUInt32(BitConverter.ToUInt16(data, index));&lt;br /&gt;
         index += 2;&lt;br /&gt;
      }&lt;br /&gt;
      chcksm = (chcksm &amp;gt;&amp;gt; 16) + (chcksm &amp;amp; 0xffff);&lt;br /&gt;
      chcksm += (chcksm &amp;gt;&amp;gt; 16);&lt;br /&gt;
      return (UInt16)(~chcksm);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>