public void ConnectionRequest_rsp(NetworkMessage msg, bool response, string slots)
 {
     if (NextDomain == false & response == true)
     {
         msg.payload = "CONNECTION_REQUEST_RSP=TRUE,NEXT_DOMAIN=FALSE " + slots;
         nc.Send(msg.ToBytes());
         Disp.ViewOnScreen(msg.ToString("[LOG]: "));
     }
     else if (NextDomain == true & response == true)
     {
         msg.payload = "CONNECTION_REQUEST_RSP=TRUE,NEXT_DOMAIN=TRUE " + slots;
         nc.Send(msg.ToBytes());
         Disp.ViewOnScreen(msg.ToString("[LOG]: "));
     }
     else if (NextDomain == false & response == false)
     {
         msg.payload = "CONNECTION_REQUEST_RSP=FALSE,NEXT_DOMAIN=FALSE " + slots;
         nc.Send(msg.ToBytes());
         Disp.ViewOnScreen(msg.ToString("[LOG]: "));
     }
     else if (NextDomain == true & response == false)
     {
         msg.payload = "CONNECTION_REQUEST_RSP=FALSE,NEXT_DOMAIN=TRUE " + slots;
         nc.Send(msg.ToBytes());
         Disp.ViewOnScreen(msg.ToString("[LOG]: "));
     }
 }
        //obsługa handlera wewnetrznego
        public void ConnectionRequest_req(string node1, string node2, string snpp1, string snpp2, int cap, string channels)
        {
            //List<int> chan = new List<int>();
            //foreach (var el in channels.Split()) chan.Add(int.Parse(el));
            Disp.ViewOnScreen("[CC -> Inner_CC]: Connection Request - request.");
            Node1    = node1;
            Node2    = node2;
            SNPP1    = snpp1;
            SNPP2    = snpp2;
            Capacity = cap;

            Disp.ViewOnScreen("[CC -> RC]: Route Table Query - request.");
            Path = RouteTableQuery_req(rc, Node1, Node2);
            string[] slotsArr = channels.Split();
            foreach (var s in slotsArr)
            {
                Channels.Add(int.Parse(s));
                var p = ChannelsAvailable.Find(x => x.Equals(int.Parse(s)));
                ChannelsAvailable.Remove(p);
            }

            //Path = RouteTableQuery_req(rc, Node1, Node2, Capacity);

            Disp.ViewOnScreen("[RC -> CC]: Route Table Query - response.");

            Disp.ViewOnScreen("[CC]: Path has been chosen! " + string.Join(" ", Path.ToArray()));

            Disp.ViewOnScreen("[CC -> LRM]: SNP Link Connection Request - request: " + string.Join(" ", Path.ToArray()) + ", " + string.Join(" ", Channels.ToArray()));
            lrm.SNPLinkConnectionRequest_req(Path, Channels);
            Disp.ViewOnScreen("[Inner_CC -> CC]: Connection Request - response.");
        }
            public void CallTeardown_rsp(NetworkMessage msg, NetClient sender, bool next_domain)
            {
                msg.src = myCPCC.port;
                msg.dst = myCPCC.ncc_port;
                Disp.ViewOnScreen("Do you accept disconnection?");
                string choice = Console.ReadLine();

                if (choice.Equals("accept"))
                {
                    msg.payload = "CALL_TEARDOWN_RSP=TRUE";
                }
                else if (choice.Equals("refuse"))
                {
                    if (next_domain)
                    {
                        msg.payload = "CALL_TEARDOWN_RSP=FALSE,NEXT_DOMAIN=TRUE";
                    }
                    else
                    {
                        msg.payload = "CALL_TEARDOWN_RSP=FALSE,NEXT_DOMAIN=FALSE";
                    }
                }
                sender.Send(msg.ToBytes());
                Disp.ViewOnScreen(msg.ToString("Message sent: "));
            }
        public bool ConnectionRequest_req(string node1, string node2, int cap, string snpp1, string snpp2, string slots)
        {
            Disp.ViewOnScreen("[NCC -> CC]: Connection Request - request.");
            Node1    = node1;
            Node2    = node2;
            SNPP1    = snpp1;
            SNPP2    = snpp2;
            Capacity = cap;
            Disp.ViewOnScreen("[CC -> RC]: Route Table Query - request.");

            if (slots.Equals(""))
            {
                Path     = RouteTableQuery_req(rc, Node1, Node2, Capacity);
                slotsNum = Path[0];
                Path.RemoveAt(0);
                Channels = getChannels(int.Parse(slotsNum));
            }
            else
            {
                Path = RouteTableQuery_req(rc, Node1, Node2);
                string[] slotsArr = slots.Split();
                foreach (var s in slotsArr)
                {
                    Channels.Add(int.Parse(s));
                    var p = ChannelsAvailable.Find(x => x.Equals(int.Parse(s)));
                    ChannelsAvailable.Remove(p);
                }
            }

            Disp.ViewOnScreen("[RC -> CC]: Route Table Query - response.");
            Disp.ViewOnScreen("[CC]: Path has been chosen! " + string.Join(" ", Path.ToArray()));
            Disp.ViewOnScreen("[CC -> LRM]: SNP Link Connection Request - request: " + string.Join(" ", Path.ToArray()) + ", " + string.Join(" ", Channels.ToArray()));
            return(lrm.SNPLinkConnectionRequest_req(Path, Channels));
        }
        public static void Main(string[] args)
        {
            Config(args[0], args[1]);
            //Config("..\\..\\..\\..\\Configs\\NetworkConfig1.txt");

            NetClient nc = new NetClient(HandleMessage, Name);

            Task.Run(() => nc.ListenForMessages());

            if (Inner_Name.Equals(" ") && !Name.Equals("NC2"))
            {
                Disp.ViewOnScreen("INNER SUBNETWORK " + Name);
                NetworkMessage msg = new NetworkMessage(Name, Upper_Name, IPAddress.Parse("1.0.0.1"), IPAddress.Parse("2.0.0.1"), 1, "INNER_NC_AVAILABLE");
                nc.Send(msg.ToBytes());
            }

            Disp.ViewOnScreen("Starting subnetwork!");

            //RoutingProtocol rc = new RoutingProtocol("..\\..\\..\\..\\Configs\\RCConfigNode1.txt", "..\\..\\..\\..\\Configs\\RCConfigLink1.txt");
            RoutingProtocol rc  = new RoutingProtocol(args[2], args[3], nc, Name);
            LRM             lrm = new LRM(nc, rc, Name, Links);
            CC cc = new CC(nc, rc, lrm, Name);

            _cc     = cc;
            _rc     = rc;
            _lrm    = lrm;
            _lrm.cc = cc;
            while (true)
            {
                Console.ReadLine();
            }
        }
 public CC(NetClient nc, RoutingProtocol rc, LRM lrm, string name)
 {
     this.nc  = nc;
     this.rc  = rc;
     this.lrm = lrm;
     Name     = name;
     Disp.ViewOnScreen("Starting CC!");
 }
 public void ConnectionTeardown_req(string snpp1, string snpp2, int cap)
 {
     Disp.ViewOnScreen("[NCC]: CONNECTION TEARDOWN REQUEST!");
     SNPP1    = snpp1;
     SNPP2    = snpp2;
     Capacity = cap;
     lrm.SNPReleaseResources(Path, Channels);
 }
            public void CallTeardown_req(string dst, int cap, NetClient sender)
            {
                NetworkMessage msg = new NetworkMessage(this.port, this.ncc_port, "CALL_TEARDOWN_REQ " + this.port + " " + dst + " " + cap.ToString());

                sender.Send(msg.ToBytes());
                Disp.ViewOnScreen(msg.ToString("Message sent: "));
                stream_gen.AddCalledHost(dst);
            }
            public void CallRequest_req(string src, string dst, int cap, NetClient sender)
            {
                NetworkMessage msg = new NetworkMessage(this.port, this.ncc_port, "CALL_REQUEST " + src + " " + dst + " " + cap.ToString());

                sender.Send(msg.ToBytes());
                Disp.ViewOnScreen(msg.ToString("Message sent: "));
                stream_gen.AddCalledHost(dst);
            }
