コード例 #1
0
        private void RestoreToNetworkHierarchyTreeView(NetworkAddress address, NodeView node)
        {
            TreeNode parent         = networkHierarchyTreeView.Nodes[address.GetId(0) - 1];
            var      nodes          = parent.Nodes;
            var      currentAddress = new NetworkAddress(address.GetId(0));

            for (var i = 1; i < address.Levels - 1; i++)
            {
                var id = address.GetId(i);


                var subnetworkNode = new TreeNode();
                currentAddress      = currentAddress.Append(id);
                subnetworkNode.Text = currentAddress.ToString();
                subnetworkNode.Name = currentAddress.ToString();
                subnetworkNode.Tag  = new HierarchicalPathComputationServer(currentAddress,
                                                                            "127.0.0.1", Settings.Default.SignallingCloudListeningPort);

                if (!nodes.ContainsKey(subnetworkNode.Name))
                {
                    nodes.Add(subnetworkNode);
                    parent = subnetworkNode;
                    nodes  = parent.Nodes;
                }
                else
                {
                    parent = nodes[subnetworkNode.Name];
                    nodes  = parent.Nodes;
                }
            }


            var treeNode = new TreeNode {
                Tag  = node,
                Text = address.ToString(),
                Name = address.ToString()
            };

            if (!nodes.ContainsKey(treeNode.Name))
            {
                nodes.Add(treeNode);
            }
            else
            {
                nodes[treeNode.Name].Tag = treeNode.Tag;
            }
        }
コード例 #2
0
        private NetworkAddress AddToTreeView(TreeNode treeNode)
        {
            NetworkAddress nodeAddress;
            var            selectedNode = networkHierarchyTreeView.SelectedNode;

            if (selectedNode != null)
            {
                selectedNode.Nodes.Add(treeNode);

                var parentAddress = new NetworkAddress(selectedNode.Text);
                var childrenIndex = selectedNode.Nodes.IndexOf(treeNode) + 1;
                nodeAddress = parentAddress.Append(childrenIndex);
            }
            else
            {
                networkHierarchyTreeView.Nodes.Add(treeNode);

                var childrenIndex = networkHierarchyTreeView.Nodes.IndexOf(treeNode) + 1;
                nodeAddress = new NetworkAddress(childrenIndex);
            }

            return(nodeAddress);
        }
コード例 #3
0
        public void TestLRM()
        {
            var subnetwork1Address = new NetworkAddress("1");

            var client1Address = new NetworkAddress("1.1.1");
            var client2Address = new NetworkAddress("1.2.1");

            var node1Address = new NetworkAddress("1.1");
            var node2Address = new NetworkAddress("1.2");

            var node1Client1SnppOut = new SubnetworkPointPool(client1Address.Append(1));
            var node1Client1SnppIn  = new SubnetworkPointPool(node1Address.Append(1));
            var node1Node2SnppOut   = new SubnetworkPointPool(node2Address.Append(2));
            var node1Node2SnppIn    = new SubnetworkPointPool(node1Address.Append(2));
            var node2Client2SnppOut = new SubnetworkPointPool(client2Address.Append(1));
            var node2Client2SnppIn  = new SubnetworkPointPool(node2Address.Append(1));

            var client1Node1Link = new Link(node1Client1SnppIn, node1Client1SnppOut, 10, true);
            var node1Node2Link   = new Link(node1Node2SnppIn, node1Node2SnppOut, 10, false);
            var client2Node2Link = new Link(node2Client2SnppIn, node2Client2SnppOut, 10, true);

            var rcAddress = subnetwork1Address;
            var rc        = new RoutingController(rcAddress);

            _controlPlaneElements.Add(new Row(rcAddress, ControlPlaneElementType.RC), rc);

            var ccAddress = subnetwork1Address;
            var cc        = new ConnectionController(ccAddress);

            _controlPlaneElements.Add(new Row(ccAddress, ControlPlaneElementType.CC), cc);

            var cc1Address = node1Address;
            var cc1        = new ConnectionController(cc1Address);

            _controlPlaneElements.Add(new Row(cc1Address, ControlPlaneElementType.CC), cc1);

            var cc2Address = node2Address;
            var cc2        = new ConnectionController(cc2Address);

            _controlPlaneElements.Add(new Row(cc2Address, ControlPlaneElementType.CC), cc2);

            var lrm1Address = node1Address;
            var lrm1        = new LinkResourceManager(lrm1Address);

            _controlPlaneElements.Add(new Row(lrm1Address, ControlPlaneElementType.LRM), lrm1);

            var lrm2Address = node2Address;
            var lrm2        = new LinkResourceManager(lrm2Address);

            _controlPlaneElements.Add(new Row(lrm2Address, ControlPlaneElementType.LRM), lrm2);


            rc.MessageToSend   += PassMessage;
            cc.MessageToSend   += PassMessage;
            cc1.MessageToSend  += PassMessage;
            cc2.MessageToSend  += PassMessage;
            lrm1.MessageToSend += PassMessage;
            lrm2.MessageToSend += PassMessage;

            rc.UpdateState   += UpdateState;
            cc.UpdateState   += UpdateState;
            cc1.UpdateState  += UpdateState;
            cc2.UpdateState  += UpdateState;
            lrm1.UpdateState += UpdateState;
            lrm2.UpdateState += UpdateState;

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client1Node1Link,
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client1Node1Link.Reverse(),
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link,
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm1.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link.Reverse(),
                DestinationAddress             = node1Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link,
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = node1Node2Link.Reverse(),
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client2Node2Link,
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            lrm2.ReceiveMessage(new SignallingMessage {
                Operation                      = OperationType.Configuration,
                Payload                        = client2Node2Link.Reverse(),
                DestinationAddress             = node2Address,
                DestinationControlPlaneElement = ControlPlaneElementType.LRM
            });

            cc.ReceiveMessage(new SignallingMessage {
                DemandedCapacity               = 5,
                DestinationAddress             = ccAddress,
                DestinationControlPlaneElement = ControlPlaneElementType.CC,
                DestinationClientAddress       = client2Address,
                Operation = OperationType.ConnectionRequest,
                Payload   = new[] {
                    node1Client1SnppIn,
                    node1Node2SnppOut
                },
                SourceAddress             = subnetwork1Address,
                SourceClientAddress       = client1Address,
                SourceControlPlaneElement = ControlPlaneElementType.CC
            });
        }
