[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip Application.java, 1.24, 1.25 DHCPC.java, 1.2,
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2007-10-20 13:27:27
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv20961/core/protocolsuite/tcp_ip Modified Files: Application.java DHCPC.java DHCPD.java Echo.java Echo_tcp.java ExternalProxyApp.java PosixTelnetClient.java SNMP.java TCP_packet.java Telnet_client.java Telnet_server.java Log Message: Node timers; DHCPC resendings; TCP to bytes packing. Index: TCP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_packet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TCP_packet.java 25 Sep 2007 22:34:09 -0000 1.5 --- TCP_packet.java 20 Oct 2007 13:27:21 -0000 1.6 *************** *** 420,424 **** return ( sequence_number - ((TCP_packet)o).sequence_number ); } ! }//EOF --- 420,463 ---- return ( sequence_number - ((TCP_packet)o).sequence_number ); } ! ! public String toBytes(){ ! return RawtoBytes() + IPtoBytes() + TCPtoBytes(); ! } ! ! public void fromBytes(String str){ ! RawfromBytes(str); ! IPfromBytes(str); ! TCPfromBytes(str); ! } ! ! public String TCPtoBytes(){ ! return "T|" + TCP_MessageLength + "|" + TCP_message + "|" + TCP_srcPort + "|" + TCP_destPort + "|" ! + TCP_window + "|" + get_acknowledgment_number() + "|" + get_sequence_number() + "|" ! + get_ACK_flag() + "|" + get_FIN_flag() + "|" + get_PSH_flag() + "|" + get_RST_flag() + "|" ! + get_SYN_flag() + "|" + get_URG_flag() + "|#"; ! } ! ! public void TCPfromBytes(String str){ ! String icmp = str.replaceAll(".*#T\\|", ""); ! ! System.out.println(icmp); ! ! String[] fields = icmp.split("\\|"); ! ! TCP_MessageLength = Integer.valueOf(fields[0]); ! TCP_message = fields[1]; ! TCP_srcPort = Integer.valueOf(fields[2]); ! TCP_destPort = Integer.valueOf(fields[3]); ! TCP_window = Integer.valueOf(fields[4]); ! set_acknowledgment_number(Integer.valueOf(fields[5])); ! set_sequence_number(Integer.valueOf(fields[6])); ! set_ACK_flag(Boolean.valueOf(fields[7])); ! set_FIN_flag(Boolean.valueOf(fields[8])); ! set_PSH_flag(Boolean.valueOf(fields[9])); ! set_RST_flag(Boolean.valueOf(fields[10])); ! set_SYN_flag(Boolean.valueOf(fields[11])); ! set_URG_flag(Boolean.valueOf(fields[12])); ! } ! }//EOF Index: Telnet_client.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_client.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Telnet_client.java 1 Oct 2007 04:58:12 -0000 1.15 --- Telnet_client.java 20 Oct 2007 13:27:21 -0000 1.16 *************** *** 36,39 **** --- 36,41 ---- appSock = mParentStack.SL().socket(jnSocket.TCP_socket, this); } + + public void Timer(int code){ } /** Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** Telnet_server.java 15 Oct 2007 21:41:43 -0000 1.19 --- Telnet_server.java 20 Oct 2007 13:27:21 -0000 1.20 *************** *** 41,44 **** --- 41,46 ---- appSock = mParentStack.SL().socket(jnSocket.TCP_socket, this); } + + public void Timer(int code){ } /** Index: PosixTelnetClient.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/PosixTelnetClient.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PosixTelnetClient.java 1 Oct 2007 04:58:12 -0000 1.6 --- PosixTelnetClient.java 20 Oct 2007 13:27:21 -0000 1.7 *************** *** 26,29 **** --- 26,31 ---- appSock = mParentStack.SL().socket(jnSocket.TCP_socket, this); } + + public void Timer(int code){ } /** Index: DHCPC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPC.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DHCPC.java 14 Oct 2007 17:19:07 -0000 1.2 --- DHCPC.java 20 Oct 2007 13:27:20 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- import core.LayerInfo; import core.Simulation; + import javax.lang.model.util.SimpleAnnotationValueVisitor6; /** *************** *** 26,29 **** --- 27,33 ---- int leaseTime; + String resend; + int resendings; + /** Creates a new instance of DHCPC */ *************** *** 33,36 **** --- 37,62 ---- running = false; completed = false; + resend = ""; + resendings = 0; + } + + public void Timer(int code){ + if(running){ + if(!completed){ + if(resend != "" && resendings++ < 5){ + LayerInfo protInfo = new LayerInfo(getClass().getName()); + protInfo.setObjectName(mParentStack.getParentNodeName()); + protInfo.setDataType("DHCP client"); + protInfo.setLayer("Application "); + protInfo.setDescription("Resening DHCP packet to 255.255.255.255 due to timer."); + Simulation.addLayerInfo(protInfo); + try{ + SendData(appSock, "255.255.255.255", 67, resend); + }catch(Exception e){} + } + }else{ + //re-lease + } + } } *************** *** 73,76 **** --- 99,103 ---- public void Free() throws TransportLayerException { + mParentStack.getParentNode().cancelTimerTask(this); printLayerInfo("DHCP Client", "DHCP Client application freed socket."); mParentStack.SL().free(appSock); *************** *** 174,179 **** r.chaddr + "' DHCP Server='" + r.DHCPServer + "' preferred IP='" + r.WantedIP + "'."); Simulation.addLayerInfo(protInfo); try{ ! SendData(appSock, "255.255.255.255", 67, r.toBytes()); }catch(CommunicationException e){ throw new TransportLayerException(e.toString()); --- 201,209 ---- r.chaddr + "' DHCP Server='" + r.DHCPServer + "' preferred IP='" + r.WantedIP + "'."); Simulation.addLayerInfo(protInfo); + + resend = r.toBytes(); + try{ ! SendData(appSock, "255.255.255.255", 67, resend); }catch(CommunicationException e){ throw new TransportLayerException(e.toString()); *************** *** 202,205 **** --- 232,238 ---- Simulation.addLayerInfo(protInfo); + resend = ""; + resendings = 0; + try{ mParentStack.setIPAddress(iface, p.yiaddr ); *************** *** 259,262 **** --- 292,298 ---- String Data = d.toBytes(); + resend = Data; + resendings = 0; + LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); *************** *** 274,277 **** --- 310,315 ---- Simulation.addLayerInfo(protInfo); + mParentStack.getParentNode().startTimerTask(this, 5000); + SendData(appSock, "255.255.255.255", 67, Data); } Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Echo_tcp.java 15 Oct 2007 12:04:33 -0000 1.39 --- Echo_tcp.java 20 Oct 2007 13:27:20 -0000 1.40 *************** *** 40,43 **** --- 40,45 ---- } + public void Timer(int code){ } + /** * This method start to listen on application port Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** Echo.java 19 Oct 2007 08:52:26 -0000 1.30 --- Echo.java 20 Oct 2007 13:27:20 -0000 1.31 *************** *** 26,32 **** public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); ! appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); int fake = 0; } /** --- 26,34 ---- public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); ! appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); int fake = 0; } + + public void Timer(int code){ } /** Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Application.java 13 Oct 2007 12:57:00 -0000 1.24 --- Application.java 20 Oct 2007 13:27:20 -0000 1.25 *************** *** 17,21 **** * @author key */ ! public abstract class Application { protected String protocolName; --- 17,21 ---- * @author key */ ! public abstract class Application extends core.TimerApp{ protected String protocolName; *************** *** 25,41 **** protected int appType; ! protected int appSock; - protected int UID; /** Creates a new instance of ApplicationProtocol */ public Application(ProtocolStack inParentStack, int listenPort, int appType, int UID){ this.listenPort = listenPort; this.mParentStack = inParentStack; ! this.appType = appType; ! this.UID = UID; } - /** * This method start to listen on application port --- 25,39 ---- protected int appType; ! protected int appSock; /** Creates a new instance of ApplicationProtocol */ public Application(ProtocolStack inParentStack, int listenPort, int appType, int UID){ + super(UID); this.listenPort = listenPort; this.mParentStack = inParentStack; ! this.appType = appType; } /** * This method start to listen on application port *************** *** 120,127 **** } - public int getUID(){ - return this.UID; - } - protected void printLayerInfo(String DataType, String s) { LayerInfo protInfo = new LayerInfo(getClass().getName()); --- 118,121 ---- Index: ExternalProxyApp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ExternalProxyApp.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ExternalProxyApp.java 15 Oct 2007 12:04:33 -0000 1.7 --- ExternalProxyApp.java 20 Oct 2007 13:27:20 -0000 1.8 *************** *** 71,74 **** --- 71,76 ---- System.out.println("NAT step 1.5"); } + + public void Timer(int code){ } /** Index: DHCPD.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/DHCPD.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DHCPD.java 15 Oct 2007 12:04:33 -0000 1.3 --- DHCPD.java 20 Oct 2007 13:27:20 -0000 1.4 *************** *** 63,67 **** appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } ! /** * This method start to listen on application port --- 63,69 ---- appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } ! ! public void Timer(int code){ } ! /** * This method start to listen on application port Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SNMP.java 15 Oct 2007 21:41:42 -0000 1.25 --- SNMP.java 20 Oct 2007 13:27:21 -0000 1.26 *************** *** 132,135 **** --- 132,138 ---- appSock = mParentStack.SL().socket(jnSocket.UDP_socket, this); } + + public void Timer(int code){ } + /** * This method start to listen on application port |