Exemple #10
0
 public void CallCoordinationTeardown_rsp(NetworkMessage msg) //odpowiedż drugiej domeny na zgłoszenie chęci zakończenia połączenia
 {
     msg.src     = myNCC.port;
     msg.dst     = myNCC.ncc_port;
     msg.payload = "CALL_COORDINATION_RSP=FALSE";
     ncc.Send(msg.ToBytes());
     Disp.ViewOnScreen("Message sent: ");
 }
        public List <string> RouteTableQuery_req(RoutingProtocol rc, string node1, string node2)        //Otrzymanie informacji o drogę przed podsieć
        {
            Disp.ViewOnScreen("[RC]: Preparing possible path!");
            Disp.ViewOnScreen("[RC]: Source: " + node1 + " Target: " + node2);
            List <string> path = rc.ShortestPath(node1, node2);

            return(path);
        }
Exemple #12
0
 public void CallTeardown_rsp(NetworkMessage msg) //przesyłami pierwszemu klientowi, że ten drugi nie zgodził sie na zerwanie połączenia
 {
     msg.src     = myNCC.port;
     msg.dst     = myNCC.callingpcc_port;
     msg.payload = "CALL_TEARDOWN_RSP=FALSE";
     ncc.Send(msg.ToBytes());
     Disp.ViewOnScreen("[NCC -> CPCC] Call Teardown - response.");
 }
