[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip Application.java,1.12,1.13 Echo.java,1.15,1.16
Status: Beta
Brought to you by:
darkkey
From: gift <gi...@us...> - 2005-11-27 20:14:21
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13129/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Echo_tcp.java ProtocolStack.java Log Message: New better working version! Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ProtocolStack.java 27 Nov 2005 18:17:34 -0000 1.19 --- ProtocolStack.java 27 Nov 2005 20:14:12 -0000 1.20 *************** *** 1595,1600 **** boolean flags[]={false,false,false,false,true,false}; /* URG, ACK, PSH, RST, !SYN!, FIN */ rval=mTCPprotocol.ReservePort(application, inDestIPAddress, indestPort); ! sendTCPSegment(application, msg, flags); ! return rval; } --- 1595,1600 ---- boolean flags[]={false,false,false,false,true,false}; /* URG, ACK, PSH, RST, !SYN!, FIN */ rval=mTCPprotocol.ReservePort(application, inDestIPAddress, indestPort); ! if (sendTCPSegment(application, msg, flags)) ! return rval; else return 0; } *************** *** 1654,1658 **** */ ! public void sendTCPSegment(Object application, String inTCPMessage, boolean flags[]) throws LowLinkException, CommunicationException { String FirstInterfaceName; --- 1654,1658 ---- */ ! public boolean sendTCPSegment(Object application, String inTCPMessage, boolean flags[]) throws LowLinkException, CommunicationException { String FirstInterfaceName; *************** *** 1689,1693 **** }catch(Exception e){ ! try { LayerInfo TCP_Info = new LayerInfo(getClass().getName()); --- 1689,1693 ---- }catch(Exception e){ ! //try { LayerInfo TCP_Info = new LayerInfo(getClass().getName()); *************** *** 1697,1702 **** TCP_Info.setDescription("TCP sending error: \""+ e.toString() + "\"."); Simulation.addLayerInfo(TCP_Info); ! ! mTCPprotocol.ClosePort(application); } catch (TransportLayerException te) { --- 1697,1702 ---- TCP_Info.setDescription("TCP sending error: \""+ e.toString() + "\"."); Simulation.addLayerInfo(TCP_Info); ! return false; ! /* mTCPprotocol.ClosePort(application); } catch (TransportLayerException te) { *************** *** 1707,1713 **** TCP_Info.setDescription("TCP port freeing: \""+ te.toString() + "\"."); Simulation.addLayerInfo(TCP_Info); ! } } } --- 1707,1714 ---- TCP_Info.setDescription("TCP port freeing: \""+ te.toString() + "\"."); Simulation.addLayerInfo(TCP_Info); ! } */ } + return true; } Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Application.java 26 Nov 2005 16:48:25 -0000 1.12 --- Application.java 27 Nov 2005 20:14:11 -0000 1.13 *************** *** 65,69 **** */ ! public abstract void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException; /** --- 65,69 ---- */ ! public abstract boolean ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException; /** Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Echo_tcp.java 27 Nov 2005 18:17:34 -0000 1.6 --- Echo_tcp.java 27 Nov 2005 20:14:12 -0000 1.7 *************** *** 68,75 **** */ ! public void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException { sdHost = Host; sdPort = port; ! clientPort = mParentStack.ConnectTCP(this, sdHost, sdPort); } --- 68,76 ---- */ ! public boolean ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException { sdHost = Host; sdPort = port; ! clientPort = mParentStack.ConnectTCP(this, sdHost, sdPort); ! if (clientPort>0) return true; else return false; } *************** *** 184,199 **** */ public void SendEcho(String Data, String Host, int port) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ ! //mParentStack.FreeUDPApplication(this); ! ClientConnect(Host, port); ! ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Start sending echo message '" + Data + "' to " + Host + ":" + port); ! Simulation.addLayerInfo(protInfo); ! ! SendData(Data); } --- 185,209 ---- */ public void SendEcho(String Data, String Host, int port) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ ! mParentStack.FreeTCPApplication(this); ! if (ClientConnect(Host, port)) ! { ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Start sending echo message '" + Data + "' to " + Host + ":" + port); ! Simulation.addLayerInfo(protInfo); ! ! SendData(Data); ! } else ! { ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Error: can not connect to " + Host + ":" + port + "!"); ! Simulation.addLayerInfo(protInfo); ! } } Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Echo.java 26 Nov 2005 16:48:25 -0000 1.15 --- Echo.java 27 Nov 2005 20:14:12 -0000 1.16 *************** *** 68,75 **** */ ! public void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException { sdHost = Host; sdPort = port; clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); } --- 68,76 ---- */ ! public boolean ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException { sdHost = Host; sdPort = port; clientPort = mParentStack.reserveUDPPort(this, sdHost, sdPort); + if (clientPort>0) return true; else return false; } *************** *** 183,196 **** mParentStack.FreeUDPApplication(this); ! ClientConnect(Host, port); ! ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Start sending echo message '" + Data + "' to " + Host + ":" + port); ! Simulation.addLayerInfo(protInfo); ! ! SendData(Data); } --- 184,206 ---- mParentStack.FreeUDPApplication(this); ! if (ClientConnect(Host, port)) ! { ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Start sending echo message '" + Data + "' to " + Host + ":" + port); ! Simulation.addLayerInfo(protInfo); ! ! SendData(Data); ! } else ! { ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Error: can not connect to " + Host + ":" + port + "!"); ! Simulation.addLayerInfo(protInfo); ! } } |