private void _SendMyOwnFlow() { int destID = 0; float Currdemand; string key = null; this._DestNum = this.MyDestinationsAndDemands.Count; try { for (int j = 0; j < this._DestNum; j++) { destID = MyDestinationsAndDemands.ElementAt(j).Key; Currdemand = MyDestinationsAndCurrentDemands.ElementAt(j).Value; if (Targets[ForwardingTable[destID]]) { key = this.ID + ":" + destID; if (NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID].ContainsKey(key)) { NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].FlowCameFrom = this.ID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].OriginID = this.ID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].DestinationID = destID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].OriginalFlow = Currdemand; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].CurrFlow = Currdemand; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].FlowCameFrom = this.ID; } else { AdHocFlow myFlow = new AdHocFlow(); myFlow.FlowCameFrom = this.ID; myFlow.OriginID = this.ID; myFlow.DestinationID = destID; myFlow.OriginalFlow = Currdemand; myFlow.CurrFlow = Currdemand; myFlow.FlowCameFrom = this.ID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID].Add(key, myFlow); } } if (TargetsAndMyFlowSent[ForwardingTable[destID]].ContainsKey(destID)) { TargetsAndMyFlowSent[ForwardingTable[destID]][destID] = Currdemand; } else { TargetsAndMyFlowSent[ForwardingTable[destID]].Add(destID, Currdemand); } } } catch (Exception ex) { Console.WriteLine("Node: " + this.ID + "was trying to send its own flow to: " + ForwardingTable[destID] + "\n" + ex.ToString()); } }
private void _SendMyOwnFlow() { int destID = 0; float Currdemand; string key = null; this._DestNum = this.MyDestinationsAndDemands.Count; try { for (int j = 0; j < this._DestNum; j++) { destID = MyDestinationsAndDemands.ElementAt(j).Key; Currdemand = MyDestinationsAndCurrentDemands.ElementAt(j).Value; if (Targets[ForwardingTable[destID]]) { key = this.ID + ":" + destID; if (NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID].ContainsKey(key)) { NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].FlowCameFrom = this.ID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].OriginID = this.ID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].DestinationID = destID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].OriginalFlow = Currdemand; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].CurrFlow = Currdemand; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID][key].FlowCameFrom = this.ID; } else { AdHocFlow myFlow = new AdHocFlow(); myFlow.FlowCameFrom = this.ID; myFlow.OriginID = this.ID; myFlow.DestinationID = destID; myFlow.OriginalFlow = Currdemand; myFlow.CurrFlow = Currdemand; myFlow.FlowCameFrom = this.ID; NodeList.Nodes[ForwardingTable[destID]].InFlow[this.ID].Add(key, myFlow); } } if (TargetsAndMyFlowSent[ForwardingTable[destID]].ContainsKey(destID)) { TargetsAndMyFlowSent[ForwardingTable[destID]][destID] = Currdemand; } else { TargetsAndMyFlowSent[ForwardingTable[destID]].Add(destID, Currdemand); } } } catch (Exception ex) { Console.WriteLine("Node: " + this.ID + "was trying to send its own flow to: " + ForwardingTable[destID] + "\n" + ex.ToString()); } }
private void _ForwardFlow(string flowID, int sourceID) { int target = ForwardingTable[this.InFlow[sourceID][flowID].DestinationID]; int OriginID = this.InFlow[sourceID][flowID].OriginID; int DestinationID = this.InFlow[sourceID][flowID].DestinationID; float blockRate = 0; float amount = this.InFlow[sourceID][flowID].CurrFlow; float flowCame = this.InFlow[sourceID][flowID].CurrFlow; float amountblocked = 0; string key = OriginID + ":" + DestinationID; blockRate = this.GetBlockRate(sourceID); try { if (Targets[target]) { if (amount != 0) { amountblocked = (amount * blockRate); amount = amount - amountblocked; } if (NodeList.Nodes[target].InFlow[this.ID].ContainsKey(key)) { NodeList.Nodes[target].InFlow[this.ID][key].OriginID = OriginID; NodeList.Nodes[target].InFlow[this.ID][key].DestinationID = DestinationID; NodeList.Nodes[target].InFlow[this.ID][key].FlowCameFrom = this.ID; NodeList.Nodes[target].InFlow[this.ID][key].CurrFlow = amount; NodeList.Nodes[target].InFlow[this.ID][key].FlowBlockedByPrevNode = amountblocked; NodeList.Nodes[target].InFlow[this.ID][key].OriginalFlow = this.InFlow[sourceID][flowID].OriginalFlow; } else { AdHocFlow flow = new AdHocFlow(); flow.OriginID = OriginID; flow.DestinationID = DestinationID; flow.FlowCameFrom = this.ID; flow.CurrFlow = amount; flow.FlowBlockedByPrevNode = amountblocked; flow.OriginalFlow = this.InFlow[sourceID][flowID].OriginalFlow; NodeList.Nodes[target].InFlow[this.ID].Add(key, flow); } } else { NodeList.Nodes[OriginID].FlowReached[DestinationID] = 0; } float[] flowVals = new float[2]; flowVals[0] = amount; flowVals[1] = flowCame; if (this.SourcesAndFlowForwarded[sourceID].ContainsKey(key)) { this.SourcesAndFlowForwarded[sourceID][key] = flowVals; } else { this.SourcesAndFlowForwarded[sourceID].Add(key, flowVals); } if (this.TargetsAndFlowForwarded[target].ContainsKey(key)) { this.TargetsAndFlowForwarded[target][key] = flowVals[0]; } else { this.TargetsAndFlowForwarded[target].Add(key, flowVals[0]); } } catch (Exception ex) { Console.WriteLine("Node: " + this.ID + "was trying to forward flow to: " + target + "\n" + ex.ToString()); } }
private void _ForwardFlow(string flowID, int sourceID) { int target = ForwardingTable[this.InFlow[sourceID][flowID].DestinationID]; int OriginID = this.InFlow[sourceID][flowID].OriginID; int DestinationID = this.InFlow[sourceID][flowID].DestinationID; float blockRate = 0; float amount = this.InFlow[sourceID][flowID].CurrFlow; float flowCame = this.InFlow[sourceID][flowID].CurrFlow; float amountblocked = 0; string key = OriginID + ":" + DestinationID; blockRate = this.GetBlockRate(sourceID); try { if (Targets[target]) { if (amount != 0) { amountblocked = (amount * blockRate); amount = amount - amountblocked; } if (NodeList.Nodes[target].InFlow[this.ID].ContainsKey(key)) { NodeList.Nodes[target].InFlow[this.ID][key].OriginID = OriginID; NodeList.Nodes[target].InFlow[this.ID][key].DestinationID = DestinationID; NodeList.Nodes[target].InFlow[this.ID][key].FlowCameFrom = this.ID; NodeList.Nodes[target].InFlow[this.ID][key].CurrFlow = amount; NodeList.Nodes[target].InFlow[this.ID][key].FlowBlockedByPrevNode = amountblocked; NodeList.Nodes[target].InFlow[this.ID][key].OriginalFlow = this.InFlow[sourceID][flowID].OriginalFlow; } else { AdHocFlow flow = new AdHocFlow(); flow.OriginID = OriginID; flow.DestinationID = DestinationID; flow.FlowCameFrom = this.ID; flow.CurrFlow = amount; flow.FlowBlockedByPrevNode = amountblocked; flow.OriginalFlow = this.InFlow[sourceID][flowID].OriginalFlow; NodeList.Nodes[target].InFlow[this.ID].Add(key, flow); } } else { NodeList.Nodes[OriginID].FlowReached[DestinationID] = 0; } float[] flowVals = new float[2]; flowVals[0] = amount; flowVals[1] = flowCame; if (this.SourcesAndFlowForwarded[sourceID].ContainsKey(key)) { this.SourcesAndFlowForwarded[sourceID][key] = flowVals; } else { this.SourcesAndFlowForwarded[sourceID].Add(key, flowVals); } if (this.TargetsAndFlowForwarded[target].ContainsKey(key)) { this.TargetsAndFlowForwarded[target][key] = flowVals[0]; } else { this.TargetsAndFlowForwarded[target].Add(key, flowVals[0]); } } catch (Exception ex) { Console.WriteLine("Node: " + this.ID + "was trying to forward flow to: " + target + "\n" + ex.ToString()); } }