Exemple #13
0
 public void CallCoordinationTeardown_req(NetworkMessage msg) //informowanie drugiej domeny o chęci zakończenia połączenia
 {
     msg.src     = myNCC.port;
     msg.dst     = myNCC.ncc_port;
     msg.payload = "CALL_COORDINATION_TEARDOWN_REQ";
     ncc.Send(msg.ToBytes());
     Disp.ViewOnScreen("[NCC -> NCC] Call Coordination Teardown - request.");
 }
        public void LinkRestoration(string src, string dst)
        {
            lrm.SNPReleaseResources_req(src, dst, Channels);
            Disp.ViewOnScreen("[CC -> RC] Route Table Query - request.");
            List <string> new_path = rc.ShortestPath(src, dst);

            Disp.ViewOnScreen("[RC -> CC] Route Table Query - response. Path: " + string.Join(" ", new_path.ToArray()));
            lrm.SNPLinkConnectionRequest_req(new_path, Channels);
        }
Exemple #15
0
        public void CallCoordination_req(NetworkMessage msg)//Adres domeny, Adres2, SNPP z innej domeny) //Zestawienie połączenia miedzydomenowego. On już wie ze tu wszystko zestawione wiec mowi to dla NCC obok
        {
            msg.src = myNCC.port;
            msg.dst = myNCC.ncc_port;
            string str = msg.payload.Replace("CONNECTION_REQUEST_RSP=TRUE,NEXT_DOMAIN=TRUE", "");

            msg.payload = "CALL_COORDINATION_REQ " + myNCC.callingpcc_port + " " + myNCC.calledpcc_port + " " + myNCC.hostcap + str;
            ncc.Send(msg.ToBytes());
            Disp.ViewOnScreen("[NCC -> NCC] Call Coordination - request.");
            Disp.ViewOnScreen(msg.ToString());
        }
        private List <int> getChannels(int slotsNum)
        {
            List <int> temp = new List <int>();

            for (int i = 0; i < slotsNum; i++)
            {
                temp.Add(ChannelsAvailable[0]);
                ChannelsAvailable.RemoveAt(0);
            }
            Disp.ViewOnScreen("[RC]: SLOTS CHOSE: " + string.Join(" ", temp.ToArray()));
            return(temp);
        }
 private void SendCallback(IAsyncResult ar)
 {
     try
     {
         Socket client    = (Socket)ar.AsyncState;
         int    bytesSent = client.EndSend(ar);
         sendDone.Set();
     }
     catch (Exception e)
     {
         Disp.ViewOnScreen(e.ToString());
     }
 }
Exemple #18
0
 public void CallAccept_req(NetworkMessage msg) //Czy akceptujesz takie zgłoszenie?
 {
     msg.src = myNCC.port;
     msg.dst = myNCC.calledpcc_port;
     if (NCC.flag == 0)
     {
         msg.payload = "CALL_ACCEPT_REQ,NEXT_DOMAIN=FALSE";
     }
     else if (NCC.flag == 1)
     {
         msg.payload = "CALL_ACCEPT_REQ,NEXT_DOMAIN=TRUE";
     }
     ncc.Send(msg.ToBytes());
     Disp.ViewOnScreen("[NCC -> CPCC] Call Accept - request.");
 }