コード例 #4
0
        public void TestMessageTransfer()
        {
            var directory = new Directory(NameServer.Address);

            _controlPlaneElements.Add(new Row(NameServer.Address, ControlPlaneElementType.Directory), directory);

            var policy = new Policy(NameServer.Address);

            _controlPlaneElements.Add(new Row(NameServer.Address, ControlPlaneElementType.Policy), policy);

            var ncc1Address = new NetworkAddress("1");
            var ncc1        = new NetworkCallController(ncc1Address);

            _controlPlaneElements.Add(new Row(ncc1Address, ControlPlaneElementType.NCC), ncc1);

            var ncc2Address = new NetworkAddress("2");
            var ncc2        = new NetworkCallController(ncc2Address);

            _controlPlaneElements.Add(new Row(ncc2Address, ControlPlaneElementType.NCC), ncc2);

            var cpccAAddress = new NetworkAddress("1.1.1");
            var cpccA        = new CallingPartyCallController(cpccAAddress);

            _controlPlaneElements.Add(new Row(cpccAAddress, ControlPlaneElementType.CPCC), cpccA);
            directory.UpdateDirectory("A", cpccAAddress, new SubnetworkPointPool(cpccAAddress.Append(1)));

            var cpccBAddress = new NetworkAddress("2.1.2");
            var cpccB        = new CallingPartyCallController(cpccBAddress);

            _controlPlaneElements.Add(new Row(cpccBAddress, ControlPlaneElementType.CPCC), cpccB);
            directory.UpdateDirectory("B", cpccBAddress, new SubnetworkPointPool(cpccBAddress.Append(1)));

            var cc1Address = new NetworkAddress("1");
            var cc1        = new ConnectionController(cc1Address);

            _controlPlaneElements.Add(new Row(cc1Address, ControlPlaneElementType.CC), cc1);

            var cc2Address = new NetworkAddress("2");
            var cc2        = new ConnectionController(cc2Address);

            _controlPlaneElements.Add(new Row(cc2Address, ControlPlaneElementType.CC), cc2);

            var rc2Address = new NetworkAddress("2");
            var rc2        = new RoutingController(rc2Address);

            _controlPlaneElements.Add(new Row(rc2Address, ControlPlaneElementType.RC), rc2);

            directory.MessageToSend += PassMessage;
            policy.MessageToSend    += PassMessage;
            ncc1.MessageToSend      += PassMessage;
            ncc2.MessageToSend      += PassMessage;
            cpccA.MessageToSend     += PassMessage;
            cpccB.MessageToSend     += PassMessage;
            cc1.MessageToSend       += PassMessage;
            cc2.MessageToSend       += PassMessage;
            rc2.MessageToSend       += PassMessage;

            directory.UpdateState += UpdateState;
            policy.UpdateState    += UpdateState;
            ncc1.UpdateState      += UpdateState;
            ncc2.UpdateState      += UpdateState;
            cpccA.UpdateState     += UpdateState;
            cpccB.UpdateState     += UpdateState;
            cc1.UpdateState       += UpdateState;
            cc2.UpdateState       += UpdateState;
            rc2.UpdateState       += UpdateState;

            cpccA.SendCallRequest("A", "B", 20);

            Thread.Sleep(10000);
        }