[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip ProtocolStack.java,1.26,1.27 Tcp.java,1.18,1.1
Status: Beta
Brought to you by:
darkkey
From: gift <gi...@us...> - 2005-12-01 18:37:25
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4473/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Tcp.java Log Message: BUGGGGED timer Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** ProtocolStack.java 1 Dec 2005 15:03:28 -0000 1.26 --- ProtocolStack.java 1 Dec 2005 18:37:16 -0000 1.27 *************** *** 152,156 **** mICMPprotocol = new ICMP(this); ! mTCPprotocol = new Tcp(this); //gift (sourceforge.net user) 25 Nov 2005 --- 152,156 ---- mICMPprotocol = new ICMP(this); ! mTCPprotocol = new Tcp(this); //gift (sourceforge.net user) 25 Nov 2005 Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Tcp.java 1 Dec 2005 16:54:54 -0000 1.18 --- Tcp.java 1 Dec 2005 18:37:16 -0000 1.19 *************** *** 78,81 **** --- 78,84 ---- import core.protocolsuite.tcp_ip.ProtocolStack; + import java.util.Timer; + + import java.util.TimerTask; *************** *** 160,164 **** public boolean isFIN_sent; public boolean isFIN_confirmed; ! public boolean isPassive; public void reset() --- 163,169 ---- public boolean isFIN_sent; public boolean isFIN_confirmed; ! public boolean isPassive; ! ! public Timer timer=null; //our timer for this connection public void reset() *************** *** 228,232 **** this.isFIN_sent=false; this.isFIN_confirmed=false; ! this.isPassive=false; } } --- 233,238 ---- this.isFIN_sent=false; this.isFIN_confirmed=false; ! this.isPassive=false; ! if (timer!=null) this.timer.cancel(); } } *************** *** 242,246 **** private static final int TOTAL_TIME = 10; //seconds to send all data private static final int ACCELER_KOEFF=2; //coeff depends on line quality, in practise >=2 ! /** * This method assigns the ParentStack --- 248,253 ---- private static final int TOTAL_TIME = 10; //seconds to send all data private static final int ACCELER_KOEFF=2; //coeff depends on line quality, in practise >=2 ! private static final double TCP_TIME= 0.1; //sec ! /** * This method assigns the ParentStack *************** *** 259,266 **** Elm.reset(); PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // DANGEROUS PLACE! Check before change. ! } } /** * This method reserves LOCAL port number for an application in case reserved. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] --- 266,323 ---- Elm.reset(); PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // DANGEROUS PLACE! Check before change. ! } } + /** + * This method defines TCP timer + * @author gift (sourceforge.net user) + * @param Elm TCP_HashTableElement + * @version v0.10 + */ + public void TCPsetTimer(TCP_HashTableElement Elm) + { + Elm.timer=new Timer(); + Elm.timer.schedule(new TCPTask(Elm),0,500); + } + + public class TCPTask extends TimerTask + { + private TCP_HashTableElement Elm; + + public TCPTask (TCP_HashTableElement inElm) + { + this.Elm=inElm; + } + + + /** + * This methos implements TCP timer + * @author gift (sourceforge.net user) + * @param Elm TCP_HashTableElement + * @version v0.10 + */ + public void run() + { + System.out.println("Timer start!"); + if(!Elm.SegmentsToResend.isEmpty()) + { + Enumeration HTkeys; + Integer curkey; + HTkeys = Elm.SegmentsToResend.keys(); + while (HTkeys.hasMoreElements()) + { + curkey= (Integer) HTkeys.nextElement(); + try{ + mParentStack.sendPacket((TCP_packet)Elm.SegmentsToResend.get(curkey)); + } catch (Exception e) {} + } + } + else { + System.out.println("Timer cancel!"); Elm.timer.cancel(); + } + } + } + /** * This method reserves LOCAL port number for an application in case reserved. Port number range: [PORT_START_NUMBER; PORT_START_NUMBER+PORT_QUANT] *************** *** 688,691 **** --- 745,750 ---- if (flags[5]) Elm.isFIN_sent=true; + TCPsetTimer(Elm); + Elm=null; //Create Layer info *************** *** 703,706 **** --- 762,766 ---- Simulation.addLayerInfo(TCP_Info); + return tosend; } else{ *************** *** 1123,1126 **** --- 1183,1188 ---- return tosend_clone; } + + |