Exemple #19
0
        //CALL TEARDOWN

        public void CallTeardown_req(NetworkMessage msg) //Czy akceptujesz zakończenie połączenia?
        {
            Disp.ViewOnScreen("[NCC -> NCC] Call Coordination Teardown - request.");
            msg.src = myNCC.port;
            msg.dst = myNCC.calledpcc_port;
            if (NCC.flag == 0)
            {
                msg.payload = "CALL_TEARDOWN_REQ,NEXT_DOMAIN=FALSE";
            }
            else if (NCC.flag == 1)
            {
                msg.payload = "CALL_TEARDOWN_REQ,NEXT_DOMAIN=TRUE";
            }
            ncc.Send(msg.ToBytes());
            Disp.ViewOnScreen("[NCC -> CPCC] Call Teardown - request.");
        }
Exemple #20
0
 public void CallCoordination_rsp(NetworkMessage msg, bool p) //Przekazuje czy zezwolone polaczenie czy nie (jak nie to musi do CC i zwolnic zasoby!)
 {
     msg.src = myNCC.port;
     msg.dst = myNCC.ncc_port;
     if (p == false)
     {
         msg.payload = "CALL_COORDINATION_RSP=FALSE";
         Disp.ViewOnScreen("[NCC -> NCC] Call Coordination Teardown - response.");
     }
     else
     {
         msg.payload = "CALL_COORDINATION_RSP=TRUE";
         Disp.ViewOnScreen("[NCC -> NCC] Call Coordination - response.");
     }
     ncc.Send(msg.ToBytes());
 }
 public void SendData()
 {
     while (true)
     {
         foreach (var host in hosts)
         {
             //Console.WriteLine("wchodzi");
             NetworkMessage msg = new NetworkMessage(Client.name, gate, "DATASTREAM");
             nc.Send(msg.ToBytes());
             Disp.ViewOnScreen(msg.ToString());
             //AddCalledHost(host);
             //ConfirmHostDelete();
         }
         Thread.Sleep(10000);
     }
 }
Exemple #22
0
        public void CallRequest_rsp(IPAddress src, IPAddress dst, bool p) //Możesz zrstawiac połączenie jeśli SUCCESS, nie możesz jeśli FAIL
        {
            NetworkMessage msg;

            if (p == false)
            {
                msg = new NetworkMessage(myNCC.port, myNCC.callingpcc_port, src, dst, 0, "CALL_REQUEST_RESPONSE=FAIL");
                Disp.ViewOnScreen("[NCC -> CPCC] Call Teardown - response.");
            }
            else
            {
                msg = new NetworkMessage(myNCC.port, myNCC.callingpcc_port, src, dst, 0, "CALL_REQUEST_RESPONSE=SUCCESS");
                Disp.ViewOnScreen("[NCC -> CPCC] Call Request - response.");
            }
            ncc.Send(msg.ToBytes());
        }
Exemple #23
0
 public void ConnectionRequest_req(NetworkMessage msg, bool p) //Podajemy adresy portów pomiedzy którymi połaczenie ma być zestawione
 {
     msg.src = myNCC.port;
     msg.dst = myNCC.cc_port;
     if (p == false)
     {
         msg.payload = "CONNECTION_REQUEST=FAIL " + myNCC.realname1 + " " + myNCC.realname2 + " " + myNCC.hostcap;
     }
     else
     {
         msg.payload = "CONNECTION_REQUEST " + myNCC.realname1 + " " + myNCC.realname2 + " " + myNCC.hostcap + " " + myNCC.slots;
     }
     ncc.Send(msg.ToBytes());
     Disp.ViewOnScreen($"[NCC -> CC] Connection Request - request.");
     myNCC.slots = "";
 }
        private void ReceiveCallback(IAsyncResult ar)
        {
            try
            {
                Socket client    = (Socket)ar.AsyncState;
                int    bytesRead = client.EndReceive(ar);

                if (bytesRead > 0)
                {
                    byte[] msg = HandleMessage(receive_buffer);
                    //Send(msg);
                    receiveDone.Set();
                }
            }
            catch (Exception e)
            {
                Disp.ViewOnScreen(e.ToString());
            }
        }
