javanetsim-cvs Mailing List for javaNetSim (Page 32)
Status: Beta
Brought to you by:
darkkey
You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(120) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(1) |
Feb
(69) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(76) |
Oct
(28) |
Nov
(77) |
Dec
(186) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(36) |
Oct
(61) |
Nov
(23) |
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(17) |
Oct
(105) |
Nov
(5) |
Dec
(1) |
2009 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(8) |
Oct
(9) |
Nov
|
Dec
|
From: gift <gi...@us...> - 2005-11-28 21:50:46
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27578/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java Tcp.java Log Message: OK here we go Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Tcp.java 28 Nov 2005 20:29:49 -0000 1.14 --- Tcp.java 28 Nov 2005 21:50:37 -0000 1.15 *************** *** 854,858 **** listener = (Application)Elm.application; //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! mParentStack.sendTCPSegment(listener,msg,flags); } else { --- 854,858 ---- listener = (Application)Elm.application; //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! // mParentStack.sendTCPSegment(listener,msg,flags); } else { *************** *** 864,868 **** listener = (Application)Elm.application; Elm.isFIN_confirmed=true; ! mParentStack.sendTCPSegment(listener,msg,flags); } else { --- 864,868 ---- listener = (Application)Elm.application; Elm.isFIN_confirmed=true; ! // mParentStack.sendTCPSegment(listener,msg,flags); } else { *************** *** 873,877 **** Application listener; listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); } ClosePort((Application)Elm.application); //FIN sent and confirmed!!! Closing connection --- 873,877 ---- Application listener; listener = (Application)Elm.application; ! // mParentStack.sendTCPSegment(listener,msg,flags); } ClosePort((Application)Elm.application); //FIN sent and confirmed!!! Closing connection *************** *** 931,935 **** if (rs>2) listener.RecvData(inPacket.getTCP_message()); ! if ((our_ack!=2 || Elm.sent_segments!=2) && Elm.PortStatus!=1) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established //we have sent last ACK and we can close TCP port now --- 931,935 ---- if (rs>2) listener.RecvData(inPacket.getTCP_message()); ! // if ((our_ack!=2 || Elm.sent_segments!=2) && Elm.PortStatus!=1) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established //we have sent last ACK and we can close TCP port now Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Echo_tcp.java 28 Nov 2005 20:29:49 -0000 1.9 --- Echo_tcp.java 28 Nov 2005 21:50:37 -0000 1.10 *************** *** 108,112 **** { ! mParentStack.SendTCP(this, Data); //processing the protocol doings. --- 108,112 ---- { ! // mParentStack.SendTCP(this, Data); //processing the protocol doings. |
From: gift <gi...@us...> - 2005-11-28 20:30:34
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10893/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java ProtocolStack.java Tcp.java Log Message: ttt Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ProtocolStack.java 27 Nov 2005 20:36:05 -0000 1.21 --- ProtocolStack.java 28 Nov 2005 20:29:49 -0000 1.22 *************** *** 1592,1599 **** { int rval; String msg=""; 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 -1; } --- 1592,1600 ---- { int rval; + int ack_num=-1; String msg=""; 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,ack_num)) return rval; else return -1; } *************** *** 1605,1608 **** --- 1606,1610 ---- * @author gift (sourceforge.net user) * @param application the application that sets the connection + * @param inTCPMessage string we want to send * @return Nothing * @exception CommunicationException *************** *** 1613,1620 **** */ ! public void SendTCP(Object application, String inTCPMessage) throws LowLinkException, CommunicationException { ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! sendTCPSegment(application, inTCPMessage, flags); } --- 1615,1623 ---- */ ! public void SendTCP(Object application, String inTCPMessage, int acknow_numb) throws LowLinkException, CommunicationException { ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! if (acknow_numb==-1) flags[1]=false; ! sendTCPSegment(application, inTCPMessage, flags, acknow_numb); } *************** *** 1622,1626 **** /** * This method sends the TCP segments ! * NOTE: call this method from application to send last TCP segment * @author gift (sourceforge.net user) * @param application the application that sets the connection --- 1625,1629 ---- /** * This method sends the TCP segments ! * NOTE: call this method from application to safe close TCP connection * @author gift (sourceforge.net user) * @param application the application that sets the connection *************** *** 1633,1640 **** */ ! public void SendFinalTCP(Object application, String inTCPMessage) throws LowLinkException, CommunicationException { ! boolean flags[]={false,true,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ ! sendTCPSegment(application, inTCPMessage, flags); } --- 1636,1645 ---- */ ! public void FinalizeTCP(Object application) throws LowLinkException, CommunicationException { ! int ack_num=-1; ! String msg=""; ! boolean flags[]={false,false,false,false,false,true}; /* URG, ACK, PSH, RST, SYN, !FIN! */ ! sendTCPSegment(application, msg, flags,ack_num); } *************** *** 1646,1649 **** --- 1651,1655 ---- * @param inTCPMessage TCP message to send * @param flags[] 6 flags to set in segment + * @param acknow_num int number of TCP segment that we want to confirm (-1 if we do not send ACK segment) * @return Nothing * @exception CommunicationException *************** *** 1654,1658 **** */ ! public boolean sendTCPSegment(Object application, String inTCPMessage, boolean flags[]) throws LowLinkException, CommunicationException { String FirstInterfaceName; --- 1660,1664 ---- */ ! public boolean sendTCPSegment(Object application, String inTCPMessage, boolean flags[], int acknow_num) throws LowLinkException, CommunicationException { String FirstInterfaceName; *************** *** 1680,1684 **** //let's get first interface IP address SourceIPAddress=getIPAddress(FirstInterfaceName); ! TCP_packet tosend = mTCPprotocol.sendTCPPacket(DestIPAddress,SourceIPAddress,destPort,srcPort,inTCPMessage,flags); //and sending out ;) sendPacket(tosend); --- 1686,1690 ---- //let's get first interface IP address SourceIPAddress=getIPAddress(FirstInterfaceName); ! TCP_packet tosend = mTCPprotocol.sendTCPPacket(DestIPAddress,SourceIPAddress,destPort,srcPort,inTCPMessage,flags,acknow_num); //and sending out ;) sendPacket(tosend); Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Tcp.java 27 Nov 2005 18:17:34 -0000 1.13 --- Tcp.java 28 Nov 2005 20:29:49 -0000 1.14 *************** *** 552,555 **** --- 552,556 ---- * @param inMessage TCP message to send * @param flags[] 6 flags to set in segment + * @param acknow_num int ack number of the segment we want to send * @return TCP_packet to send in Network Layer * @exception TransportLayerException *************** *** 558,562 **** */ ! public TCP_packet sendTCPPacket(String inDestIPAddress,String inSourceIPAddress, int indestPort, int insrcPort, String inMessage, boolean flags[]) throws TransportLayerException, LowLinkException { //check if window is available --- 559,563 ---- */ ! public TCP_packet sendTCPPacket(String inDestIPAddress,String inSourceIPAddress, int indestPort, int insrcPort, String inMessage, boolean flags[], int acknow_num) throws TransportLayerException, LowLinkException { //check if window is available *************** *** 723,733 **** String msg=""; boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ ! Application listener; listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet } else { //we have already received this segment Elm.received_duplicates++; } } else { //not a SYN packet - have to wait until SYN packet will come --- 724,739 ---- String msg=""; boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ ! Application listener;int ack_num=1; listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags,ack_num); //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet } else { //we have already received this segment Elm.received_duplicates++; + String msg=""; + boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ + Application listener;int ack_num=1; + listener = (Application)Elm.application; + mParentStack.sendTCPSegment(listener,msg,flags,ack_num); } } else { //not a SYN packet - have to wait until SYN packet will come *************** *** 775,787 **** //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! String msg=""; boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ Application listener; listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet } else { //we have already received this segment Elm.received_duplicates++; } --- 781,798 ---- //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! String msg="";int ack_num=1; boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ Application listener; listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags, ack_num); //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet } else { //we have already received this segment Elm.received_duplicates++; + String msg=""; + boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ + Application listener;int ack_num=1; + listener = (Application)Elm.application; + mParentStack.sendTCPSegment(listener,msg,flags,ack_num); } *************** *** 839,843 **** Elm.isPassive=true; String msg=""; ! boolean flags[]={false,true,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ //maybe not like in RFC page 37 p3.5 Application listener; listener = (Application)Elm.application; --- 850,854 ---- Elm.isPassive=true; String msg=""; ! boolean flags[]={false,false,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ //maybe not like in RFC page 37 p3.5 Application listener; listener = (Application)Elm.application; Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Echo_tcp.java 27 Nov 2005 20:36:05 -0000 1.8 --- Echo_tcp.java 28 Nov 2005 20:29:49 -0000 1.9 *************** *** 157,163 **** Simulation.addLayerInfo(protInfo2); ! // SendData(Data); ! mParentStack.SendFinalTCP(this, Data); //will close both connections LayerInfo protInfo3 = new LayerInfo(getClass().getName()); --- 157,163 ---- Simulation.addLayerInfo(protInfo2); ! SendData(Data); ! mParentStack.FinalizeTCP(this); //will close both connections LayerInfo protInfo3 = new LayerInfo(getClass().getName()); |
From: Alouette <alo...@us...> - 2005-11-28 13:47:51
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19584/core/protocolsuite/tcp_ip/ospf Modified Files: OSPFDTBdescription_packet.java Log Message: Index: OSPFDTBdescription_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPFDTBdescription_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPFDTBdescription_packet.java 28 Nov 2005 13:17:18 -0000 1.1 --- OSPFDTBdescription_packet.java 28 Nov 2005 13:47:37 -0000 1.2 *************** *** 17,28 **** */ public class OSPFDTBdescription_packet extends ospf_packetheader { ! private int options; ! private int IMMS; private int DDSequenceNumber; ! private int LSAheader; /** Creates a new instance of OSPFDTBdescription_packet */ public OSPFDTBdescription_packet() { } --- 17,37 ---- */ public class OSPFDTBdescription_packet extends ospf_packetheader { ! private int[] options; ! private int[] IMMS ; private int DDSequenceNumber; ! private String LSAheader; /** Creates a new instance of OSPFDTBdescription_packet */ public OSPFDTBdescription_packet() { + int i; + + options = new int[8]; + IMMS=new int[8]; + for (i=0; i<8; i++) + { + options[i]=0; + IMMS[i]=0; + } } |
From: Alouette <alo...@us...> - 2005-11-28 13:17:26
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13403/core/protocolsuite/tcp_ip/ospf Added Files: OSPFDTBdescription_packet.java OSPF_lsaheader.java Log Message: --- NEW FILE: OSPFDTBdescription_packet.java --- (This appears to be a binary file; contents omitted.) --- NEW FILE: OSPF_lsaheader.java --- (This appears to be a binary file; contents omitted.) |
From: gift <gi...@us...> - 2005-11-27 20:36:12
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17125/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java ProtocolStack.java Log Message: Line 159 Echo_tcp schould be uncommented! There is an error I'll fix it tomorrow Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ProtocolStack.java 27 Nov 2005 20:14:12 -0000 1.20 --- ProtocolStack.java 27 Nov 2005 20:36:05 -0000 1.21 *************** *** 1596,1600 **** rval=mTCPprotocol.ReservePort(application, inDestIPAddress, indestPort); if (sendTCPSegment(application, msg, flags)) ! return rval; else return 0; } --- 1596,1600 ---- rval=mTCPprotocol.ReservePort(application, inDestIPAddress, indestPort); if (sendTCPSegment(application, msg, flags)) ! return rval; else return -1; } Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Echo_tcp.java 27 Nov 2005 20:14:12 -0000 1.7 --- Echo_tcp.java 27 Nov 2005 20:36:05 -0000 1.8 *************** *** 72,76 **** sdPort = port; clientPort = mParentStack.ConnectTCP(this, sdHost, sdPort); ! if (clientPort>0) return true; else return false; } --- 72,76 ---- sdPort = port; clientPort = mParentStack.ConnectTCP(this, sdHost, sdPort); ! if (clientPort>-1) return true; else return false; } *************** *** 157,161 **** Simulation.addLayerInfo(protInfo2); ! //SendData(Data); mParentStack.SendFinalTCP(this, Data); //will close both connections --- 157,161 ---- Simulation.addLayerInfo(protInfo2); ! // SendData(Data); mParentStack.SendFinalTCP(this, Data); //will close both connections |
From: gift <gi...@us...> - 2005-11-27 20:36:12
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17125 Modified Files: TODO.txt Log Message: Line 159 Echo_tcp schould be uncommented! There is an error I'll fix it tomorrow Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TODO.txt 27 Nov 2005 09:34:22 -0000 1.11 --- TODO.txt 27 Nov 2005 20:36:05 -0000 1.12 *************** *** 40,47 **** pretty done 16. TCP(Gift && Key) - FIN packet processing! TCP application clarification. - !!!NO ACK for FIN is sent and ACK for FIN can not be received!!! 17. 2Fedor: RIP (over IP) --- 40,46 ---- pretty done 16. TCP(Gift && Key) TCP application clarification. + !!!!!! FATAL: See line 159 Echo_TCP!!!!! 17. 2Fedor: RIP (over IP) |
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); ! } } |
From: gift <gi...@us...> - 2005-11-27 18:17:47
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21159/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java ProtocolStack.java Tcp.java Log Message: UUUUUUUUUUUUUU TCP's working. TCP v1.0 :) Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ProtocolStack.java 26 Nov 2005 18:20:57 -0000 1.18 --- ProtocolStack.java 27 Nov 2005 18:17:34 -0000 1.19 *************** *** 1522,1554 **** Simulation.addLayerInfo(TCP_Info); } ! } ! ! ! /** ! * This method sets the TCP port free ! * @author gift (sourceforge.net user) ! * @param application application that uses port ! * @return Nothing ! * @exception TransportLayerException ! * @version v0.10 ! * @see TransportLayerException ! */ ! public void freeTCPPort(Object application) throws TransportLayerException ! { ! try { ! mTCPprotocol.FreePort(application); ! } catch (TransportLayerException te) ! { ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP port freeing: \""+ te.toString() + "\"."); ! Simulation.addLayerInfo(TCP_Info); ! } ! } /** ! * This method sets the TCP port totally free * @author gift (sourceforge.net user) * @param application application that uses port --- 1522,1529 ---- Simulation.addLayerInfo(TCP_Info); } ! } /** ! * This method sets the TCP port totally free (undepending on it's status) * @author gift (sourceforge.net user) * @param application application that uses port *************** *** 1723,1727 **** Simulation.addLayerInfo(TCP_Info); ! mTCPprotocol.FreePort(application); } catch (TransportLayerException te) { --- 1698,1702 ---- Simulation.addLayerInfo(TCP_Info); ! mTCPprotocol.ClosePort(application); } catch (TransportLayerException te) { Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Tcp.java 27 Nov 2005 09:34:22 -0000 1.12 --- Tcp.java 27 Nov 2005 18:17:34 -0000 1.13 *************** *** 134,137 **** --- 134,141 ---- /*end of database*/ + public boolean isFIN_sent; + public boolean isFIN_confirmed; + public boolean isPassive; + public void reset() { *************** *** 157,160 **** --- 161,167 ---- } } + this.isFIN_sent=false; + this.isFIN_confirmed=false; + this.isPassive=false; } } *************** *** 325,351 **** Elm.reset(); } else throw new TransportLayerException("TCP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); ! } ! ! /** ! * This method sets the TCP port free ! * @author gift (sourceforge.net user) ! * @param application application that uses port ! * @return Nothing ! * @exception TransportLayerException ! * @version v0.10 ! * @see TransportLayerException ! */ ! public void FreePort(Object application) throws TransportLayerException //changes port status from 2 (busy) to 0 (free) ! { ! TCP_HashTableElement Elm=null; ! Integer PortToFree=getApplicationLocalPortNumber(application); ! ! Elm=(TCP_HashTableElement) PortTable.get((Integer)PortToFree); ! ! if (Elm.PortStatus==2) ! { ! Elm.reset(); ! } else throw new TransportLayerException("TCP Error: port "+ PortToFree +" is not BUSY by the application: \"" + application.toString() + "\"."); ! } /** --- 332,336 ---- Elm.reset(); } else throw new TransportLayerException("TCP Error: port "+ PortToClose +" is not being LISTENED to by the application: \"" + application.toString() + "\"."); ! } /** *************** *** 608,612 **** tosend_clone.set_SYN_flag(flags[4]); tosend_clone.set_FIN_flag(flags[5]); ! //here we push out segment in Hashtable SegmentsToResend and increment counters s_num=Elm.seq_number; //getting sequence number 0-for SYN --- 593,597 ---- tosend_clone.set_SYN_flag(flags[4]); tosend_clone.set_FIN_flag(flags[5]); ! //here we push out segment in Hashtable SegmentsToResend and increment counters s_num=Elm.seq_number; //getting sequence number 0-for SYN *************** *** 635,641 **** } ! Elm=null; ! /* URG, ACK, PSH, RST, SYN, FIN */ //Create Layer info LayerInfo TCP_Info = new LayerInfo(getClass().getName()); --- 620,627 ---- } ! if (flags[5]) Elm.isFIN_sent=true; ! Elm=null; ! /* URG, ACK, PSH, RST, SYN, FIN */ //Create Layer info LayerInfo TCP_Info = new LayerInfo(getClass().getName()); *************** *** 830,852 **** TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP FIN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."); Simulation.addLayerInfo(TCP_Info); ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC Elm.SegmentsToResend.remove((Integer)our_ack-1); //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) ! //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! String msg=""; ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! Application listener; ! listener = (Application)Elm.application; ! listener.RecvData(inPacket.getTCP_message()); ! //if (!Elm.SegmentsToResend.isEmpty()) ! // mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now ! ! ! /*NOTE!!!! MAYBE USEFUL TO COMMENT THIS LINE DUE TO THE STATISTIC*/ // FreePort(listener); } else { //we have already received this segment --- 816,871 ---- TCP_Info.setLayer("Transport"); ! String s; ! if (!Elm.isFIN_sent) ! s="TCP FIN-packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + ". Now safe closing connection!"; ! else ! { ! if (!Elm.isFIN_confirmed) ! s="TCP FIN-packet ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + ". Now sending our FIN confirmation!"; ! else s="TCP FIN-packet ACK confirmation received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + ". Now closing connection!"; ! } ! ! TCP_Info.setDescription(s); Simulation.addLayerInfo(TCP_Info); ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC Elm.SegmentsToResend.remove((Integer)our_ack-1); //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) ! //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! if (Elm.isFIN_sent==false) ! { ! Elm.isPassive=true; ! String msg=""; ! boolean flags[]={false,true,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ //maybe not like in RFC page 37 p3.5 ! Application listener; ! listener = (Application)Elm.application; ! //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! mParentStack.sendTCPSegment(listener,msg,flags); ! } else ! { ! if (Elm.isFIN_confirmed==false) ! { ! String msg=""; ! boolean flags[]={false,true,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ //maybe not like in RFC page 37 p3.5 ! Application listener; ! listener = (Application)Elm.application; ! Elm.isFIN_confirmed=true; ! mParentStack.sendTCPSegment(listener,msg,flags); ! } else ! { ! if (!Elm.isPassive) ! { ! String msg=""; ! boolean flags[]={false,true,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ //maybe not like in RFC page 37 p3.5 ! Application listener; ! listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); ! } ! ClosePort((Application)Elm.application); //FIN sent and confirmed!!! Closing connection ! } ! ! } } else { //we have already received this segment *************** *** 901,905 **** if (rs>2) listener.RecvData(inPacket.getTCP_message()); ! if (our_ack!=2 || Elm.sent_segments!=2) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established //we have sent last ACK and we can close TCP port now --- 920,924 ---- if (rs>2) listener.RecvData(inPacket.getTCP_message()); ! if ((our_ack!=2 || Elm.sent_segments!=2) && Elm.PortStatus!=1) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established //we have sent last ACK and we can close TCP port now Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Echo_tcp.java 27 Nov 2005 14:28:22 -0000 1.5 --- Echo_tcp.java 27 Nov 2005 18:17:34 -0000 1.6 *************** *** 138,142 **** protInfo.setDescription("Recieving echo message '" + Data + "' from server."); Simulation.addLayerInfo(protInfo);*/ ! Disconnect(); //if FIN message in TCP then no call to Disconnect(); }else{ //server processing recieve --- 138,142 ---- protInfo.setDescription("Recieving echo message '" + Data + "' from server."); Simulation.addLayerInfo(protInfo);*/ ! //Disconnect(); }else{ //server processing recieve *************** *** 158,162 **** //SendData(Data); ! mParentStack.SendFinalTCP(this, Data); LayerInfo protInfo3 = new LayerInfo(getClass().getName()); --- 158,162 ---- //SendData(Data); ! mParentStack.SendFinalTCP(this, Data); //will close both connections LayerInfo protInfo3 = new LayerInfo(getClass().getName()); *************** *** 167,171 **** Simulation.addLayerInfo(protInfo3); ! Disconnect(); Listen(); }catch(Exception e){ --- 167,171 ---- Simulation.addLayerInfo(protInfo3); ! // Disconnect(); Listen(); }catch(Exception e){ |
From: Alexander B. <da...@us...> - 2005-11-27 14:28:33
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7531/core Modified Files: PC.java Log Message: Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PC.java 26 Nov 2005 16:48:24 -0000 1.5 --- PC.java 27 Nov 2005 14:28:22 -0000 1.6 *************** *** 57,61 **** Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); ! addApp(echoServer, 70); addApp(echoClient, 30007); --- 57,61 ---- Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); ! addApp(echoServer, 7); addApp(echoClient, 30007); |
From: Alexander B. <da...@us...> - 2005-11-27 14:28:30
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7531/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java Log Message: Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Echo_tcp.java 27 Nov 2005 09:34:22 -0000 1.4 --- Echo_tcp.java 27 Nov 2005 14:28:22 -0000 1.5 *************** *** 57,61 **** public void Close() throws TransportLayerException { ! mParentStack.CloseTCP(this); } --- 57,61 ---- public void Close() throws TransportLayerException { ! mParentStack.FreeTCPApplication(this); } *************** *** 92,96 **** public void Disconnect() throws TransportLayerException { ! mParentStack.freeTCPPort(this); } --- 92,97 ---- public void Disconnect() throws TransportLayerException { ! mParentStack.CloseTCP(this); ! //mParentStack.freeTCPPort(this); } *************** *** 166,171 **** Simulation.addLayerInfo(protInfo3); ! //Close(); ! //Listen(); }catch(Exception e){ ///*TODO*: here to catch --- 167,172 ---- Simulation.addLayerInfo(protInfo3); ! Disconnect(); ! Listen(); }catch(Exception e){ ///*TODO*: here to catch |
From: gift <gi...@us...> - 2005-11-27 09:34:32
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24254/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java Tcp.java Log Message: TCP v0.xx Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Tcp.java 26 Nov 2005 21:42:00 -0000 1.11 --- Tcp.java 27 Nov 2005 09:34:22 -0000 1.12 *************** *** 845,852 **** listener.RecvData(inPacket.getTCP_message()); //if (!Elm.SegmentsToResend.isEmpty()) ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now ! ! /*NOTE!!!! MAYBE USEFUL TO COMMENT THIS LINE DUE TO THE STATISTIC*/ FreePort(listener); } else { //we have already received this segment --- 845,852 ---- listener.RecvData(inPacket.getTCP_message()); //if (!Elm.SegmentsToResend.isEmpty()) ! // mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now ! ! /*NOTE!!!! MAYBE USEFUL TO COMMENT THIS LINE DUE TO THE STATISTIC*/ // FreePort(listener); } else { //we have already received this segment Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Echo_tcp.java 26 Nov 2005 21:42:00 -0000 1.3 --- Echo_tcp.java 27 Nov 2005 09:34:22 -0000 1.4 *************** *** 167,171 **** //Close(); ! Listen(); }catch(Exception e){ ///*TODO*: here to catch --- 167,171 ---- //Close(); ! //Listen(); }catch(Exception e){ ///*TODO*: here to catch |
From: gift <gi...@us...> - 2005-11-27 09:34:32
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24254 Modified Files: TODO.txt Log Message: TCP v0.xx Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TODO.txt 26 Nov 2005 21:43:28 -0000 1.10 --- TODO.txt 27 Nov 2005 09:34:22 -0000 1.11 *************** *** 42,45 **** --- 42,48 ---- FIN packet processing! TCP application clarification. + + !!!NO ACK for FIN is sent and ACK for FIN can not be received!!! + 17. 2Fedor: RIP (over IP) |
From: gift <gi...@us...> - 2005-11-26 21:43:38
|
Update of /cvsroot/javanetsim/javaNetSim In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32206 Modified Files: TODO.txt Log Message: tasks Index: TODO.txt =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/TODO.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TODO.txt 25 Nov 2005 14:23:56 -0000 1.9 --- TODO.txt 26 Nov 2005 21:43:28 -0000 1.10 *************** *** 40,44 **** pretty done 16. TCP(Gift && Key) ! Starting..... You, Bobr, high time you've started to do something!!!! 17. 2Fedor: RIP (over IP) --- 40,45 ---- pretty done 16. TCP(Gift && Key) ! FIN packet processing! ! TCP application clarification. 17. 2Fedor: RIP (over IP) |
From: gift <gi...@us...> - 2005-11-26 21:42:09
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31979/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java Tcp.java Log Message: TCP v0.3!!! We are working. Have to clarify TCP application structure! Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Tcp.java 26 Nov 2005 20:32:25 -0000 1.10 --- Tcp.java 26 Nov 2005 21:42:00 -0000 1.11 *************** *** 637,641 **** Elm=null; ! //Create Layer info LayerInfo TCP_Info = new LayerInfo(getClass().getName()); --- 637,641 ---- Elm=null; ! /* URG, ACK, PSH, RST, SYN, FIN */ //Create Layer info LayerInfo TCP_Info = new LayerInfo(getClass().getName()); *************** *** 643,647 **** TCP_Info.setDataType("TCP Protocol"); TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Created TCP packet for " + inDestIPAddress + ":" + indestPort +"."); Simulation.addLayerInfo(TCP_Info); --- 643,652 ---- TCP_Info.setDataType("TCP Protocol"); TCP_Info.setLayer("Transport"); ! String s=new String(); ! ! if (flags[4]) s="Created TCP SYN-packet for " + inDestIPAddress + ":" + indestPort +"."; ! if (flags[5]) s="Created TCP FIN-packet for " + inDestIPAddress + ":" + indestPort +"."; ! if (! (flags[4] || flags[5]) ) s="Created TCP packet for " + inDestIPAddress + ":" + indestPort +"."; ! TCP_Info.setDescription(s); Simulation.addLayerInfo(TCP_Info); *************** *** 875,880 **** TCP_Info.setLayer("Transport"); ! String s; ! if (our_ack!=2 || Elm.sent_segments !=2) s="TCP packet with data ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; else s="TCP packet with establishing connection ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC --- 880,886 ---- TCP_Info.setLayer("Transport"); ! String s; ! int rs = Elm.received_segments; ! if (rs>2) s="TCP packet with data ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; else s="TCP packet with establishing connection ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + ". Connection confirmed!"; //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC *************** *** 892,898 **** Application listener; listener = (Application)Elm.application; ! if (our_ack>2) listener.RecvData(inPacket.getTCP_message()); ! // boolean bo=Elm.SegmentsToResend.isEmpty(); if (!bo) ! if (our_ack!=2 || Elm.sent_segments!=2) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established //we have sent last ACK and we can close TCP port now --- 898,905 ---- Application listener; listener = (Application)Elm.application; ! ! if (rs>2) listener.RecvData(inPacket.getTCP_message()); ! ! if (our_ack!=2 || Elm.sent_segments!=2) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established //we have sent last ACK and we can close TCP port now Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Echo_tcp.java 26 Nov 2005 18:20:57 -0000 1.2 --- Echo_tcp.java 26 Nov 2005 21:42:00 -0000 1.3 *************** *** 137,141 **** protInfo.setDescription("Recieving echo message '" + Data + "' from server."); Simulation.addLayerInfo(protInfo);*/ ! Disconnect(); }else{ //server processing recieve --- 137,141 ---- protInfo.setDescription("Recieving echo message '" + Data + "' from server."); Simulation.addLayerInfo(protInfo);*/ ! Disconnect(); //if FIN message in TCP then no call to Disconnect(); }else{ //server processing recieve |
From: gift <gi...@us...> - 2005-11-26 20:32:34
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18074/core/protocolsuite/tcp_ip Modified Files: Tcp.java Log Message: v0.2 Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Tcp.java 26 Nov 2005 19:43:36 -0000 1.9 --- Tcp.java 26 Nov 2005 20:32:25 -0000 1.10 *************** *** 703,707 **** //Have to "establish" a new TCP connection by updating hashtable element information //and sending out ! //in case this is not duplicate Integer chk = (Integer)inPacket.get_sequence_number(); --- 703,707 ---- //Have to "establish" a new TCP connection by updating hashtable element information //and sending out ! //in case this is not duplicate Integer chk = (Integer)inPacket.get_sequence_number(); *************** *** 712,716 **** Elm.connectedtoPort=inPacket.get_srcPort(); Elm.received_segments++; ! Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received // everything is OK now we decompose TCP datagram --- 712,716 ---- Elm.connectedtoPort=inPacket.get_srcPort(); Elm.received_segments++; ! Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received // everything is OK now we decompose TCP datagram *************** *** 762,765 **** --- 762,767 ---- Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received + Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); + Elm.ReceivedACKs.addElement(our_ack); //adding ACK that we have received // everything is OK now we decompose TCP datagram *************** *** 777,783 **** Simulation.addLayerInfo(TCP_Info); ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received ! Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); ! Elm.SegmentsToResend.remove(our_ack); //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) --- 779,784 ---- Simulation.addLayerInfo(TCP_Info); ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC ! Elm.SegmentsToResend.remove((Integer)our_ack-1); //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) *************** *** 811,814 **** --- 812,817 ---- Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received + Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); + Elm.ReceivedACKs.addElement(our_ack); //adding ACK that we have received // everything is OK now we decompose TCP datagram *************** *** 826,832 **** Simulation.addLayerInfo(TCP_Info); ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received ! Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); ! Elm.SegmentsToResend.remove(our_ack); //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) --- 829,834 ---- Simulation.addLayerInfo(TCP_Info); ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC ! Elm.SegmentsToResend.remove((Integer)our_ack-1); //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) *************** *** 860,863 **** --- 862,867 ---- Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received + Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); + Elm.ReceivedACKs.addElement(our_ack); //adding ACK that we have received // everything is OK now we decompose TCP datagram *************** *** 871,879 **** TCP_Info.setLayer("Transport"); ! String s="TCP packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received ! Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); ! Elm.SegmentsToResend.remove(our_ack); if (our_ack==1 && (Integer)inPacket.get_sequence_number()==1) s=s + " New TCP connection established!"; --- 875,883 ---- TCP_Info.setLayer("Transport"); ! String s; ! if (our_ack!=2 || Elm.sent_segments !=2) s="TCP packet with data ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; else s="TCP packet with establishing connection ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received NOTE: dec by 1 is used see RFC ! Elm.SegmentsToResend.remove((Integer)our_ack-1); if (our_ack==1 && (Integer)inPacket.get_sequence_number()==1) s=s + " New TCP connection established!"; *************** *** 890,894 **** if (our_ack>2) listener.RecvData(inPacket.getTCP_message()); // boolean bo=Elm.SegmentsToResend.isEmpty(); if (!bo) ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now --- 894,899 ---- if (our_ack>2) listener.RecvData(inPacket.getTCP_message()); // boolean bo=Elm.SegmentsToResend.isEmpty(); if (!bo) ! if (our_ack!=2 || Elm.sent_segments!=2) mParentStack.sendTCPSegment(listener,msg,flags); //our_ack==2 when connection is established ! //we have sent last ACK and we can close TCP port now |
From: gift <gi...@us...> - 2005-11-26 19:43:46
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10590/core/protocolsuite/tcp_ip Modified Files: Tcp.java Log Message: Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Tcp.java 26 Nov 2005 18:20:57 -0000 1.8 --- Tcp.java 26 Nov 2005 19:43:36 -0000 1.9 *************** *** 804,807 **** --- 804,809 ---- if (!(inPacket.get_ACK_flag())) throw new TransportLayerPortException("TCP Error: No ACK flag set in segment!"); + //Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); + Integer chk = (Integer)inPacket.get_sequence_number(); if (!(Elm.ReceivedSegments.contains(chk))) *************** *** 835,839 **** listener = (Application)Elm.application; listener.RecvData(inPacket.getTCP_message()); ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now --- 837,842 ---- listener = (Application)Elm.application; listener.RecvData(inPacket.getTCP_message()); ! //if (!Elm.SegmentsToResend.isEmpty()) ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now *************** *** 885,890 **** Application listener; listener = (Application)Elm.application; ! listener.RecvData(inPacket.getTCP_message()); ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now --- 888,894 ---- Application listener; listener = (Application)Elm.application; ! if (our_ack>2) listener.RecvData(inPacket.getTCP_message()); ! // boolean bo=Elm.SegmentsToResend.isEmpty(); if (!bo) ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now |
From: gift <gi...@us...> - 2005-11-26 18:21:07
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27821/core/protocolsuite/tcp_ip Modified Files: Echo_tcp.java ProtocolStack.java Tcp.java Udp.java Log Message: More Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ProtocolStack.java 26 Nov 2005 14:44:02 -0000 1.17 --- ProtocolStack.java 26 Nov 2005 18:20:57 -0000 1.18 *************** *** 1436,1440 **** try { ! mUDPprotocol.FreePort(application); LayerInfo UDP_Info = new LayerInfo(getClass().getName()); --- 1436,1440 ---- try { ! LayerInfo UDP_Info = new LayerInfo(getClass().getName()); *************** *** 1443,1447 **** UDP_Info.setLayer("Transport"); UDP_Info.setDescription("UDP sending error: \""+ e.toString() + "\"."); ! Simulation.addLayerInfo(UDP_Info); //*TODO*: here we shall put some layerinfo for TransportException } catch (TransportLayerException te) --- 1443,1448 ---- UDP_Info.setLayer("Transport"); UDP_Info.setDescription("UDP sending error: \""+ e.toString() + "\"."); ! Simulation.addLayerInfo(UDP_Info); ! mUDPprotocol.FreePort(application); //*TODO*: here we shall put some layerinfo for TransportException } catch (TransportLayerException te) *************** *** 1603,1607 **** * @param inDestIPAddress destination IP address * @param indestPort destination port number ! * @return Nothing * @exception CommunicationException * @exception LowLinkException --- 1604,1608 ---- * @param inDestIPAddress destination IP address * @param indestPort destination port number ! * @return int port number that has been reserved for application * @exception CommunicationException * @exception LowLinkException *************** *** 1613,1622 **** */ ! public void ConnectTCP(Object application, String inDestIPAddress, int indestPort) throws LowLinkException, CommunicationException, TransportLayerException ! { String msg=""; boolean flags[]={false,false,false,false,true,false}; /* URG, ACK, PSH, RST, !SYN!, FIN */ ! mTCPprotocol.ReservePort(application, inDestIPAddress, indestPort); sendTCPSegment(application, msg, flags); } --- 1614,1625 ---- */ ! public int ConnectTCP(Object application, String inDestIPAddress, int indestPort) throws LowLinkException, CommunicationException, TransportLayerException ! { ! int rval; String msg=""; 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; } *************** *** 1712,1716 **** try { ! mTCPprotocol.FreePort(application); LayerInfo TCP_Info = new LayerInfo(getClass().getName()); TCP_Info.setObjectName(getParentNodeName()); --- 1715,1719 ---- try { ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); TCP_Info.setObjectName(getParentNodeName()); *************** *** 1718,1722 **** TCP_Info.setLayer("Transport"); TCP_Info.setDescription("TCP sending error: \""+ e.toString() + "\"."); ! Simulation.addLayerInfo(TCP_Info); } catch (TransportLayerException te) { --- 1721,1727 ---- TCP_Info.setLayer("Transport"); TCP_Info.setDescription("TCP sending error: \""+ e.toString() + "\"."); ! Simulation.addLayerInfo(TCP_Info); ! ! mTCPprotocol.FreePort(application); } catch (TransportLayerException te) { Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Tcp.java 26 Nov 2005 16:11:43 -0000 1.7 --- Tcp.java 26 Nov 2005 18:20:57 -0000 1.8 *************** *** 578,583 **** TCP_HashTableElement Elm; Elm = (TCP_HashTableElement) PortTable.get(insrcPort); ! if (Elm.seq_number <= (Integer)Elm.ReceivedACKs.lastElement()+window_size) { --- 578,586 ---- TCP_HashTableElement Elm; Elm = (TCP_HashTableElement) PortTable.get(insrcPort); + Integer gg = new Integer(0); ! if (!Elm.ReceivedACKs.isEmpty()) gg = (Integer)Elm.ReceivedACKs.lastElement(); ! ! if (Elm.seq_number <= gg+window_size) { *************** *** 588,591 **** --- 591,596 ---- tosend.setTCP_message(inMessage); + tosend_clone.setTCP_message(inMessage); + //now we set all the flags /* URG, ACK, PSH, RST, SYN, FIN */ *************** *** 638,642 **** TCP_Info.setDataType("TCP Protocol"); TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Created TCP packet for " + inDestIPAddress + ":" + insrcPort +"."); Simulation.addLayerInfo(TCP_Info); --- 643,647 ---- TCP_Info.setDataType("TCP Protocol"); TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Created TCP packet for " + inDestIPAddress + ":" + indestPort +"."); Simulation.addLayerInfo(TCP_Info); *************** *** 768,772 **** TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP SYN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); Simulation.addLayerInfo(TCP_Info); --- 773,777 ---- TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP SYN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " still has status \"busy\"."); Simulation.addLayerInfo(TCP_Info); *************** *** 815,819 **** TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP FIN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); Simulation.addLayerInfo(TCP_Info); --- 820,824 ---- TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP FIN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."); Simulation.addLayerInfo(TCP_Info); *************** *** 828,834 **** boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ Application listener; ! listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now listener.RecvData(inPacket.getTCP_message()); /*NOTE!!!! MAYBE USEFUL TO COMMENT THIS LINE DUE TO THE STATISTIC*/ FreePort(listener); --- 833,840 ---- boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ Application listener; ! listener = (Application)Elm.application; listener.RecvData(inPacket.getTCP_message()); + mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now + /*NOTE!!!! MAYBE USEFUL TO COMMENT THIS LINE DUE TO THE STATISTIC*/ FreePort(listener); *************** *** 861,872 **** TCP_Info.setLayer("Transport"); - - TCP_Info.setDescription("TCP packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); - - Simulation.addLayerInfo(TCP_Info); //deleting from SegmentsToResend the segmet with the acknowledgment number we have received Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); Elm.SegmentsToResend.remove(our_ack); //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) --- 867,881 ---- TCP_Info.setLayer("Transport"); + String s="TCP packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "."; + //deleting from SegmentsToResend the segmet with the acknowledgment number we have received Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); Elm.SegmentsToResend.remove(our_ack); + + if (our_ack==1 && (Integer)inPacket.get_sequence_number()==1) s=s + " New TCP connection established!"; + TCP_Info.setDescription(s); + + Simulation.addLayerInfo(TCP_Info); //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) *************** *** 875,881 **** boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ Application listener; ! listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now listener.RecvData(inPacket.getTCP_message()); } else { //we have already received this segment --- 884,891 ---- boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ Application listener; ! listener = (Application)Elm.application; listener.RecvData(inPacket.getTCP_message()); + mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now + } else { //we have already received this segment Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Echo_tcp.java 26 Nov 2005 16:56:00 -0000 1.1 --- Echo_tcp.java 26 Nov 2005 18:20:57 -0000 1.2 *************** *** 71,77 **** sdHost = Host; sdPort = port; ! //should be a return value here... ! //clientPort = mParentStack.ConnectTCP(this, sdHost, sdPort); ! mParentStack.ConnectTCP(this, sdHost, sdPort); } --- 71,75 ---- sdHost = Host; sdPort = port; ! clientPort = mParentStack.ConnectTCP(this, sdHost, sdPort); } Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Udp.java 26 Nov 2005 16:11:43 -0000 1.29 --- Udp.java 26 Nov 2005 18:20:57 -0000 1.30 *************** *** 295,299 **** UDP_Info.setDataType("UDP Protocol"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet for " + inDestIPAddress + ":" + insrcPort +"."); Simulation.addLayerInfo(UDP_Info); --- 295,299 ---- UDP_Info.setDataType("UDP Protocol"); UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("Created UDP packet for " + inDestIPAddress + ":" + indestPort +"."); Simulation.addLayerInfo(UDP_Info); |
From: Alexander B. <da...@us...> - 2005-11-26 16:56:08
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7122/core/protocolsuite/tcp_ip Added Files: Echo_tcp.java Log Message: --- NEW FILE: Echo_tcp.java --- (This appears to be a binary file; contents omitted.) |
From: Alexander B. <da...@us...> - 2005-11-26 16:48:37
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5884/guiUI Modified Files: ApplicationLayerDevice.java MainScreen.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MainScreen.java 21 Nov 2005 15:58:20 -0000 1.12 --- MainScreen.java 26 Nov 2005 16:48:25 -0000 1.13 *************** *** 118,121 **** --- 118,122 ---- import core.protocolsuite.tcp_ip.Echo; + import core.protocolsuite.tcp_ip.Echo_tcp; *************** *** 2875,2878 **** --- 2876,2906 ---- } + public void EchotcpServerListen(String inNodeName){ + + String port = JOptionPane.showInputDialog(this, "Port:", "Set Echo Server listening on port.", JOptionPane.QUESTION_MESSAGE); + + if(port!=null){ + + try{ + + + + Echo_tcp echo1 = ((Echo_tcp)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(17)); + + echo1.setPort(Integer.valueOf(port).intValue()); + + echo1.Listen(); + + printLayerInfo(); + + }catch(Exception e){ + + addToConsole(e.toString()); + + } + + } + + } *************** *** 2919,2923 **** } ! /** --- 2947,2991 ---- } ! /** ! ! * Send echo message to server ! ! * @author Key ! ! * @param String inNodeName Name of node to server listen ! ! */ ! ! ! ! public void EchotcpSend(String inNodeName){ ! ! String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! ! String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); ! ! String msg = JOptionPane.showInputDialog(this, "Message:", "Message.", JOptionPane.QUESTION_MESSAGE); ! ! if(port!=null && ip!=null && msg!=null){ ! ! try{ ! ! printNetworkStart(); ! ! ((Echo_tcp)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30017)).SendEcho(msg, ip, Integer.valueOf(port).intValue()); ! ! this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); ! ! }catch(Exception e){ ! ! addToConsole(e.toString()); ! ! } ! ! printLayerInfo(); ! ! } ! ! } /** Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/ApplicationLayerDevice.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ApplicationLayerDevice.java 19 Nov 2005 16:16:32 -0000 1.3 --- ApplicationLayerDevice.java 26 Nov 2005 16:48:25 -0000 1.4 *************** *** 21,26 **** public class ApplicationLayerDevice extends NetworkLayerDevice { ! private JMenuItem mnuEchoListen = new JMenuItem("Start echo server to listen."); ! private JMenuItem mnuEchoSend = new JMenuItem("Send data via echo client."); /** Creates a new instance of ApplicationLayerDevice */ --- 21,28 ---- public class ApplicationLayerDevice extends NetworkLayerDevice { ! private JMenuItem mnuEchoListen = new JMenuItem("Start udp echo server to listen."); ! private JMenuItem mnuEchoSend = new JMenuItem("Send data via udp echo client."); ! private JMenuItem mnuEchotcpListen = new JMenuItem("Start tcp echo server to listen."); ! private JMenuItem mnuEchotcpSend = new JMenuItem("Send data via tcp echo client."); /** Creates a new instance of ApplicationLayerDevice */ *************** *** 41,47 **** --- 43,63 ---- }); + mnuEchotcpListen.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.EchotcpServerListen(lblNodeName.getText()); + + + } + }); + mnuEchotcpSend.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent e){ + controller.EchotcpSend(lblNodeName.getText()); + } + }); GuiNodePopMenu.add(mnuEchoListen); GuiNodePopMenu.add(mnuEchoSend); + GuiNodePopMenu.add(mnuEchotcpListen); + GuiNodePopMenu.add(mnuEchotcpSend); } } |
From: Alexander B. <da...@us...> - 2005-11-26 16:48:37
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5884/core Modified Files: PC.java Log Message: Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PC.java 19 Nov 2005 14:26:02 -0000 1.4 --- PC.java 26 Nov 2005 16:48:24 -0000 1.5 *************** *** 29,32 **** --- 29,33 ---- import core.protocolsuite.tcp_ip.Echo; + import core.protocolsuite.tcp_ip.Echo_tcp; /** *************** *** 52,59 **** Echo echoServer = new Echo(NodeProtocolStack, 7, 1, core.ProtocolStack.UIDGen++); Echo echoClient = new Echo(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); ! addApp(echoServer, 7); addApp(echoClient, 30007); addNetworkInterface("eth0"); } --- 53,66 ---- Echo echoServer = new Echo(NodeProtocolStack, 7, 1, core.ProtocolStack.UIDGen++); Echo echoClient = new Echo(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); + + Echo_tcp echotcpServer = new Echo_tcp(NodeProtocolStack, 17, 1, core.ProtocolStack.UIDGen++); + Echo_tcp echotcpClient = new Echo_tcp(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); ! addApp(echoServer, 70); addApp(echoClient, 30007); + addApp(echotcpServer, 17); + addApp(echotcpClient, 30017); + addNetworkInterface("eth0"); } |
From: Alexander B. <da...@us...> - 2005-11-26 16:48:37
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5884/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Log Message: Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Application.java 20 Nov 2005 21:06:50 -0000 1.11 --- Application.java 26 Nov 2005 16:48:25 -0000 1.12 *************** *** 65,69 **** */ ! public abstract void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException; /** --- 65,69 ---- */ ! public abstract void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException; /** Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Echo.java 25 Nov 2005 21:21:53 -0000 1.14 --- Echo.java 26 Nov 2005 16:48:25 -0000 1.15 *************** *** 68,72 **** */ ! public void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException { sdHost = Host; sdPort = port; --- 68,72 ---- */ ! public void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException, CommunicationException, LowLinkException { sdHost = Host; sdPort = port; |
From: Alexander B. <da...@us...> - 2005-11-26 16:25:46
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2022 Added Files: TCP_packet.java Log Message: --- NEW FILE: TCP_packet.java --- /* 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 core.Packet; import core.TransportLayerException; /** * This is for design and future implementation of TCP_PACKET * @author luke_hamilton * @since Sep 17, 2004 * Design and implementation of TCP_packet * @author gift (sourceforge.net user) * @since Nov 25, 2005 * @version v0.20 */ public class TCP_packet extends IP_packet { /* DO NOT forget about pseudo UDP header fields * - mSourceIPAddress (implemented) * - mDestIPAddress (implemented) * - PTCL (protocol type code) (implemented) * - TCP length - not needed (not implemented) * that's why TCP_packet as well as UDP_packet extends IP_packet */ private int TCP_srcPort; private int TCP_destPort; private int TCP_MessageLength; 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 */ private int TCP_window; //for future developing :) private Object URG_pointer; //for future developing :) private String TCP_message; private static final int PTCL = 6; //see RFC :) private static final int CHECK_SUM = 1; //for future developing :) private static final int HEAD_LENGTH = 22; //TCP header is 22 bytes private static final int MAX_LENGTH = 65535; //bytes is UDP datagramm maximum length /** * This method passes the destination and source addresses into the super class * @author gift (sourceforge.net user) * @param inDestIPAddress destination IP address * @param inSourceIPAddress source IP address * @param indestPort destination port number * @param insrcPort sorce port number * @return Nothing. * @version v0.20 */ public TCP_packet(String inDestIPAddress, String inSourceIPAddress, int indestPort, int insrcPort) { super (inDestIPAddress); this.setSourceIPAddress(inSourceIPAddress); TCP_destPort = indestPort; TCP_srcPort = insrcPort; TCP_MessageLength = HEAD_LENGTH; TCP_message = ""; } /** * This method sets the TCP_message and calculates TCP_message length * @author gift (sourceforge.net user) * @param inTCP_message a string to be set as a TCP message * @return Nothing. * @exception TransportLayerException If TCP message exceeds maximum size of TCP message. * @version v0.20 * @see TransportLayerException */ public void setTCP_message(String inTCP_message) throws TransportLayerException { int length; length = HEAD_LENGTH + TCP_message.length(); if (length <= MAX_LENGTH) { TCP_message = inTCP_message; TCP_MessageLength = length; }else { throw new TransportLayerException("TCP Error: TCP message exceeds maximum size of " + MAX_LENGTH + " bytes."); } } /** * This method returns the string describing TCP message * @author gift (sourceforge.net user) * @param Unused. * @return the TCP message * @version v0.20 */ public String getTCP_message() { return TCP_message; } /** * This method returns integer describing TCP message length * @author gift (sourceforge.net user) * @param Unused. * @return the length of TCP message. * @version v0.20 */ public int getTCP_MessageLength() { return TCP_MessageLength; } /** * This if for design and future implementation of TCP_packet * @author gift (sourceforge.net user) * @param Unused. * @return Nothing. * @version v0.20 */ public void calculate_Check_Sum() { } /** * This method gets Check_Sum * can be used for design and future implementation of TCP_packet * @author gift (sourceforge.net user) * @param Unused. * @return CHECK_SUM. * @version v0.20 */ public int getCheck_Sum() { return CHECK_SUM; } /** * This method gets protocol code (6 for TCP) * @author gift (sourceforge.net user) * @param Unused. * @return protocol code PTCL. * @version v0.20 */ public int getProtocolCode() { return PTCL; } /** * This method gets source port * @author gift (sourceforge.net user) * @param Unused. * @return source TCP port number. * @version v0.20 */ public int get_srcPort() { return TCP_srcPort; } /** * This method gets destination port * @author gift (sourceforge.net user) * @param Unused. * @return destination TCP port number. * @version v0.20 */ public int get_destPort() { return TCP_destPort; } /** * This method sets the sequence number * @author gift (sourceforge.net user) * @param inSNumb integer to be set as the sequence number * @return Nothing. * @version v0.20 */ public void set_sequence_number(int inSNumb) { sequence_number=inSNumb; } /** * This method sets the acknowledgment number * @author gift (sourceforge.net user) * @param inACK integer to be set as the acknowledgment number * @return Nothing. * @version v0.20 */ public void set_acknowledgment_number(int inACK) { acknowledgment_number=inACK; } /** * This method gets sequence number * @author gift (sourceforge.net user) * @param Unused. * @return TCP sequence number. * @version v0.20 */ public int get_sequence_number() { return sequence_number; } /** * This method gets acknowledgment number * @author gift (sourceforge.net user) * @param Unused. * @return TCP acknowledgment number. * @version v0.20 */ public int get_acknowledgment_number() { return acknowledgment_number; } /** * This method gets URG flag * @author gift (sourceforge.net user) * @param Unused. * @return URG boolean flag value. * @version v0.20 */ public boolean get_URG_flag() { return flags[0]; } /** * This method gets ACK flag * @author gift (sourceforge.net user) * @param Unused. * @return ACK boolean flag value. * @version v0.20 */ public boolean get_ACK_flag() { return flags[1]; } /** * This method gets PSH flag * @author gift (sourceforge.net user) * @param Unused. * @return PSH boolean flag value. * @version v0.20 */ public boolean get_PSH_flag() { return flags[2]; } /** * This method gets RST flag * @author gift (sourceforge.net user) * @param Unused. * @return RST boolean flag value. * @version v0.20 */ public boolean get_RST_flag() { return flags[3]; } /** * This method gets SYN flag * @author gift (sourceforge.net user) * @param Unused. * @return SYN boolean flag value. * @version v0.20 */ public boolean get_SYN_flag() { return flags[4]; } /** * This method gets FIN flag * @author gift (sourceforge.net user) * @param Unused. * @return FIN boolean flag value. * @version v0.20 */ public boolean get_FIN_flag() { return flags[5]; } /** * This method sets URG flag * @author gift (sourceforge.net user) * @param inflg_val boolean the value to be set for URG flag. * @return Nothing. * @version v0.20 */ public void set_URG_flag(boolean inflg_val) { flags[0]=inflg_val; } /** * This method sets ACK flag * @author gift (sourceforge.net user) * @param inflg_val boolean the value to be set for ACK flag. * @return Nothing. * @version v0.20 */ public void set_ACK_flag(boolean inflg_val) { flags[1]=inflg_val; } /** * This method sets PSH flag * @author gift (sourceforge.net user) * @param inflg_val boolean the value to be set for PSH flag. * @return Nothing. * @version v0.20 */ public void set_PSH_flag(boolean inflg_val) { flags[2]=inflg_val; } /** * This method sets RST flag * @author gift (sourceforge.net user) * @param inflg_val boolean the value to be set for RST flag. * @return Nothing. * @version v0.20 */ public void set_RST_flag(boolean inflg_val) { flags[3]=inflg_val; } /** * This method sets SYN flag * @author gift (sourceforge.net user) * @param inflg_val boolean the value to be set for SYN flag. * @return Nothing. * @version v0.20 */ public void set_SYN_flag(boolean inflg_val) { flags[4]=inflg_val; } /** * This method sets FIN flag * @author gift (sourceforge.net user) * @param inflg_val boolean the value to be set for FIN flag. * @return Nothing. * @version v0.20 */ public void set_FIN_flag(boolean inflg_val) { flags[5]=inflg_val; } }//EOF |
From: Alexander B. <da...@us...> - 2005-11-26 16:23:59
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1720 Removed Files: Tcp_packet.java Log Message: --- Tcp_packet.java DELETED --- |
From: gift <gi...@us...> - 2005-11-26 16:11:51
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32242/core/protocolsuite/tcp_ip Modified Files: Tcp.java Udp.java Log Message: YES!!! TCP v.0.1 Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Tcp.java 26 Nov 2005 14:44:02 -0000 1.6 --- Tcp.java 26 Nov 2005 16:11:43 -0000 1.7 *************** *** 677,680 **** --- 677,681 ---- if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ this.total_received++; //overall stats + // test if destination TCP port exists on this NeworkLayerDevice if (PortTable.get(inPacket.get_destPort()) !=null) *************** *** 700,704 **** //in case this is not duplicate Integer chk = (Integer)inPacket.get_sequence_number(); ! if (Elm.ReceivedSegments.contains(chk)) { Elm.PortStatus=2; //port will be busy from now --- 701,705 ---- //in case this is not duplicate Integer chk = (Integer)inPacket.get_sequence_number(); ! if (!(Elm.ReceivedSegments.contains(chk))) { Elm.PortStatus=2; //port will be busy from now *************** *** 729,733 **** listener = (Application)Elm.application; mParentStack.sendTCPSegment(listener,msg,flags); ! } else { //we have already received this segment Elm.received_duplicates++; --- 730,735 ---- listener = (Application)Elm.application; mParentStack.sendTCPSegment(listener,msg,flags); ! //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet ! } else { //we have already received this segment Elm.received_duplicates++; *************** *** 740,763 **** if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) { ! //now we decompose TCP datagram ! ! // everything is OK, one more test: check sum of TCP packet ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getTCP_message() + "\"."); ! ! Simulation.addLayerInfo(TCP_Info); ! ! Application listener; ! listener = (Application)Elm.application; ! listener.RecvData(inPacket.getTCP_message()); } else { //have to disconnect listener from port --- 742,888 ---- if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) { ! //now we decompose TCP segment ! //everything is OK ! //Check for SYN ! if (inPacket.get_SYN_flag()) ! { ! //we have received an answer for our SYN-segment ! //a little test ! if (!(inPacket.get_ACK_flag())) throw new TransportLayerPortException("TCP Error: No ACK flag set in segment!"); ! ! //in case this is not duplicate ! Integer chk = (Integer)inPacket.get_sequence_number(); ! if (!(Elm.ReceivedSegments.contains(chk))) ! { ! Elm.received_segments++; ! Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received ! // everything is OK now we decompose TCP datagram ! ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP SYN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); ! Simulation.addLayerInfo(TCP_Info); ! ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received ! Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); ! Elm.SegmentsToResend.remove(our_ack); ! ! //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) ! //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! String msg=""; ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! Application listener; ! listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); ! //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet ! ! } else { //we have already received this segment ! Elm.received_duplicates++; ! } ! ! } else ! { ! //NOT SYN-segment ! //check for FIN ! if (inPacket.get_FIN_flag()) ! { ! //FIN flag! Last segment was received. ! //a little test ! if (!(inPacket.get_ACK_flag())) throw new TransportLayerPortException("TCP Error: No ACK flag set in segment!"); ! ! Integer chk = (Integer)inPacket.get_sequence_number(); ! if (!(Elm.ReceivedSegments.contains(chk))) ! { ! Elm.received_segments++; ! Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received ! // everything is OK now we decompose TCP datagram ! ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! ! TCP_Info.setDataType("TCP Protocol"); ! ! TCP_Info.setLayer("Transport"); ! ! TCP_Info.setDescription("TCP FIN-packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); ! ! Simulation.addLayerInfo(TCP_Info); ! ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received ! Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); ! Elm.SegmentsToResend.remove(our_ack); ! ! //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) ! //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! String msg=""; ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! Application listener; ! listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now ! listener.RecvData(inPacket.getTCP_message()); ! ! /*NOTE!!!! MAYBE USEFUL TO COMMENT THIS LINE DUE TO THE STATISTIC*/ FreePort(listener); ! ! } else { //we have already received this segment ! Elm.received_duplicates++; ! } ! ! ! } else { ! // no FIN flag, no SYN flag ! //just normal mode. Have to check ACK flag, decompose, send acknowledgement ! ! //a little test ! if (!(inPacket.get_ACK_flag())) throw new TransportLayerPortException("TCP Error: No ACK flag set in segment!"); ! ! Integer chk = (Integer)inPacket.get_sequence_number(); ! if (!(Elm.ReceivedSegments.contains(chk))) ! { ! Elm.received_segments++; ! Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received ! // everything is OK now we decompose TCP datagram ! ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! ! TCP_Info.setDataType("TCP Protocol"); ! ! TCP_Info.setLayer("Transport"); ! ! TCP_Info.setDescription("TCP packet with ACK received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); ! ! Simulation.addLayerInfo(TCP_Info); ! ! //deleting from SegmentsToResend the segmet with the acknowledgment number we have received ! Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); ! Elm.SegmentsToResend.remove(our_ack); ! ! //now we have to send ACK-segment (with SYN=false, seq_num=XX, ack_num=XX) ! //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" ! String msg=""; ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! Application listener; ! listener = (Application)Elm.application; ! mParentStack.sendTCPSegment(listener,msg,flags); //we have sent last ACK and we can close TCP port now ! listener.RecvData(inPacket.getTCP_message()); ! ! } else { //we have already received this segment ! Elm.received_duplicates++; ! } ! } ! } ! } else { //have to disconnect listener from port Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** Udp.java 26 Nov 2005 14:44:02 -0000 1.28 --- Udp.java 26 Nov 2005 16:11:43 -0000 1.29 *************** *** 231,235 **** { //now we decompose UDP datagram ! // everything is OK, one more test: check sum of UDP packet //Create Layer info --- 231,235 ---- { //now we decompose UDP datagram ! // everything is OK //Create Layer info |
From: gift <gi...@us...> - 2005-11-26 14:44:13
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18123/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Tcp.java Udp.java Log Message: Have to do something more.... Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ProtocolStack.java 25 Nov 2005 21:21:53 -0000 1.16 --- ProtocolStack.java 26 Nov 2005 14:44:02 -0000 1.17 *************** *** 71,76 **** import core.Simulation; - - import core.*; --- 71,74 ---- *************** *** 779,782 **** --- 777,797 ---- // throw tpe; } + + }else if(ipPacket instanceof TCP_packet){ + + TCP_packet temp = (TCP_packet)inPacket; + try{ + mTCPprotocol.receiveTCPPacket(temp); + }catch(TransportLayerException te){} + catch (CommunicationException ce) {} + catch(TransportLayerPortException tpe){ + //here *TODO*: disconnect sender from port!!! + LayerInfo TCP_Info = new LayerInfo(getClass().getName()); + TCP_Info.setObjectName(getParentNodeName()); + TCP_Info.setDataType("TCP Packet"); + TCP_Info.setLayer("Transport"); + TCP_Info.setDescription("TCP port packet receiving: \""+ tpe.toString() + "\"."); + Simulation.addLayerInfo(TCP_Info); + } }else{ *************** *** 1578,1582 **** Simulation.addLayerInfo(TCP_Info); } ! } }//EOF --- 1593,1734 ---- Simulation.addLayerInfo(TCP_Info); } ! } ! ! ! /** ! * This method sets the TCP connection ! * NOTE: call this method from application to set up the TCP connection ! * @author gift (sourceforge.net user) ! * @param application the application that sets the connection ! * @param inDestIPAddress destination IP address ! * @param indestPort destination port number ! * @return Nothing ! * @exception CommunicationException ! * @exception LowLinkException ! * @exception TransportLayerException ! * @version v0.10 ! * @see CommunicationException ! * @see LowLinkException ! * @see TransportLayerException ! */ ! ! public void ConnectTCP(Object application, String inDestIPAddress, int indestPort) throws LowLinkException, CommunicationException, TransportLayerException ! { ! String msg=""; ! boolean flags[]={false,false,false,false,true,false}; /* URG, ACK, PSH, RST, !SYN!, FIN */ ! mTCPprotocol.ReservePort(application, inDestIPAddress, indestPort); ! sendTCPSegment(application, msg, flags); ! } ! ! ! /** ! * This method sends the TCP segments ! * NOTE: call this method from application to send TCP segment ! * @author gift (sourceforge.net user) ! * @param application the application that sets the connection ! * @return Nothing ! * @exception CommunicationException ! * @exception LowLinkException ! * @version v0.10 ! * @see CommunicationException ! * @see LowLinkException ! */ ! ! public void SendTCP(Object application, String inTCPMessage) throws LowLinkException, CommunicationException ! { ! boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! sendTCPSegment(application, inTCPMessage, flags); ! } ! ! ! /** ! * This method sends the TCP segments ! * NOTE: call this method from application to send last TCP segment ! * @author gift (sourceforge.net user) ! * @param application the application that sets the connection ! * @return Nothing ! * @exception CommunicationException ! * @exception LowLinkException ! * @version v0.10 ! * @see CommunicationException ! * @see LowLinkException ! */ ! ! public void SendFinalTCP(Object application, String inTCPMessage) throws LowLinkException, CommunicationException ! { ! boolean flags[]={false,true,false,false,false,true}; /* URG, !ACK!, PSH, RST, SYN, !FIN! */ ! sendTCPSegment(application, inTCPMessage, flags); ! } ! ! /** ! * This method sends the TCP segments with certain flags ! * NOTE: DO <b>NOT</b> CALL this method from application use only <i>SendTCP(Object application, String inTCPMessage)</i> in the application to send TCP segments ! * @author gift (sourceforge.net user) ! * @param application the application that sends the message ! * @param inTCPMessage TCP message to send ! * @param flags[] 6 flags to set in segment ! * @return Nothing ! * @exception CommunicationException ! * @exception LowLinkException ! * @version v0.40 ! * @see CommunicationException ! * @see LowLinkException ! */ ! ! public void sendTCPSegment(Object application, String inTCPMessage, boolean flags[]) throws LowLinkException, CommunicationException ! { ! String FirstInterfaceName; ! String DestIPAddress; ! String SourceIPAddress; ! int srcPort; ! int destPort; ! ! //lets get first network interface name ! Node temp = (Node)mParentNode; ! FirstInterfaceName = temp.getFirstInterfaceName(); ! ! try{ ! //let's get a reserved local port number for this application ! srcPort=mTCPprotocol.getApplicationLocalPortNumber(application); ! //and destination IP of the other host ! DestIPAddress=mTCPprotocol.getApplicationDestIP(srcPort); ! //and destination port of the other host ! destPort=mTCPprotocol.getApplicationDestPortNumber(srcPort); ! ! if (FirstInterfaceName!=null) ! { ! if(IPV4Address.validateDecIP(DestIPAddress)) ! { ! //let's get first interface IP address ! SourceIPAddress=getIPAddress(FirstInterfaceName); ! TCP_packet tosend = mTCPprotocol.sendTCPPacket(DestIPAddress,SourceIPAddress,destPort,srcPort,inTCPMessage,flags); ! //and sending out ;) ! sendPacket(tosend); ! }else ! throw new CommunicationException("Packet dropped host unreachable: " + DestIPAddress); ! } //else ! //throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! }catch(Exception e){ ! ! try { ! mTCPprotocol.FreePort(application); ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(getParentNodeName()); ! TCP_Info.setDataType("TCP Packet"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP sending error: \""+ e.toString() + "\"."); ! Simulation.addLayerInfo(TCP_Info); ! } catch (TransportLayerException te) ! { ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(getParentNodeName()); ! TCP_Info.setDataType("TCP Packet"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("TCP port freeing: \""+ te.toString() + "\"."); ! Simulation.addLayerInfo(TCP_Info); ! } ! ! } ! } }//EOF Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Udp.java 25 Nov 2005 22:54:02 -0000 1.27 --- Udp.java 26 Nov 2005 14:44:02 -0000 1.28 *************** *** 169,173 **** * @return Nothing. * @exception TransportLayerException If UDP CHECK_SUM != 1 - * @exception CommunicationException * @exception LowLinkException * @exception InvalidNetworkLayerDeviceException --- 169,172 ---- *************** *** 175,179 **** * @version v0.20 * @see TransportLayerException - * @see CommunicationException * @see LowLinkException * @see InvalidNetworkLayerDeviceException --- 174,177 ---- *************** *** 183,249 **** public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException { ! // test if this packet is for a local Address. ! if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ ! ! // test if destination UDP port exists on this NeworkLayerDevice ! if (PortTable.get(inPacket.get_destPort()) !=null) ! { ! ! //let's check all the things dealing with destination port number ! UDP_HashTableElement Elm = null; ! Elm=(UDP_HashTableElement)PortTable.get(inPacket.get_destPort()); ! ! switch(Elm.PortStatus) { - case 0: //port is free => Error: no application to receive UDP - //have to disconnect listener from port - throw new TransportLayerPortException("UDP Error: no server application listening to port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"!"); - //no break needed ;) - case 1: // port is being listened to by a new application. Have to "establish" (in UDP no connections are being established) a new connection by replacing hashtable element - Elm.PortStatus=2; //port will be busy from now - Elm.connectedtoIP=inPacket.getSourceIPAddress(); - Elm.connectedtoPort=inPacket.get_srcPort(); - - //PortTable.remove(inPacket.get_destPort()); //delete old element - //PortTable.put(new Integer(inPacket.get_destPort()),Elm); //hash table update - - //now we decompose UDP datagram - - // everything is OK, one more test: check sum of UDP packet - if (inPacket.getCheck_Sum() == 1) - { - //Create Layer info ! LayerInfo UDP_Info = new LayerInfo(getClass().getName()); ! ! UDP_Info.setObjectName(mParentStack.getParentNodeName()); ! ! UDP_Info.setDataType("UDP Protocol"); ! ! UDP_Info.setLayer("Transport"); ! ! UDP_Info.setDescription("UDP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getUDP_message() + "\"." + " UDP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); ! Simulation.addLayerInfo(UDP_Info); ! ! Application listener; ! listener = (Application)Elm.application; ! listener.RecvData(inPacket.getUDP_message()); ! ! ! } else { ! throw new TransportLayerException("UDP Error: incorrect checksum on receiving!"); ! } ! break; ! ! case 2: //busy port, let's check whether it's busy by us (sender) ;) ! if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) ! { //now we decompose UDP datagram ! ! // everything is OK, one more test: check sum of UDP packet ! if (inPacket.getCheck_Sum() == 1) ! { //Create Layer info --- 181,211 ---- public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException { + //test: check sum of UDP packet + if (inPacket.getCheck_Sum() == 1) + { + // test if this packet is for a local Address. + if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ ! // test if destination UDP port exists on this NeworkLayerDevice ! if (PortTable.get(inPacket.get_destPort()) !=null) { ! //let's check all the things dealing with destination port number ! UDP_HashTableElement Elm = null; ! Elm=(UDP_HashTableElement)PortTable.get(inPacket.get_destPort()); ! switch(Elm.PortStatus) ! { ! case 0: //port is free => Error: no application to receive UDP ! //have to disconnect listener from port ! throw new TransportLayerPortException("UDP Error: no server application listening to port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"!"); ! //no break needed ;) ! case 1: // port is being listened to by a new application. Have to "establish" (in UDP no connections are being established) a new connection by updating hashtable element information //now we decompose UDP datagram ! ! // everything is OK, one more ! Elm.PortStatus=2; //port will be busy from now ! Elm.connectedtoIP=inPacket.getSourceIPAddress(); ! Elm.connectedtoPort=inPacket.get_srcPort(); //Create Layer info *************** *** 256,288 **** UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("UDP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getUDP_message() + "\"."); ! Simulation.addLayerInfo(UDP_Info); ! ! Application listener; ! listener = (Application)Elm.application; ! listener.RecvData(inPacket.getUDP_message()); ! ! } else { ! throw new TransportLayerException("UDP Error: incorrect checksum on receiving!"); ! } ! } else { ! //have to disconnect listener from port ! throw new TransportLayerPortException("UDP Error: port is busy! Port is connected to another host or/and port and is busy by another application." + "Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); ! } ! break; ! ! default: //UDP Error: unknown port status :( ! //have to disconnect listener from port ! throw new TransportLayerPortException("UDP Error: unknown port status! Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); ! } ! } else { ! throw new TransportLayerPortException("UDP Error: port " + inPacket.get_destPort() + " does not exist. Host \"" + mParentStack.getParentNodeName()+"\"."); ! } ! } } /** ! * This method sends the UDP packet * and prints out a message to the layer info. * @author gift (sourceforge.net user) --- 218,273 ---- UDP_Info.setLayer("Transport"); ! UDP_Info.setDescription("UDP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getUDP_message() + "\"." + " UDP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); ! Simulation.addLayerInfo(UDP_Info); ! ! Application listener; ! listener = (Application)Elm.application; ! listener.RecvData(inPacket.getUDP_message()); ! break; ! ! case 2: //busy port, let's check whether it's busy by sender ;) ! if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) ! { ! //now we decompose UDP datagram ! // everything is OK, one more test: check sum of UDP packet ! //Create Layer info ! ! UDP_Info = new LayerInfo(getClass().getName()); ! ! UDP_Info.setObjectName(mParentStack.getParentNodeName()); ! ! UDP_Info.setDataType("UDP Protocol"); ! ! UDP_Info.setLayer("Transport"); ! ! UDP_Info.setDescription("UDP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getUDP_message() + "\"."); ! ! Simulation.addLayerInfo(UDP_Info); ! ! listener = (Application)Elm.application; ! listener.RecvData(inPacket.getUDP_message()); ! ! } else { ! //have to disconnect listener from port ! throw new TransportLayerPortException("UDP Error: port is busy! Port is connected to another host or/and port and is busy by another application." + "Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); ! } ! break; ! ! default: //UDP Error: unknown port status :( ! //have to disconnect listener from port ! throw new TransportLayerPortException("UDP Error: unknown port status! Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); ! } ! } else { ! throw new TransportLayerPortException("UDP Error: port " + inPacket.get_destPort() + " does not exist. Host \"" + mParentStack.getParentNodeName()+"\"."); ! } ! } ! } else { ! throw new TransportLayerException("UDP Error: incorrect checksum on receiving!"); //comment this line if you have implemented check sum tests :) ! } } /** ! * This method returns the UDP packet to send * and prints out a message to the layer info. * @author gift (sourceforge.net user) Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Tcp.java 25 Nov 2005 22:54:02 -0000 1.5 --- Tcp.java 26 Nov 2005 14:44:02 -0000 1.6 *************** *** 125,128 **** --- 125,129 ---- public int sent_duplicates; //counter inc when a duplicate of a segment is resent /*end of statistic block*/ + public int seq_number; /*database*/ public Vector ReceivedSegments = new Vector(); //contains received segments ONLY sequence_number for each segment is stored *************** *** 144,147 **** --- 145,149 ---- this.received_duplicates=0; this.sent_duplicates=0; + this.seq_number=0; if (!this.ReceivedSegments.isEmpty()) this.ReceivedSegments.removeAllElements(); if (!this.ReceivedACKs.isEmpty()) this.ReceivedACKs.removeAllElements(); *************** *** 161,169 **** private ProtocolStack mParentStack; private int window_size=10; 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 private static final int TOTAL_TIME = 10; //seconds to send all data ! private static final int AXELER_KOEFF=2; //coeff depends on line quality, in practise >=2 /** --- 163,173 ---- private ProtocolStack mParentStack; private int window_size=10; + private int total_received=0; + private int total_sent=0; 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 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 /** *************** *** 550,556 **** public void setWindowSize(int inSeg) { ! window_size=(int)AXELER_KOEFF*inSeg/TOTAL_TIME; } } //EOF --- 554,783 ---- public void setWindowSize(int inSeg) { ! window_size=(int)ACCELER_KOEFF*inSeg/TOTAL_TIME; } + /** + * This method returns the TCP packet to send + * and prints out a message to the layer info. + * @author gift (sourceforge.net user) + * @param inDestIPAddress destination IP address + * @param inSourceIPAddress our IP address + * @param indestPort destination port number + * @param insrcPort our port number + * @param inMessage TCP message to send + * @param flags[] 6 flags to set in segment + * @return TCP_packet to send in Network Layer + * @exception TransportLayerException + * @version v0.30 + * @see TransportLayerException + */ + + public TCP_packet sendTCPPacket(String inDestIPAddress,String inSourceIPAddress, int indestPort, int insrcPort, String inMessage, boolean flags[]) throws TransportLayerException, LowLinkException + { + //check if window is available + TCP_HashTableElement Elm; + Elm = (TCP_HashTableElement) PortTable.get(insrcPort); + + if (Elm.seq_number <= (Integer)Elm.ReceivedACKs.lastElement()+window_size) + { + + int s_num; + int a_num; + TCP_packet tosend_clone = new TCP_packet(inDestIPAddress,inSourceIPAddress,indestPort,insrcPort); + TCP_packet tosend = new TCP_packet(inDestIPAddress,inSourceIPAddress,indestPort,insrcPort); + + tosend.setTCP_message(inMessage); + //now we set all the flags + /* URG, ACK, PSH, RST, SYN, FIN */ + tosend.set_URG_flag(flags[0]); + tosend.set_ACK_flag(flags[1]); + tosend.set_PSH_flag(flags[2]); + tosend.set_RST_flag(flags[3]); + tosend.set_SYN_flag(flags[4]); + tosend.set_FIN_flag(flags[5]); + + tosend_clone.set_URG_flag(flags[0]); + tosend_clone.set_ACK_flag(flags[1]); + tosend_clone.set_PSH_flag(flags[2]); + tosend_clone.set_RST_flag(flags[3]); + tosend_clone.set_SYN_flag(flags[4]); + tosend_clone.set_FIN_flag(flags[5]); + + //here we push out segment in Hashtable SegmentsToResend and increment counters + s_num=Elm.seq_number; //getting sequence number 0-for SYN + if (Elm.ReceivedSegments.isEmpty()) a_num=0; else a_num=(Integer)Elm.ReceivedSegments.lastElement()+1; //getting ACK number 0 - for SYN, 1 - as a reply for SYN ... so on + + tosend.set_sequence_number(s_num); + tosend.set_acknowledgment_number(a_num); + + tosend_clone.set_sequence_number(s_num); + tosend_clone.set_acknowledgment_number(a_num); + + //counters inc + Elm.sent_segments++; //UNIQUE ID + Elm.seq_number++; //inc for next segment + if (!(flags[4] && a_num==0)) Elm.sent_ACK++; //inc in case this is an ACK-segment (each segment except for 1-st SYN is ACK-segment) + this.total_sent++; //overall stats + + //pushing a copy into Hashtable + Elm.SegmentsToResend.put((Integer)s_num, tosend_clone); + + if (a_num==0 && flags[4]) //first SYN packet was sent => now he have to change port status to busy, as we will get reply to this port + { + Elm.PortStatus=2; + Elm.connectedtoIP=inDestIPAddress; + Elm.connectedtoPort=indestPort; + } + + + Elm=null; + + //Create Layer info + LayerInfo TCP_Info = new LayerInfo(getClass().getName()); + TCP_Info.setObjectName(mParentStack.getParentNodeName()); + TCP_Info.setDataType("TCP Protocol"); + TCP_Info.setLayer("Transport"); + TCP_Info.setDescription("Created TCP packet for " + inDestIPAddress + ":" + insrcPort +"."); + Simulation.addLayerInfo(TCP_Info); + + return tosend; + } else{ + throw new TransportLayerException("TCP Error: window size limit reached! Can not send segments. Wait for acknowledgenemts. Current window size is \"" + window_size +"\"."); + } + } + + + + /** + * This method receives the TCP packet, checks CHECK_SUM + * and prints out a message to the layer info. + * @author gift (sourceforge.net user) + * @param inPacket a packet to receive (decompilate) + * @return Nothing. + * @exception TransportLayerException If TCP CHECK_SUM != 1 + * @exception CommunicationException + * @exception LowLinkException + * @exception InvalidNetworkLayerDeviceException + * @exception TransportLayerPortException + * @version v0.20 + * @see TransportLayerException + * @see CommunicationException + * @see LowLinkException + * @see InvalidNetworkLayerDeviceException + * @see TransportLayerPortException + */ + + public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException + { + //test: check sum of TCP packet + if (inPacket.getCheck_Sum() == 1) + { + + // test if this packet is for a local Address. + if(mParentStack.isInternalIP(inPacket.getDestIPAddress())){ + this.total_received++; //overall stats + // test if destination TCP port exists on this NeworkLayerDevice + if (PortTable.get(inPacket.get_destPort()) !=null) + { + + //let's check all the things dealing with destination port number + TCP_HashTableElement Elm = null; + Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); + + switch(Elm.PortStatus) + { + case 0: //port is free => Error: no application to receive TCP + //have to disconnect listener from port + throw new TransportLayerPortException("TCP Error: no server application listening to port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"!"); + //no break needed ;) + case 1: // port is being listened to by a new application. + //Check for SYN + if (inPacket.get_SYN_flag()) + { + //Have to "establish" a new TCP connection by updating hashtable element information + //and sending out + + //in case this is not duplicate + Integer chk = (Integer)inPacket.get_sequence_number(); + if (Elm.ReceivedSegments.contains(chk)) + { + Elm.PortStatus=2; //port will be busy from now + Elm.connectedtoIP=inPacket.getSourceIPAddress(); + Elm.connectedtoPort=inPacket.get_srcPort(); + Elm.received_segments++; + Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received + // everything is OK now we decompose TCP datagram + + //Create Layer info + LayerInfo TCP_Info = new LayerInfo(getClass().getName()); + + TCP_Info.setObjectName(mParentStack.getParentNodeName()); + + TCP_Info.setDataType("TCP Protocol"); + + TCP_Info.setLayer("Transport"); + + TCP_Info.setDescription("TCP SYN-packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + "." + " TCP Port " + inPacket.get_destPort() + " has status \"busy\" from now."); + + Simulation.addLayerInfo(TCP_Info); + + //now we have to send ACK-segment (with SYN=true, seq_num=0, ack_num=1) + //we have one received segment so everything we have to do is just to call "mParentStack.sendTCPSegment(listener,msg,flags);" + String msg=""; + boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ + Application listener; + listener = (Application)Elm.application; + mParentStack.sendTCPSegment(listener,msg,flags); + + } else { //we have already received this segment + Elm.received_duplicates++; + } + } else { //not a SYN packet - have to wait until SYN packet will come + } + break; + + case 2: //busy port, let's check whether it's busy by sender ;) + if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) + { + //now we decompose TCP datagram + + // everything is OK, one more test: check sum of TCP packet + //Create Layer info + + LayerInfo TCP_Info = new LayerInfo(getClass().getName()); + + TCP_Info.setObjectName(mParentStack.getParentNodeName()); + + TCP_Info.setDataType("TCP Protocol"); + + TCP_Info.setLayer("Transport"); + + TCP_Info.setDescription("TCP packet received from "+ inPacket.getSourceIPAddress() + ":" + inPacket.get_srcPort() + " message: \"" +inPacket.getTCP_message() + "\"."); + + Simulation.addLayerInfo(TCP_Info); + + Application listener; + listener = (Application)Elm.application; + listener.RecvData(inPacket.getTCP_message()); + } else { + //have to disconnect listener from port + throw new TransportLayerPortException("TCP Error: port is busy! Port is connected to another host or/and port and is busy by another application." + "Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); + } + break; + + default: //TCP Error: unknown port status :( + //have to disconnect listener from port + throw new TransportLayerPortException("TCP Error: unknown port status! Port "+inPacket.get_destPort() +" on host \""+ mParentStack.getParentNodeName()+"\"."); + } + } else { + throw new TransportLayerPortException("TCP Error: port " + inPacket.get_destPort() + " does not exist. Host \"" + mParentStack.getParentNodeName()+"\"."); + } + } + } else { + throw new TransportLayerException("TCP Error: incorrect checksum on receiving!"); //comment this line if you have implemented check sum tests :) + } + } + + } //EOF |