Example #1
0
        private void GetWingParameters()
        {
            N  = Int16.Parse(txt_Segments.Text);
            AR = Double.Parse(txt_AR.Text);

            B = new Double[N, N];

            txt_Sw.Text = S_w.ToString();
            tr_w        = Double.Parse(txt_Taper.Text);

            b_w = Math.Round(Math.Sqrt(AR * S_w), 4);
            txt_WingSpan.Text = b_w.ToString();

            MAC          = Math.Round(S_w / b_w, 4);
            txt_MAC.Text = MAC.ToString();

            cr_w = Math.Round((1.5 * MAC * (1 + tr_w)) / (1 + tr_w + Math.Pow(tr_w, 2)), 4);
            txt_RootChord.Text = cr_w.ToString();

            i_w = Double.Parse(txt_WingSetting.Text);

            alpha0 = Double.Parse(txt_Zerolift.Text);

            a_2d = Double.Parse(txt_LiftCurve.Text);

            alpha_twist = Double.Parse(txt_Twist.Text);
        }
Example #2
0
            public void SameObject()
            {
                Byte[] b = new byte[]
                {
                    255,
                    255,
                    255,
                    255,
                    255,
                    255
                };

                MAC m = new MAC(b);

                Assert.Equal("FF:FF:FF:FF:FF:FF", m.ToString());
            }
        public XmlElement Save(XmlDocument XmlDoc)
        {
            XmlElement NameElement = XmlDoc.CreateElement("Name");

            NameElement.InnerText = Name;

            XmlElement IpElement = XmlDoc.CreateElement("IP");

            IpElement.InnerText = IP.ToString();

            XmlElement MacElement = XmlDoc.CreateElement("MAC");

            MacElement.InnerText = MAC.ToString();

            XmlElement VlanElement = XmlDoc.CreateElement("VLAN");

            VlanElement.InnerText = VLAN.ToString();

            XmlElement ArpServiceElement = XmlDoc.CreateElement("ARP");

            ArpServiceElement.InnerText = ArpServiceSupport.ToString();

            XmlElement IcmpServiceElement = XmlDoc.CreateElement("ICMP");

            IcmpServiceElement.InnerText = IcmpServiceSupport.ToString();

            XmlElement TcpServiceElement = XmlDoc.CreateElement("TCP");

            TcpServiceElement.InnerText = TcpServiceSupport.ToString();

            XmlElement ServiceElement = XmlDoc.CreateElement("Services");

            ServiceElement.AppendChild(ArpServiceElement);
            ServiceElement.AppendChild(IcmpServiceElement);
            ServiceElement.AppendChild(TcpServiceElement);

            XmlElement AdapterElement = XmlDoc.CreateElement("VirtualAdapter");

            AdapterElement.AppendChild(NameElement);
            AdapterElement.AppendChild(IpElement);
            AdapterElement.AppendChild(MacElement);
            AdapterElement.AppendChild(VlanElement);
            AdapterElement.AppendChild(ServiceElement);

            return(AdapterElement);
        }
Example #4
0
        static void Main(string[] args)
        {
            {
                Console.WriteLine("NSHG.IP");
                IP ip0 = new IP(new Byte[] { 0, 0, 0, 0 });
                Output(ip0.Equals(ip0), "ip.Equals (Identical)");

                Console.WriteLine("NSHG.IP");
                IP ip1234  = new IP(new Byte[] { 1, 2, 3, 4, 5 }, 0);
                IP ip12342 = new IP(new Byte[] { 1, 2, 3, 4 });
                Output(ip12342.Equals(ip1234), "ip.from array size > 4");


                IP ip255  = new IP(new Byte[] { 255, 255, 255, 255 });
                IP ip2552 = new IP(new Byte[] { 255, 255, 255, 255 });
                Output(ip255.Equals(ip2552), "ip.Equals (Non Identical)");

                IP ip3 = new IP(new Byte[] { 0, 0, 0, 0 });
                Output(ip0.Equals(ip3), "ip.Equals (Non Identical)");

                IP ip4 = new IP(new Byte[] { 0, 0, 0, 1 });
                Output(!ip0.Equals(ip4), "ip.Equals (Non Identical, Not Equal)");

                // Parse
                // Normal Parse's
                IP ip5   = IP.Parse("192.168.1.1");
                IP ip192 = new IP(new Byte[] { 192, 168, 1, 1 });
                Output(ip5.Equals(ip192), "ip.Parse(\"192.168.1.1\")");

                ip5 = IP.Parse("0.0.0.0");
                Output(ip5.Equals(ip0), "ip.Parse(\"0.0.0.0\")");

                ip5 = IP.Parse("255.255.255.255");
                Output(ip5.Equals(ip255), "ip.Parse(\"255.255.255.255\")");


                // Address Segments > 255
                bool result = false;
                try
                {
                    IP ip = IP.Parse("256.256.256.256");
                }
                catch (OverflowException)
                {
                    result = true;
                }
                finally
                {
                    Output(result, "IP.Parse (Overflow)");
                }

                // Null Input
                result = false;
                try
                {
                    IP ip = IP.Parse("");
                }
                catch (ArgumentNullException)
                {
                    result = true;
                }
                finally
                {
                    Output(result, "IP.Parse (Null)");
                }

                // Not Enough Segments
                result = false;
                try
                {
                    IP ip = IP.Parse("1");
                }
                catch (ArgumentOutOfRangeException)
                {
                    result = true;
                }
                finally
                {
                    Output(result, "IP.Parse (1)");
                }
                result = false;
                try
                {
                    IP ip = IP.Parse("1.1");
                }
                catch (ArgumentOutOfRangeException)
                {
                    result = true;
                }
                finally
                {
                    Output(result, "IP.Parse (1.1)");
                }
                result = false;
                try
                {
                    IP ip = IP.Parse("1.1.1");
                }
                catch (ArgumentOutOfRangeException)
                {
                    result = true;
                }
                finally
                {
                    Output(result, "IP.Parse (1.1.1)");
                }
            }// IP

            {
                MAC m = new MAC(new Byte[] { 255, 255, 255, 255, 255, 255 });

                m = MAC.Parse("FF:FF:FF:FF:FF:00");
                Console.WriteLine(m.ToString());
                foreach (Byte b in m.ToBytes())
                {
                    Console.WriteLine(b);
                }
            }// MAC

            {
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();

                byte[] expected, actual;

                expected = new byte[]
                {
                    0x45, 0x00, 0x00, 0x28, 0x6e, 0x9c, 0x40, 0x00, 0x80, 0x06, 0x77, 0xd7, 0x0a, 0x90, 0xe3, 0x64, 0x28, 0x43, 0xfe, 0x24
                };

                IPv4Header ipv4 = new IPv4Header(0x6E9C, true, false, 128, (IPv4Header.ProtocolType) 6, IP.Parse("10.144.227.100"), IP.Parse("40.67.254.36"), new byte[0], new byte[20]);



                actual = ipv4.ToBytes();

                foreach (byte b in expected)
                {
                    Console.Write(b.ToString("X"));
                    Console.Write(" ");
                }
                Console.WriteLine();


                foreach (byte b in actual)
                {
                    Console.Write(b.ToString("X"));
                    Console.Write(" ");
                }
                Console.WriteLine();
            }// IP  Header

            {
            }// TCP Header


            Console.ReadLine();
        }