Exemple #25
0
        private void ReadCallback(IAsyncResult ar)
        {
            SocketState state   = (SocketState)ar.AsyncState;
            int         n_bytes = state.socket.EndReceive(ar);

            if (n_bytes > 0)
            {
                NetworkMessage packet = new NetworkMessage(state.receive_buffer);
                if (!packet.dst.Equals("DELETE"))
                {
                    Disp.ViewOnScreen(packet.ToString());
                    //logs.AddLog(packet.ToString());
                    Socket socket = socket_states.Find(x => x.device.Equals(packet.dst)).socket;
                    if (socket != null)
                    {
                        Send(socket, state.receive_buffer);
                    }
                }
            }

            state.receive_buffer = new byte[256];
            state.begin_receive.Set();
        }
 public void ConnectionTeardown_rsp(NetworkMessage msg)
 {
     if (NextDomain == false)
     {
         Disp.ViewOnScreen("[CC]: CONNECTION TEARDOWN REQUEST - RESPONSE: Teardown succesful!");
         msg.payload = "CONNECTION_REQUEST_RSP=FALSE,NEXT_DOMAIN=FALSE";
         //*********** Tu jest jakas lekka beka
         string temp = msg.dst;
         msg.dst = msg.src;
         msg.src = temp;
         nc.Send(msg.ToBytes());
     }
     else if (NextDomain == true)
     {
         Disp.ViewOnScreen("[CC]: CONNECTION TEARDOWN REQUEST - RESPONSE: Teardown succesful! Next Domain!");
         msg.payload = "CONNECTION_REQUEST_RSP=FALSE,NEXT_DOMAIN=TRUE";
         //*********** Tu jest jakas lekka beka
         string temp = msg.dst;
         msg.dst = msg.src;
         msg.src = temp;
         nc.Send(msg.ToBytes());
     }
 }
        static private byte[] HandleMessage(byte[] asset)
        {
            NetworkMessage msg = new NetworkMessage(asset);

            Disp.ViewOnScreen(msg.ToString("Message received: "));
            string[] payload = msg.payload.Split();
            payload[0] = payload[0].TrimEnd(new char[] { (char)0 });
            if (payload[0].Equals("CALL_REQUEST_RESPONSE=FAIL"))
            {
                myCPCC.stream_gen.ConfirmHostDelete();
            }
            else if (payload[0].Equals("CALL_REQUEST_RESPONSE=SUCCESS"))
            {
                myCPCC.stream_gen.ConfirmHost();
            }
            else if (payload[0].Equals("CALL_ACCEPT_REQ,NEXT_DOMAIN=TRUE"))
            {
                myCPCC.CallAccept_rsp(msg, nc, true);
            }
            else if (payload[0].Equals("CALL_ACCEPT_REQ,NEXT_DOMAIN=FALSE"))
            {
                myCPCC.CallAccept_rsp(msg, nc, false);
            }
            else if (payload[0].Equals("CALL_TEARDOWN_REQ,NEXT_DOMAIN=TRUE"))
            {
                myCPCC.CallTeardown_rsp(msg, nc, true);
            }
            else if (payload[0].Equals("CALL_TEARDOWN_REQ,NEXT_DOMAIN=FALSE"))
            {
                myCPCC.CallTeardown_rsp(msg, nc, false);
            }
            else if (payload[0].Equals("CALL_TEARDOWN_RSP=FALSE"))
            {
                Disp.ViewOnScreen("Response from NCC: Called Party Call Controller refused to disconnect.");
            }
            return(msg.ToBytes());
        }
        static void Main(string[] args)
        {
            Config(myCPCC, args[0]);
            Disp.ViewOnScreen($"*** CLI {name} ***");
            Disp.ViewOnScreen($"Commands: callrequest DST CAP, teardownrequest DST CAP");
            NetClient nc = new NetClient(HandleMessage, name);

            Client.nc = nc;
            Task.Run(() => nc.ListenForMessages());

            while (true)
            {
                string[] str = Console.ReadLine().Split();

                switch (str[0])
                {
                case "interrupt":
                    break;

                case "callrequest":     //callrequest DST CAP
                    myCPCC.CallRequest_req(name, str[1], int.Parse(str[2]), nc);
                    break;

                case "teardownrequest":     //teardownrequest DST CAP
                    myCPCC.CallTeardown_req(str[1], int.Parse(str[2]), nc);
                    break;

                case "true":
                    Console.WriteLine("Confirm:");
                    break;

                default:
                    Console.WriteLine("Incorrect command");
                    break;
                }
            }
        }
