[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip ProtocolStack.java,1.14,1.15 Tcp.java,1.2,1.3
Status: Beta
Brought to you by:
darkkey
From: gift <gi...@us...> - 2005-11-25 16:57:43
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20758/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Tcp.java Tcp_packet.java Udp.java Log Message: TCP structure && new revision of UDP Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ProtocolStack.java 21 Nov 2005 15:27:53 -0000 1.14 --- ProtocolStack.java 25 Nov 2005 16:57:35 -0000 1.15 *************** *** 155,159 **** mICMPprotocol = new ICMP(this); ! mTCPprotocol = new Tcp(); mUDPprotocol = new Udp(this); //gift (sourceforge.net user) 17 Nov 2005 --- 155,159 ---- mICMPprotocol = new ICMP(this); ! mTCPprotocol = new Tcp(this); //gift (sourceforge.net user) 25 Nov 2005 mUDPprotocol = new Udp(this); //gift (sourceforge.net user) 17 Nov 2005 Index: Tcp_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp_packet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Tcp_packet.java 25 Nov 2005 14:20:55 -0000 1.3 --- Tcp_packet.java 25 Nov 2005 16:57:35 -0000 1.4 *************** *** 94,100 **** private static final int RESERVED = 0; //not used ! private int sequence_number; ! private int acknowledgment_number; boolean flags[] = {false,false,false,false,false,false}; /* URG, ACK, PSH, RST, SYN, FIN */ --- 94,100 ---- private static final int RESERVED = 0; //not used ! private int sequence_number; //very very important field. It's value is used as an unique ID of each TCP_packet ! private int acknowledgment_number; //important field as well ;) boolean flags[] = {false,false,false,false,false,false}; /* URG, ACK, PSH, RST, SYN, FIN */ Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Udp.java 21 Nov 2005 15:27:53 -0000 1.24 --- Udp.java 25 Nov 2005 16:57:35 -0000 1.25 *************** *** 77,82 **** import core.protocolsuite.tcp_ip.ProtocolStack; - ///import core.protocolsuite.tcp_ip.UDP_HashTableElement; - /** --- 77,80 ---- *************** *** 108,116 **** * @author gift (sourceforge.net user) - * @since 17 Nov 2005 ! ! * @version v0.10 ! */ --- 106,111 ---- * @author gift (sourceforge.net user) * @since 17 Nov 2005 ! * @version v0.11 */ *************** *** 134,144 **** public byte PortStatus; // 0 - free port; 1 - port is being listened to; 2 - busy. public Object application; //points to application that listens to this port | provided PortStatus==1 ! public String connectedtoIP; //contains IP of the other connected computer | provided PortStatus==3 ! public int connectedtoPort; //contains port number of the other connected computer | provided PortStatus==3 } private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private static final int PORT_QUANT=100; //should be 100, only for dbg purposes private static final int PORT_START_NUMBER=3000; private static final int PORT_INIT = -1; //used in ListenPort && AlreadyListens --- 129,139 ---- public byte PortStatus; // 0 - free port; 1 - port is being listened to; 2 - busy. public Object application; //points to application that listens to this port | provided PortStatus==1 ! public String connectedtoIP; //contains IP of the other connected computer | provided PortStatus==2 ! public int connectedtoPort; //contains port number of the other connected computer | provided PortStatus==2 } private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private static final int PORT_QUANT=100; private static final int PORT_START_NUMBER=3000; private static final int PORT_INIT = -1; //used in ListenPort && AlreadyListens *************** *** 152,157 **** public Udp(ProtocolStack inParentStack) { - //String i; //String is port number :( such a pity but we use hash tables - //int j; //port number int i; --- 147,150 ---- *************** *** 167,171 **** ! PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // CHECK HERE } } --- 160,164 ---- ! PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // DANGEROUS PLACE! Check before change. } } Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Tcp.java 20 Nov 2005 20:30:53 -0000 1.2 --- Tcp.java 25 Nov 2005 16:57:35 -0000 1.3 *************** *** 1,43 **** /* Java Firewall Simulator (jFirewallSim) Copyright (c) 2004, jFirewallSim development team All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Canberra Institute of Technology nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package core.protocolsuite.tcp_ip; import java.io.Serializable; /** * This is for design and future implementation of TCP * @author luke_hamilton * @since Sep 17, 2004 * @version v0.20 */ ! public class Tcp implements Serializable{ } --- 1,156 ---- /* + Java Firewall Simulator (jFirewallSim) + + Copyright (c) 2004, jFirewallSim development team All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, this list + of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other + materials provided with the distribution. + - Neither the name of the Canberra Institute of Technology nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + package core.protocolsuite.tcp_ip; import java.io.Serializable; + import java.util.*; + + import core.CommunicationException; + + import core.LowLinkException; + + import core.LayerInfo; + + import core.Simulation; + + import core.TransportLayerException; + + import core.TransportLayerPortException; + + import core.InvalidNetworkLayerDeviceException; + + import core.protocolsuite.tcp_ip.ProtocolStack; + + + /** + * This is for design and future implementation of TCP + * @author luke_hamilton + * @since Sep 17, 2004 + * @version v0.20 + * + * @author gift (sourceforge.net user) + * @since 25 Nov 2005 + * @version v0.10 + */ ! ! ! ! public class Tcp implements Serializable ! { ! /* ! * TCP_HashTableElement.java ! * ! * Created on 25 November 2005, 17:33 ! */ ! ! /** ! * @author gift (sourceforge.net user) ! * @version v0.10, 25 Nov 2005 ! */ ! public class TCP_HashTableElement ! { ! public byte PortStatus; // 0 - free port; 1 - port is being listened to; 2 - busy. ! public Object application; //points to application that listens to this port | provided PortStatus==1 ! public String connectedtoIP; //contains IP of the other connected computer | provided PortStatus==2 ! public int connectedtoPort; //contains port number of the other connected computer | provided PortStatus==2 ! public Vector ReceivedSegments; //contains received segments ONLY sequence_number for each segment is stored ! public Vector ReceivedACKs; //contains received acknowledgments from destination computer ONLY sequence_number for each ACK segment is stored ! public Hashtable SegmentsToResend; //contains segments that will be resend in case no ACK for them will be received ! } ! ! private Hashtable PortTable = new Hashtable(); ! private ProtocolStack mParentStack; ! private static final int PORT_QUANT=100; ! private static final int PORT_START_NUMBER=3000; ! private static final int PORT_INIT = -1; //used in ListenPort && AlreadyListens ! ! /** ! * This method assigns the ParentStack ! * @author gift (sourceforge.net user) ! * @param inParentStack protocol stack ! * @version v0.20 ! */ ! public Tcp(ProtocolStack inParentStack) ! { ! int i; ! ! for(i=0;i<PORT_QUANT;i++) ! { ! TCP_HashTableElement Elm = new TCP_HashTableElement(); ! ! Elm.PortStatus=0; ! Elm.application=null; ! Elm.connectedtoIP=""; ! Elm.connectedtoPort=0; ! mParentStack = inParentStack; ! ! ! PortTable.put(new Integer((PORT_START_NUMBER+i)),Elm); // DANGEROUS PLACE! Check before change. ! } ! } } + |