public void FixedSlotConstraintTest_complexCase() { Topology t = new Topology(); t.AddDevice("O1"); t.AddDevice("D1"); t.AddDevice("I1"); t.AddDevice("I2"); t.AddConnection("C1", "I1", "D1", 40); t.AddConnection("C2", "I2", "D1", 40); t.AddConnection("C3", "D1", "O1", 80); t.AddLink("L1", "I1", "O1", 10); t.AddLink("L2", "I2", "O1", 10); t.AddFixedSlotConstraint("L1", 3, 4); t.AddFixedSlotConstraint("L2", 3, 4); t.AllocateLinksPaths(); t.AllocateSlots(); Assert.AreEqual("L1", t.GetConnection("C3").slots[6].slotOWner.name); Assert.AreEqual("L2", t.GetConnection("C3").slots[7].slotOWner.name); }
public void Find8SlotsSameSize() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddConnection("C1", "D1", "D2", 80); t.AddLink("L1", "D1", "D2", 10); t.AddLink("L2", "D1", "D2", 10); t.AddLink("L3", "D1", "D2", 10); t.AddLink("L4", "D1", "D2", 10); t.AddLink("L5", "D1", "D2", 10); t.AddLink("L6", "D1", "D2", 10); t.AddLink("L7", "D1", "D2", 10); t.AddLink("L8", "D1", "D2", 10); t.AllocateLinksPaths(); t.AllocateSlots(); Assert.AreEqual(1, t.GetLink("L1").mainPath.Count); Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source); Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination); Assert.AreEqual(8, t.GetConnection("C1").slots.Count); Assert.AreEqual(t.GetLink("L1"), t.GetConnection("C1").slots[0].slotOWner); Assert.AreEqual(t.GetLink("L2"), t.GetConnection("C1").slots[1].slotOWner); Assert.AreEqual(t.GetLink("L3"), t.GetConnection("C1").slots[2].slotOWner); Assert.AreEqual(t.GetLink("L4"), t.GetConnection("C1").slots[3].slotOWner); Assert.AreEqual(t.GetLink("L5"), t.GetConnection("C1").slots[4].slotOWner); Assert.AreEqual(t.GetLink("L6"), t.GetConnection("C1").slots[5].slotOWner); Assert.AreEqual(t.GetLink("L7"), t.GetConnection("C1").slots[6].slotOWner); Assert.AreEqual(t.GetLink("L8"), t.GetConnection("C1").slots[7].slotOWner); }
public void FindPathWith2Sources() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddDevice("D3"); t.AddConnection("C1", "D1", "D3", 10); t.AddConnection("C2", "D2", "D3", 10); List<string> sources = new List<string>() { "D1", "D2" }; List<string> destinations = new List<string>() { "D3" }; t.AddLink("L1", sources, destinations, 10); t.AllocateLinksPaths(); }
public void FixedSlotConstraintTest() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddDevice("D3"); t.AddConnection("C1", "D1", "D2", 20); t.AddConnection("C2", "D2", "D3", 80); t.AddLink("L1", "D1", "D3", 10); t.AddFixedSlotConstraint("L1", 3, 4); t.AllocateLinksPaths(); t.AllocateSlots(); }
public void SimpleRoutingCalculation() { Topology t = new Topology(); t.AddDevice("D/I"); t.AddDevice("P/O"); t.AddDevice("RT/I"); t.AddDevice("RT/O"); t.AddConnection("C1", "D/I", "RT/I", 20); t.AddConnection("C2", "RT/I", "RT/O", 80); t.AddConnection("C3", "RT/O", "P/O", 40); t.AddLink("L1", "D/I", "P/O", 10); t.AddLink("L2", "D/I", "P/O", 10); t.AllocateLinksPaths(); t.AllocateSlots(); RoutingTable rt = t.CalculateRoutingTableForDevice("RT"); Assert.AreEqual(2, rt.routingEntities.Count); }
public void SlotAllocationWithMultiplexing_ComplexCase() { Topology t = new Topology(); t.AddDevice("O1"); t.AddDevice("O2"); t.AddDevice("O3"); t.AddDevice("O4"); t.AddDevice("D1"); t.AddDevice("I1"); t.AddConnection("C1", "D1", "O1", 10); t.AddConnection("C2", "D1", "O2", 40); t.AddConnection("C3", "D1", "O3", 20); t.AddConnection("C4", "D1", "O4", 10); t.AddConnection("C5", "I1", "D1", 80); t.AddLink("L1", "I1", "O1", 10); t.AddLink("L2", "I1", "O2", 20); t.AddLink("L3", "I1", "O2", 10); t.AddLink("L4", "I1", "O2", 10); t.AddLink("L5", "I1", "O3", 5); t.AddLink("L6", "I1", "O3", 5); t.AddLink("L7", "I1", "O3", 10); t.AddLink("L8", "I1", "O4", 5); t.AddLink("L9", "I1", "O4", 5); t.AllocateLinksPaths(); t.AllocateSlots(); }
public void SlotAllocationWithMultiplexing() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddDevice("D3"); t.AddDevice("D4"); t.AddConnection("C1", "D1", "D2", 20); t.AddConnection("C2", "D2", "D3", 10); t.AddConnection("C3", "D2", "D4", 10); t.AddLink("L1", "D1", "D3", 10); t.AddLink("L2", "D1", "D4", 10); t.AllocateLinksPaths(); t.AllocateSlots(); }
public void SlotAllocationWithDemultiplexing_EvenMoreComplexCase() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddDevice("D3"); t.AddDevice("D4"); t.AddConnection("C1", "D1", "D3", 40); t.AddConnection("C2", "D2", "D3", 10); t.AddConnection("C3", "D3", "D4", 80); t.AddLink("L1", "D1", "D4", 10); t.AddLink("L2", "D1", "D4", 20); t.AddLink("L3", "D1", "D4", 10); t.AddLink("L4", "D2", "D4", 10); t.AllocateLinksPaths(); t.AllocateSlots(); }
public void SimpleSlotFind() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddConnection("C1", "D1", "D2", 10); t.AddLink("L1", "D1", "D2", 10); t.AllocateLinksPaths(); t.AllocateSlots(); Assert.AreEqual(1, t.GetLink("L1").mainPath.Count); Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source); Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination); Assert.AreEqual(1, t.GetConnection("C1").slots.Count); Assert.AreEqual(t.GetLink("L1"), t.GetConnection("C1").slots[0].slotOWner); }
public void PathAllocationNeedsSorting() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddDevice("D3"); t.AddConnection("C1", "D1", "D2", 20); t.AddConnection("C2", "D1", "D3", 10); t.AddConnection("C3", "D3", "D2", 10); t.AddLink("L1", "D1", "D2", 10); t.AddLink("L2", "D1", "D2", 20); t.AllocateLinksPaths(); t.AllocateSlots(); //ASSERIONS NOT NEEDED - NO EXCEPTION SHOULD BE ENOUGH! }
public void TwoWayPathFind() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddConnection("C1", "D1", "D2", 10); t.AddConnection("C2", "D2", "D1", 10); t.AddLink("L1", "D1", "D2", 10); t.AddLink("L2", "D2", "D1", 10); t.AllocateLinksPaths(); Assert.AreEqual(1, t.GetLink("L1").mainPath.Count); Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source); Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination); Assert.AreEqual(1, t.GetLink("L2").mainPath.Count); Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L2").mainPath[0].source); Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L2").mainPath[0].destination); }
public void ForbiddenSlotConstraintTest() { Topology t = new Topology(); t.AddDevice("D1"); t.AddDevice("D2"); t.AddConnection("C1", "D1", "D2", 20); t.AddLink("L1", "D1", "D2", 10); t.AddForbiddenSlotConstraint("Constraint-1", "D1", 0, 2); t.AllocateLinksPaths(); t.AllocateSlots(); Assert.AreEqual(1, t.GetLink("L1").mainPath.Count); Assert.AreEqual(t.GetDevice("D1"), t.GetLink("L1").mainPath[0].source); Assert.AreEqual(t.GetDevice("D2"), t.GetLink("L1").mainPath[0].destination); Assert.AreEqual(2, t.GetConnection("C1").slots.Count); Assert.AreEqual(Slot.State.FORBIDDEN, t.GetConnection("C1").slots[0].state); Assert.AreEqual("Constraint-1", t.GetConnection("C1").slots[0].constraintName); Assert.AreEqual(Slot.State.TAKEN, t.GetConnection("C1").slots[1].state); Assert.AreEqual(t.GetLink("L1"), t.GetConnection("C1").slots[1].slotOWner); }