Exemple #29
0
        static private byte[] HandleMessage(byte[] asset)
        {
            //tutaj jest kod do obslugi wiadomosci przychodzacej
            NetworkMessage msg = new NetworkMessage(asset);

            string[] payload = msg.payload.Split();
            if (payload[0].Equals("CALL_REQUEST"))
            {
                Disp.ViewOnScreen($"[CPCC -> NCC] Call Request - request.");
                myNCC.callingpcc_port = msg.src;
                myNCC.calledpcc_port  = payload[2];
                myNCC.hostcap         = payload[3];
                Disp.ViewOnScreen($"[NCC -> D] Directory Request - request: {payload[1]} to {payload[2]} ");
                msg = myNCC.DirectoryRequest_req(msg);


                Disp.ViewOnScreen($"[D -> NCC] SNPP1: {msg.src_addr} SNPP2: {msg.dst_addr}");
                bool     l;
                string[] payload2 = msg.payload.Split();
                if (payload2[0] != "CONNECTION_REQUEST=FAIL")
                {
                    myNCC.realname1 = payload2[1];
                    myNCC.realname2 = payload2[2];
                    Disp.ViewOnScreen($"[NCC -> P] Policy Request - request: {msg.src_addr} to {msg.dst_addr}, cap:{myNCC.hostcap}");
                    l = myNCC.Policy_req(msg.src_addr, msg.dst_addr, int.Parse(payload[3]));
                    Disp.ViewOnScreen($"[P -> NCC] Connection Allowed!");
                }
                else
                {
                    l = false;
                }

                if (l == false)
                {
                    Disp.ViewOnScreen($"[P -> NCC] Connection Disallowed!");
                    myNCC.CallRequest_rsp(msg.src_addr, msg.dst_addr, false);
                }
                else
                {
                    myNCC.ConnectionRequest_req(msg, true);
                }
            }
            else if (payload[0].Equals("CONNECTION_REQUEST_RSP=FALSE,NEXT_DOMAIN=FALSE"))
            {
                Disp.ViewOnScreen($"[CC -> NCC] Connection Request - response.");
                myNCC.CallRequest_rsp(msg.src_addr, msg.dst_addr, false);
            }
            else if (payload[0].Equals("CONNECTION_REQUEST_RSP=FALSE,NEXT_DOMAIN=TRUE"))
            {
                Disp.ViewOnScreen($"[CC -> NCC] Connection Request - response.");
                NCC.flag = 0;
                myNCC.CallCoordination_rsp(msg, false);
            }
            else if (payload[0].Equals("CONNECTION_REQUEST_RSP=TRUE,NEXT_DOMAIN=FALSE"))
            {
                Disp.ViewOnScreen($"[CC -> NCC] Connection Request - response.");
                myNCC.CallAccept_req(msg);
            }
            else if (payload[0].Equals("CONNECTION_REQUEST_RSP=TRUE,NEXT_DOMAIN=TRUE"))
            {
                Disp.ViewOnScreen($"[CC -> NCC] Connection Request - response.");
                myNCC.CallCoordination_req(msg);
            }
            else if (payload[0].Equals("CALL_ACCEPT_RSP=TRUE,NEXT_DOMAIN=FALSE"))
            {
                Disp.ViewOnScreen($"[CPCC -> NCC] Call Accept - response.");
                myNCC.CallRequest_rsp(msg.src_addr, msg.dst_addr, true);
            }
            else if (payload[0].Equals("CALL_ACCEPT_RSP=TRUE,NEXT_DOMAIN=TRUE"))
            {
                Disp.ViewOnScreen($"[CPCC -> NCC] Call Accept - response.");
                NCC.flag = 0;
                myNCC.CallCoordination_rsp(msg, true);
            }
            else if (payload[0].Equals("CALL_ACCEPT_RSP=FALSE"))
            {
                Disp.ViewOnScreen($"[CPCC -> NCC] Call Accept - response.");
                myNCC.ConnectionRequest_req(msg, false);
            }
            else if (payload[0].Equals("CALL_COORDINATION_RSP=TRUE"))
            {
                Disp.ViewOnScreen($"[NCC -> NCC] Call Coordination - response.");
                myNCC.CallRequest_rsp(msg.src_addr, msg.dst_addr, true);
            }
            else if (payload[0].Equals("CALL_COORDINATION_RSP=FALSE"))
            {
                Disp.ViewOnScreen($"[NCC -> NCC] Call Coordination Teardown - response.");
                myNCC.ConnectionRequest_req(msg, false);
            }
            else if (payload[0].Equals("CALL_COORDINATION_REQ"))
            {
                NCC.flag             = 1;
                myNCC.hostcap        = payload[3];
                myNCC.calledpcc_port = payload[2];

                string str = msg.payload;
                myNCC.slots = str.Replace(payload[0] + " " + payload[1] + " " + payload[2] + " " + payload[3] + " ", "");
                Disp.ViewOnScreen($"[NCC -> D] Directory Request - request: {payload[1]} to {payload[2]} ");
                msg = myNCC.DirectoryRequest_req(msg);
                string[] payload2 = msg.payload.Split();
                myNCC.realname1 = payload2[1];
                myNCC.realname2 = payload2[2];
                Disp.ViewOnScreen($"[NCC -> NCC] Call Coordination - request.");
                myNCC.ConnectionRequest_req(msg, true);
            }

            //CALL TEARDOWN
            else if (payload[0].Equals("CALL_TEARDOWN_REQ"))
            {
                Disp.ViewOnScreen($"[CPCC -> NCC] Call Teardown - request.");
                myNCC.callingpcc_port = msg.src;
                myNCC.calledpcc_port  = payload[2];
                myNCC.hostcap         = payload[3];
                // Disp.ViewOnScreen($"Sending directory request: {payload[1]} to {payload[2]} ");

                msg = myNCC.DirectoryRequest_req(msg);
                string[] payload2 = msg.payload.Split();
                if (payload2[0] != "CONNECTION_REQUEST=FAIL")
                {
                    myNCC.realname1 = payload2[1];
                    myNCC.realname2 = payload2[2];
                    if (myNCC.callingpcc_port == "H1")
                    {
                        if (myNCC.calledpcc_port == "H2")
                        {
                            myNCC.CallTeardown_req(msg);
                        }
                        if (myNCC.calledpcc_port == "H3")
                        {
                            myNCC.CallCoordinationTeardown_req(msg);
                        }
                    }
                    else if (myNCC.callingpcc_port == "H2")
                    {
                        if (myNCC.calledpcc_port == "H1")
                        {
                            myNCC.CallTeardown_req(msg);
                        }
                        if (myNCC.calledpcc_port == "H3")
                        {
                            myNCC.CallCoordinationTeardown_req(msg);
                        }
                    }
                    else if (myNCC.callingpcc_port == "H3")
                    {
                        if (myNCC.calledpcc_port == "H2")
                        {
                            myNCC.CallCoordinationTeardown_req(msg);
                        }
                        if (myNCC.calledpcc_port == "H1")
                        {
                            myNCC.CallCoordinationTeardown_req(msg);
                        }
                    }
                }
                else
                {
                    myNCC.CallTeardown_rsp(msg);
                }
            }

            else if (payload[0].Equals("CALL_COORDINATION_TEARDOWN_REQ"))
            {
                NCC.flag = 1;
                myNCC.CallTeardown_req(msg);
            }
            else if (payload[0].Equals("CALL_TEARDOWN_RSP=TRUE"))
            {
                Disp.ViewOnScreen($"[CPCC -> NCC] Call Teardown - response.");
                myNCC.ConnectionRequest_req(msg, false);
            }
            else if (payload[0].Equals("CALL_TEARDOWN_RSP=FALSE,NEXT_DOMAIN=FALSE"))
            {
                myNCC.CallTeardown_rsp(msg);
            }
            else if (payload[0].Equals("CALL_TEARDOWN_RSP=FALSE,NEXT_DOMAIN=TRUE"))
            {
                NCC.flag = 0;
                myNCC.CallCoordinationTeardown_rsp(msg);
            }
            else if (payload[0].Equals("CALL_COORDINATION_RSP=FALSE"))
            {
                myNCC.CallTeardown_rsp(msg);
            }


            return(msg.ToBytes());
        }