Beispiel #1
0
 public static IpPacket RandomPacket(IpVersion version)
 {
     if (version == IpVersion.IPv4)
     {
         return(IPv4Packet.RandomPacket());
     }
     if (version != IpVersion.IPv6)
     {
         throw new InvalidOperationException("Unknown version of " + version);
     }
     return(IPv6Packet.RandomPacket());
 }
Beispiel #2
0
        /// <summary>
        ///     Generate a random packet of a specific ip version
        /// </summary>
        /// <param name="version">
        ///     A <see cref="IpVersion" />
        /// </param>
        /// <returns>
        ///     A <see cref="IpPacket" />
        /// </returns>
        public static IpPacket RandomPacket(IpVersion version)
        {
            Log.DebugFormat("version {0}", version);

            if (version == IpVersion.IPv4)
            {
                return(IPv4Packet.RandomPacket());
            }
            if (version == IpVersion.IPv6)
            {
                return(IPv6Packet.RandomPacket());
            }
            throw new InvalidOperationException("Unknown version of " + version);
        }