[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip Echo_tcp.java,1.1,1.2 ProtocolStack.java,1.17,
Status: Beta
Brought to you by:
darkkey
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); |