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