public static ProtocalStatByLayer getProtocalStatByLayerInfo() { serviceStackDBHelper = ServiceStackDBHelper.getInstance(); ProtocalStatByLayer protocalStatByLayer = serviceStackDBHelper.ProtocalStatisticsByLayers(); return(protocalStatByLayer); }
//协议分级统计 public ProtocalStatByLayer ProtocalStatisticsByLayers() { string sql = Globals.sqlToString("ProtocalByLayer.sql"); ProtocalStatByLayer results = null; using (db = dbFactory.Open()) { try { results = db.Single <ProtocalStatByLayer>(sql); } catch (Exception) { } } return(results); }
public void LoadData() { TreeListModel = null; TreeRoot = new TreeModelRoot(); TreeRoot.IsBatchLoading = true; protocalStatByLayer = ProtocalStatisticsWindow.getProtocalStatByLayerInfo(); if (protocalStatByLayer != null) { //frame ProtocalStatisticsTreeModel frame = new ProtocalStatisticsTreeModel() { DisplayName = "Frame", Protocal = "Frame", PacketPercent = 100.0, PacketNum = protocalStatByLayer.LinkNum, BytesPercent = 100.0, Bytes = protocalStatByLayer.FrameSum, bps = Math.Round(protocalStatByLayer.FrameSum / protocalStatByLayer.Duration, 3) }; //ethernet ProtocalStatisticsTreeModel ethernet = new ProtocalStatisticsTreeModel() { DisplayName = "Ethernet", Protocal = "Ethernet", PacketPercent = 100.0, PacketNum = protocalStatByLayer.LinkNum, BytesPercent = Math.Round(protocalStatByLayer.LinkHeadSum * 100 / (double)protocalStatByLayer.FrameSum, 2), Bytes = protocalStatByLayer.LinkHeadSum, bps = Math.Round(protocalStatByLayer.LinkHeadSum / protocalStatByLayer.Duration, 3) }; //ipv4 ProtocalStatisticsTreeModel ipv4 = new ProtocalStatisticsTreeModel() { DisplayName = "Internet Protocal Version 4", Protocal = "Internet Protocal Version 4", PacketPercent = Math.Round(protocalStatByLayer.IpV4Num * 100 / (double)protocalStatByLayer.LinkNum, 2), PacketNum = protocalStatByLayer.IpV4Num, BytesPercent = Math.Round(protocalStatByLayer.IpV4HSum * 100 / (double)protocalStatByLayer.FrameSum, 2), Bytes = protocalStatByLayer.IpV4HSum, bps = Math.Round(protocalStatByLayer.IpV4HSum / protocalStatByLayer.Duration, 3) }; //ipv4-tcp ProtocalStatisticsTreeModel ipv4tcp = new ProtocalStatisticsTreeModel() { DisplayName = "Transmisson Control Protocol", Protocal = "Transmisson Control Protocol", PacketPercent = Math.Round(protocalStatByLayer.IpV4TCPNum * 100 / (double)protocalStatByLayer.IpV4Num, 2), PacketNum = protocalStatByLayer.IpV4TCPNum, BytesPercent = Math.Round(protocalStatByLayer.IpV4TCPHSum * 100 / (double)protocalStatByLayer.IpV4TSum, 2), Bytes = protocalStatByLayer.IpV4TCPHSum, bps = Math.Round(protocalStatByLayer.IpV4TCPHSum / protocalStatByLayer.Duration, 3) }; ////ipv4-tcp-H //ProtocalStatisticsTreeModel ipv4tcpH = new ProtocalStatisticsTreeModel() //{ // DisplayName = "Header", // Protocal = "Header", // PacketPercent = protocalStatByLayer.IpV4TCPNum / (double)protocalStatByLayer.IpV4Num, // PacketNum = protocalStatByLayer.IpV4TCPNum, // BytesPercent = protocalStatByLayer.IpV4TCPHSum / (double)protocalStatByLayer.IpV4TSum, // Bytes = protocalStatByLayer.IpV4TCPHSum, // bps = protocalStatByLayer.IpV4TCPHSum / protocalStatByLayer.Duration //}; ////ipv4-tcp-DATA //ProtocalStatisticsTreeModel ipv4tcpdata = new ProtocalStatisticsTreeModel() //{ // DisplayName = "Data", // Protocal = "Data", // PacketPercent = protocalStatByLayer.IpV4TCPNum / (double)protocalStatByLayer.IpV4Num, // PacketNum = protocalStatByLayer.IpV4TCPNum, // BytesPercent = protocalStatByLayer.IpV4TCPHSum / (double)protocalStatByLayer.IpV4TSum, // Bytes = protocalStatByLayer.IpV4TCPHSum, // bps = protocalStatByLayer.IpV4TCPHSum / protocalStatByLayer.Duration //}; //ipv4-udp ProtocalStatisticsTreeModel ipv4udp = new ProtocalStatisticsTreeModel() { DisplayName = "User Datagram Protocol", Protocal = "User Datagram Protocol", PacketPercent = Math.Round(protocalStatByLayer.IpV4UDPNum * 100 / (double)protocalStatByLayer.IpV4Num, 2), PacketNum = protocalStatByLayer.IpV4UDPNum, BytesPercent = Math.Round(protocalStatByLayer.IpV4UDPHSum * 100 / (double)protocalStatByLayer.IpV4TSum, 2), Bytes = protocalStatByLayer.IpV4UDPHSum, bps = Math.Round(protocalStatByLayer.IpV4UDPHSum / protocalStatByLayer.Duration, 3) }; //ipv6 ProtocalStatisticsTreeModel ipv6 = new ProtocalStatisticsTreeModel() { DisplayName = "Internet Protocal Version 6", Protocal = "Internet Protocal Version 6", PacketPercent = Math.Round(protocalStatByLayer.IpV6Num * 100 / (double)protocalStatByLayer.LinkNum, 2), PacketNum = protocalStatByLayer.IpV6Num, BytesPercent = Math.Round(protocalStatByLayer.IpV6HSum * 100 / (double)protocalStatByLayer.FrameSum, 2), Bytes = protocalStatByLayer.IpV6HSum, bps = Math.Round(protocalStatByLayer.IpV6HSum / protocalStatByLayer.Duration, 3) }; //ipv6-tcp ProtocalStatisticsTreeModel ipv6tcp = new ProtocalStatisticsTreeModel() { DisplayName = "Transmisson Control Protocol", Protocal = "Transmisson Control Protocol", PacketPercent = Math.Round(protocalStatByLayer.IpV6TCPNum * 100 / (double)protocalStatByLayer.IpV6Num, 2), PacketNum = protocalStatByLayer.IpV6TCPNum, BytesPercent = Math.Round(protocalStatByLayer.IpV6TCPHSum * 100 / (double)protocalStatByLayer.IpV6TSum, 2), Bytes = protocalStatByLayer.IpV6TCPHSum, bps = Math.Round(protocalStatByLayer.IpV6TCPHSum / protocalStatByLayer.Duration, 3) }; //ipv6-udp ProtocalStatisticsTreeModel ipv6udp = new ProtocalStatisticsTreeModel() { DisplayName = "User Datagram Protocol", Protocal = "User Datagram Protocol", PacketPercent = Math.Round(protocalStatByLayer.IpV6UDPNum * 100 / (double)protocalStatByLayer.IpV6Num, 2), PacketNum = protocalStatByLayer.IpV6UDPNum, BytesPercent = Math.Round(protocalStatByLayer.IpV6UDPHSum * 100 / (double)protocalStatByLayer.IpV6TSum, 2), Bytes = protocalStatByLayer.IpV6UDPHSum, bps = Math.Round(protocalStatByLayer.IpV6UDPHSum / protocalStatByLayer.Duration, 3) }; //arp ProtocalStatisticsTreeModel arp = new ProtocalStatisticsTreeModel() { DisplayName = "Adress Resolution Protocal", Protocal = "Adress Resolution Protocal", PacketPercent = Math.Round(protocalStatByLayer.ArpNum * 100 / (double)protocalStatByLayer.LinkNum, 2), PacketNum = protocalStatByLayer.ArpNum, BytesPercent = Math.Round(protocalStatByLayer.ArpHSum * 100 / (double)protocalStatByLayer.FrameSum, 2), Bytes = protocalStatByLayer.ArpHSum, bps = Math.Round(protocalStatByLayer.ArpHSum / protocalStatByLayer.Duration, 3) }; ipv4.Children.Add(ipv4tcp); ipv4.Children.Add(ipv4udp); ipv6.Children.Add(ipv6tcp); ipv6.Children.Add(ipv6udp); ethernet.Children.Add(ipv4); ethernet.Children.Add(ipv6); ethernet.Children.Add(arp); frame.Children.Add(ethernet); TreeRoot.Children.Add(frame); } TreeRoot.IsBatchLoading = false; TreeListModel = TreeRoot; }