[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip Echo.java,1.16,1.17 Echo_tcp.java,1.17,1.18 Ro
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-12-08 20:11:38
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16673/core/protocolsuite/tcp_ip Modified Files: Echo.java Echo_tcp.java Route_entry.java Log Message: New Echo (v2) implementation. Index: Route_entry.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Route_entry.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Route_entry.java 1 Dec 2005 14:54:37 -0000 1.4 --- Route_entry.java 8 Dec 2005 20:10:56 -0000 1.5 *************** *** 2,6 **** * Route_entry.java * ! * Created on 7 Nov 2005 Ç., 17:52 * * To change this template, choose Tools | Options and locate the template under --- 2,6 ---- * Route_entry.java * ! * Created on 7 Nov 2005, 17:52 * * To change this template, choose Tools | Options and locate the template under Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Echo_tcp.java 8 Dec 2005 19:35:07 -0000 1.17 --- Echo_tcp.java 8 Dec 2005 20:10:56 -0000 1.18 *************** *** 30,39 **** private byte ConnectionAttempts=5; ! private int tryings; /** Creates a new instance of Echo */ public Echo_tcp(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); ! tryings = 0; } --- 30,39 ---- private byte ConnectionAttempts=5; ! private int counts; /** Creates a new instance of Echo */ public Echo_tcp(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); ! counts = 0; } *************** *** 46,50 **** //throw new TransportLayerException("Cannot bind port " + listenPort + "."); try{ ! if(appType == 1) mParentStack.ListenTCP(this, listenPort); } catch (TransportLayerException e) { --- 46,50 ---- //throw new TransportLayerException("Cannot bind port " + listenPort + "."); try{ ! if(appType != 0) mParentStack.ListenTCP(this, listenPort); } catch (TransportLayerException e) { *************** *** 124,128 **** protInfo3.setDataType("Echo Protocol Data"); protInfo3.setLayer("Application "); ! protInfo3.setDescription("Application closing connection. Now listening on " + listenPort + "."); Simulation.addLayerInfo(protInfo3); --- 124,132 ---- protInfo3.setDataType("Echo Protocol Data"); protInfo3.setLayer("Application "); ! if(appType==0){ ! protInfo3.setDescription("Application closing connection."); ! }else{ ! protInfo3.setDescription("Application closing connection. Now listening on " + listenPort + "."); ! } Simulation.addLayerInfo(protInfo3); *************** *** 174,178 **** protInfo.setDescription("Recieving echo message '" + Data + "' from server."); Simulation.addLayerInfo(protInfo);*/ ! Disconnect(); }else{ --- 178,192 ---- protInfo.setDescription("Recieving echo message '" + Data + "' from server."); Simulation.addLayerInfo(protInfo);*/ ! ! if(this.counts==0){ ! Disconnect(); ! }else{ ! this.counts--; ! try { ! SendData(Data); ! }catch(Exception e){ ! ///*TODO*: here to catch ! } ! } }else{ *************** *** 192,204 **** protInfo2.setDescription("Sending echo message '" + Data + "' to client."); Simulation.addLayerInfo(protInfo2); ! try { SendData(Data); }catch(Exception e){ ///*TODO*: here to catch } ! ! // Disconnect(); ! ! // Listen(); } } --- 206,216 ---- protInfo2.setDescription("Sending echo message '" + Data + "' to client."); Simulation.addLayerInfo(protInfo2); ! ! try { SendData(Data); }catch(Exception e){ ///*TODO*: here to catch } ! } } *************** *** 213,220 **** * @version v0.02 */ ! public void SendEcho(String Data, String Host, int port) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ mParentStack.FreeTCPApplication(this); ! if (ClientConnect(Host, port)) --- 225,232 ---- * @version v0.02 */ ! public void SendEcho(String Data, String Host, int port, int counts) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ mParentStack.FreeTCPApplication(this); ! this.counts = counts; if (ClientConnect(Host, port)) *************** *** 227,230 **** --- 239,243 ---- Simulation.addLayerInfo(protInfo); + this.counts--; SendData(Data); *************** *** 237,241 **** protInfo.setDescription("Error: can not connect to " + Host + ":" + port + "!"); Simulation.addLayerInfo(protInfo); ! } } --- 250,254 ---- protInfo.setDescription("Error: can not connect to " + Host + ":" + port + "!"); Simulation.addLayerInfo(protInfo); ! this.counts=0; } } Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Echo.java 27 Nov 2005 20:14:12 -0000 1.16 --- Echo.java 8 Dec 2005 20:10:56 -0000 1.17 *************** *** 181,187 **** * @version v0.01 */ ! public void SendEcho(String Data, String Host, int port) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ mParentStack.FreeUDPApplication(this); if (ClientConnect(Host, port)) { --- 181,188 ---- * @version v0.01 */ ! public void SendEcho(String Data, String Host, int port, int counts) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException{ mParentStack.FreeUDPApplication(this); + for(int c=0; c<counts; c++){ if (ClientConnect(Host, port)) { *************** *** 202,206 **** --- 203,209 ---- protInfo.setDescription("Error: can not connect to " + Host + ":" + port + "!"); Simulation.addLayerInfo(protInfo); + c=counts; } + } } |