public void GetNodes(string path) { XmlReader xmlReader = new XmlReader(path); int numberofnodes = xmlReader.GetNumberOfItems("router"); this.Topo.AlgNetwork.countn = numberofnodes; for (int a = 0; a < numberofnodes; a++) { var node_id = Int32.Parse(xmlReader.GetAttributeValue(a, "router", "ID")); var node_ip_address = xmlReader.GetAttributeValue(a, "router", "IP_ADDRESS"); AlgNode node = new AlgNode(node_id, node_ip_address); this.Topo.AlgNetwork.nodes.Add(node); nodeDict.Add(node_id, node_ip_address); } }
public void GetLink(string path) { XmlReader xmlReader = new XmlReader(path); int numberoflinks = xmlReader.GetNumberOfItems("connect"); this.Topo.AlgNetwork.counte = numberoflinks; for (int a = 0; a < numberoflinks; a++) { var node_name1 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect", "NODE1")); var node_name2 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect", "NODE2")); var path_id = Int32.Parse(xmlReader.GetAttributeValue(a, "connect", "PATH_ID")); var distance = Double.Parse(xmlReader.GetAttributeValue(a, "connect", "DROGA")); var port1 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect", "PORTIN")); var port2 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect", "PORTOUT")); AlgNode no = this.Topo.AlgNetwork.nodes.Find(x => x.IdNode == node_name1); AlgNode nd = this.Topo.AlgNetwork.nodes.Find(x => x.IdNode == node_name2); AlgLink algLink = new AlgLink(path_id, no, nd, distance); this.Topo.AlgNetwork.edges.Add(algLink); } int numberofconnectr = xmlReader.GetNumberOfItems("connect_r"); for (int a = 0; a < numberofconnectr; a++) { var node_name1 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect_r", "NODE1")); var node_name2 = Int32.Parse(xmlReader.GetAttributeValue(a, "connect_r", "NODE2")); var port1 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect_r", "PORTIN")); var port2 = UInt16.Parse(xmlReader.GetAttributeValue(a, "connect_r", "PORTOUT")); //SNPLinkNode.Add(node_name1 + ":" + node_name2, port1 + ":" + port2); //SNPLinkNode.Add(node_name2 + ":" + node_name1, port2 + ":" + port1); SNPLinkNode.Add(node_name1 + ":" + port1 + ":" + node_name2 + ":" + port2); SNPLinkNode.Add(node_name2 + ":" + port2 + ":" + node_name1 + ":" + port1); } }
public AlgLink(int id, AlgNode one, AlgNode two, double wei) { IdLink = id; NodeOne = one; NodeTwo = two; NodeFirst = one.IdNode; NodeSecond = two.IdNode; Weight = wei; //int band = (int)(64 - Math.Sqrt(wei)); //int firstSNPid; //int secondSNPid; //if (NodeOne.SNPPool.SNPList[0].PortO == -1) //{ // firstSNPid = 0; // NodeOne.SNPPool.SNPList[0].PortO = IdLink; //} //else //{ // //Odnalezienie węzła z dołączonym interfejsem // firstSNPid = this.NodeOne.SNPPool.SNPList.FindIndex(x => x.PortO == IdLink); //} //if (NodeTwo.SNPPool.SNPList[0].PortO == -1) //{ // secondSNPid = 0; // NodeTwo.SNPPool.SNPList[0].PortO = IdLink; //} //else //{ // //Odnalezienie węzła z dołączonym interfejsem // secondSNPid = this.NodeTwo.SNPPool.SNPList.FindIndex(x => x.PortO == IdLink); //} ////Jeżeli węzeł nie ma doprowadzonego takiego łącza //if (firstSNPid == -1) //{ // //Dodanie nowego interfejsu do wezla 1 // NodeOne.SNPPool.SNPList.Add(new SNP(IPAddress.Parse(NodeOne.IPNode), -1, IdLink)); // firstSNPid = NodeOne.SNPPool.SNPList.Count - 1; //} ////Jeżeli węzeł nie ma doprowadzonego takiego łącza //if (secondSNPid == -1) //{ // //Dodanie nowego interfejsu do wezla 1 // NodeTwo.SNPPool.SNPList.Add(new SNP(IPAddress.Parse(NodeTwo.IPNode), IdLink, -1)); // secondSNPid = NodeTwo.SNPPool.SNPList.Count - 1; //} //if (64 >= Math.Sqrt(Weight)) //{ // //Na wyjsciu wezla 1 // //this.NodeOne.SNPPool.SNPList[firstSNPid].slTable // // .addRow(new EONTableRowOut(0, (short)(64- band))); // ////Na wejsciu wezla 2 // //this.Wezel2.SNPP.snps[SNP2Index].eonTable // // .addRow(new EONTableRowIN(0, (short)(EONTable.capacity - band))); // Weight = wei; //} }