javanetsim-cvs Mailing List for javaNetSim (Page 27)
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: QweR <qw...@us...> - 2006-02-25 22:48:37
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19142/guiUI Modified Files: ApplicationLayerDevice.java MainScreen.java TelnetEmulator.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** MainScreen.java 25 Feb 2006 00:00:03 -0000 1.35 --- MainScreen.java 25 Feb 2006 22:48:34 -0000 1.36 *************** *** 3002,3033 **** } ! public void TelnetListen(String inNodeName){ ! String port = JOptionPane.showInputDialog(this, "Port:", "Set Telnet Server listening on port.", JOptionPane.QUESTION_MESSAGE); - if(port!=null){ - try{ - - - Telnet_server telnet1 = ((Telnet_server)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(23)); - telnet1.setPort(Integer.valueOf(port).intValue()); - telnet1.Listen(); - printLayerInfo(true); - }catch(Exception e){ - addToConsole(e.toString()); - } - } - } ! /** --- 3002,3028 ---- } ! public void TelnetListen(String inNodeName){ String port = JOptionPane.showInputDialog(this, "Port:", "Set Telnet Server listening on port.", JOptionPane.QUESTION_MESSAGE); if(port!=null){ try{ Telnet_server telnet1 = ((Telnet_server)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(23)); telnet1.setPort(Integer.valueOf(port).intValue()); telnet1.Listen(); printLayerInfo(true); }catch(Exception e){ addToConsole(e.toString()); } } } ! public void TelnetNoListen(String inNodeName){ ! try{ ! Telnet_server telnet1 = ((Telnet_server)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(23)); ! telnet1.Close(); ! }catch(Exception e){ ! addToConsole(e.toString()); ! } ! printLayerInfo(true); ! } ! /** *************** *** 3093,3096 **** --- 3088,3101 ---- } } + public void SNMPStopAgent(String inNodeName) { + try{ + SNMP snmpa = (SNMP)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(161); + snmpa.Close(); + } + catch(Exception e){ + addToConsole(e.toString()); + } + printLayerInfo(true); + } public void SNMPSendMessage(String inNodeName) { Index: TelnetEmulator.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/TelnetEmulator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** TelnetEmulator.java 25 Feb 2006 00:00:03 -0000 1.5 --- TelnetEmulator.java 25 Feb 2006 22:48:34 -0000 1.6 *************** *** 117,143 **** printInfo(); } ! else { ! String s = String.valueOf(e.getKeyCode()).toString(); ! sendData(s); ! printInfo(); ! } } }); - - // public void keyTyped(KeyEvent e) { - // - // char c = e.getKeyChar(); - // - // String s = String.valueOf(c).toString(); - // sendData(s); - // printInfo(); - // } - // }); this.addWindowListener( new java.awt.event.WindowAdapter() { ! public void windowClosing(WindowEvent winEvt) { ! printInfo(); ! } }); --- 117,134 ---- printInfo(); } ! // else { ! // String s = String.valueOf(e.getKeyCode()).toString(); ! // sendData(s); ! // printInfo(); ! // } } }); this.addWindowListener( new java.awt.event.WindowAdapter() { ! public void windowClosing(WindowEvent winEvt) { ! exitWindow(); ! printInfo(); ! } }); *************** *** 185,189 **** if(Data.compareTo("\nQUIT")==0) { this.removeKeyListener(kl); - terminal.setText(text + "\nServer closed connection."); } else { --- 176,179 ---- *************** *** 208,212 **** public void exitWindow(){ ! this.dispose(); } } --- 198,211 ---- public void exitWindow(){ ! // this.dispose(); ! try { ! telnet.Disconnect(); ! } ! catch(TransportLayerException e) { ! ! } ! catch(LowLinkException e) { ! ! } } } Index: ApplicationLayerDevice.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/ApplicationLayerDevice.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ApplicationLayerDevice.java 22 Feb 2006 16:29:30 -0000 1.7 --- ApplicationLayerDevice.java 25 Feb 2006 22:48:34 -0000 1.8 *************** *** 27,33 **** private JMenuItem mnuEchotcpSend = new JMenuItem("Send data via tcp echo client."); private JMenuItem mnuTelnetListen = new JMenuItem("Start telnet server to listen."); private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); private JMenu mnuAppLayer = new JMenu("Applications"); ! private JMenuItem mnuSNMPAgent = new JMenuItem("Start SNMP agent"); private JMenuItem mnuSNMPManager = new JMenuItem("Send SNMP message"); --- 27,35 ---- private JMenuItem mnuEchotcpSend = new JMenuItem("Send data via tcp echo client."); private JMenuItem mnuTelnetListen = new JMenuItem("Start telnet server to listen."); + private JMenuItem mnuTelnetNoListen = new JMenuItem("Stop telnet server."); private JMenuItem mnuTelnetConnect = new JMenuItem("Telnet client."); private JMenu mnuAppLayer = new JMenu("Applications"); ! private JMenuItem mnuSNMPStartAgent = new JMenuItem("Start SNMP agent"); ! private JMenuItem mnuSNMPStopAgent = new JMenuItem("Stop SNMP agent"); private JMenuItem mnuSNMPManager = new JMenuItem("Send SNMP message"); *************** *** 71,80 **** mnuAppLayer.add(mnuEchotcpSend); ! mnuSNMPAgent.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ controller.SNMPStartAgent(lblNodeName.getText()); } }); ! mnuSNMPManager.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ --- 73,86 ---- mnuAppLayer.add(mnuEchotcpSend); ! mnuSNMPStartAgent.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ controller.SNMPStartAgent(lblNodeName.getText()); } }); ! mnuSNMPStopAgent.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.SNMPStopAgent(lblNodeName.getText()); ! } ! }); mnuSNMPManager.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ *************** *** 82,85 **** --- 88,92 ---- } }); + mnuTelnetListen.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ *************** *** 87,91 **** } }); ! mnuTelnetConnect.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ --- 94,102 ---- } }); ! mnuTelnetNoListen.addActionListener(new ActionListener(){ ! public void actionPerformed(ActionEvent e){ ! controller.TelnetNoListen(lblNodeName.getText()); ! } ! }); mnuTelnetConnect.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ *************** *** 94,101 **** }); mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuSNMPAgent); mnuAppLayer.add(mnuSNMPManager); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuTelnetListen); mnuAppLayer.add(mnuTelnetConnect); } --- 105,114 ---- }); mnuAppLayer.addSeparator(); ! mnuAppLayer.add(mnuSNMPStartAgent); ! mnuAppLayer.add(mnuSNMPStopAgent); mnuAppLayer.add(mnuSNMPManager); mnuAppLayer.addSeparator(); mnuAppLayer.add(mnuTelnetListen); + mnuAppLayer.add(mnuTelnetNoListen); mnuAppLayer.add(mnuTelnetConnect); } |
From: gift <gi...@us...> - 2006-02-25 22:00:08
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29366/core/protocolsuite/tcp_ip Modified Files: Tcp.java Log Message: v.XXXXXxx.YYYYY.yyyy Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** Tcp.java 25 Feb 2006 01:11:54 -0000 1.43 --- Tcp.java 25 Feb 2006 22:00:04 -0000 1.44 *************** *** 470,477 **** Simulation.addLayerInfo(TCP_Info); Elm.addstats(TCPptr); Elm.reset(); } else ! { System.out.println("Timer cancel - part1!"); try{ --- 470,478 ---- Simulation.addLayerInfo(TCP_Info); Elm.addstats(TCPptr); + ((Application)Elm.application).DisconnectEvent(); Elm.reset(); } else ! { //nothing to resend, but numRepeat>0 System.out.println("Timer cancel - part1!"); try{ *************** *** 551,554 **** --- 552,556 ---- System.out.println("SERVER TIMEtoLIVE - OUT - awaiting connection timeout!"); Elm.addstats(TCPptr); + ((Application)Elm.application).DisconnectEvent(); Elm.reset(); try{ *************** *** 1556,1561 **** String msg=""; boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! Application listener; ! listener = (Application)Elm.application; int ack_num=chk+1; //our_ack==2 when connection is established --- 1558,1562 ---- String msg=""; boolean flags[]={false,true,false,false,false,false}; /* URG, !ACK!, PSH, RST, SYN, FIN */ ! int ack_num=chk+1; //our_ack==2 when connection is established *************** *** 1563,1567 **** //{ //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + " Data exchange mode, BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); --- 1564,1570 ---- //{ //we are going to send ACK for received segment => adding it to SentACKs ! Application listener; ! listener = (Application)Elm.application; ! System.out.println(mParentStack.getHostName() + ":" + " Data exchange mode, BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); |
From: gift <gi...@us...> - 2006-02-25 01:12:05
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10986/core/protocolsuite/tcp_ip Modified Files: TCP_packet.java Tcp.java Log Message: vvv Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Tcp.java 24 Feb 2006 17:16:00 -0000 1.42 --- Tcp.java 25 Feb 2006 01:11:54 -0000 1.43 *************** *** 129,132 **** --- 129,133 ---- /*end of statistic block*/ public int seq_number=0; + public int last_passed=-1; //last sequence number value of the segment that has been passed upstairs /*database*/ *************** *** 159,162 **** --- 160,172 ---- */ public Hashtable SegmentsToResend = new Hashtable(); + + /** + * Contains segments that have come in non consequential order + * maximun 200 segments can be stored + * <p>Key: Sequence number of the segment</p> + * <p>Object: The copy of the segment we have received</p> + * <p>Aim of this hashtable: necessarily to have, to pass segments upstairs in proper order</p> + */ + public Hashtable OutputBuffer = new Hashtable(200); /*end of database*/ *************** *** 232,235 **** --- 242,246 ---- this.sent_duplicates=0; this.seq_number=0; + this.last_passed=-1; if (!this.ReceivedSegments.isEmpty()) this.ReceivedSegments.removeAllElements(); *************** *** 284,287 **** --- 295,322 ---- } + try { + if (!this.OutputBuffer.isEmpty()) + { + /*Set set = this.OutputBuffer.keySet(); + Iterator itr = set.iterator(); + while (itr.hasNext()) + { + this.OutputBuffer.remove(itr.next()); + }*/ + Enumeration HTkeys; + Integer curkey; + HTkeys = OutputBuffer.keys(); + while (HTkeys.hasMoreElements()) + { + curkey= (Integer) HTkeys.nextElement(); + this.OutputBuffer.remove(curkey); + } + } + + } catch(Exception e) + { + System.out.println("TCP Element.OutputBuffer reset error: " + e.toString()); + } + this.isFIN_sent=false; this.isFIN_confirmed=false; *************** *** 296,299 **** --- 331,335 ---- private ProtocolStack mParentStack; private int window_size=25; + // private int total_received=0; // private int total_sent=0; *************** *** 1068,1072 **** public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { ! System.out.println(mParentStack.getHostName() + ":" + " !!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number()); //test: check sum of TCP packet --- 1104,1112 ---- public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { ! ! String sd=mParentStack.getHostName(); ! if (inPacket.get_ACK_flag()) sd=sd+" ACK-packet"; ! sd=sd + ":" + " !!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number(); ! System.out.println(sd); //test: check sum of TCP packet *************** *** 1084,1088 **** Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); ! System.out.println(Elm.PortStatus); switch(Elm.PortStatus) --- 1124,1128 ---- Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); ! //System.out.println(Elm.PortStatus); switch(Elm.PortStatus) *************** *** 1090,1099 **** case 0: //port is free => Error: no application to receive TCP //have to disconnect listener from port ! System.out.println(mParentStack.getHostName() + ":" + " !! 0 SEQ_numb==" + inPacket.get_sequence_number()); throw new TransportLayerPortException("TCP Error: no 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 ! System.out.println(mParentStack.getHostName() + ":" + " !! 1 SEQ_numb==" + inPacket.get_sequence_number()); try{ --- 1130,1139 ---- case 0: //port is free => Error: no application to receive TCP //have to disconnect listener from port ! //System.out.println(mParentStack.getHostName() + ":" + " !! 0 SEQ_numb==" + inPacket.get_sequence_number()); throw new TransportLayerPortException("TCP Error: no 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 ! //System.out.println(mParentStack.getHostName() + ":" + " !! 1 SEQ_numb==" + inPacket.get_sequence_number()); try{ *************** *** 1137,1140 **** --- 1177,1182 ---- listener = (Application)Elm.application; + AddOutputBuffer(Elm, inPacket); + //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + "Server received first SYN: I=" + inPacket.get_sequence_number()); *************** *** 1159,1166 **** case 2: //busy port, let's check whether it's busy by sender ;) ! System.out.println(mParentStack.getHostName() + ":" + " !! 2 SEQ_numb==" + inPacket.get_sequence_number()); if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) { ! System.out.println(mParentStack.getHostName() + ":" + " !! 3 SEQ_numb==" + inPacket.get_sequence_number()); //now we decompose TCP segment //everything is OK --- 1201,1208 ---- case 2: //busy port, let's check whether it's busy by sender ;) ! //System.out.println(mParentStack.getHostName() + ":" + " !! 2 SEQ_numb==" + inPacket.get_sequence_number()); if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) { ! //System.out.println(mParentStack.getHostName() + ":" + " !! 3 SEQ_numb==" + inPacket.get_sequence_number()); //now we decompose TCP segment //everything is OK *************** *** 1168,1172 **** if (inPacket.get_SYN_flag()) { ! System.out.println(mParentStack.getHostName() + ":" + " !! 4 SEQ_numb==" + inPacket.get_sequence_number()); try{ /* --- 1210,1214 ---- if (inPacket.get_SYN_flag()) { ! //System.out.println(mParentStack.getHostName() + ":" + " !! 4 SEQ_numb==" + inPacket.get_sequence_number()); try{ /* *************** *** 1186,1190 **** if (!(Elm.ReceivedSegments.contains(chk))) { ! System.out.println(mParentStack.getHostName() + ":" + " !! 5 SEQ_numb==" + inPacket.get_sequence_number()); try{ if (Elm.isServer) --- 1228,1232 ---- if (!(Elm.ReceivedSegments.contains(chk))) { ! //System.out.println(mParentStack.getHostName() + ":" + " !! 5 SEQ_numb==" + inPacket.get_sequence_number()); try{ if (Elm.isServer) *************** *** 1194,1198 **** } else TCPsetTimer(Elm, 5); }catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1162 " + e.toString()); } --- 1236,1240 ---- } else TCPsetTimer(Elm, 5); }catch(NullPointerException e){ ! //System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1162 " + e.toString()); } *************** *** 1232,1236 **** Application listener; listener = (Application)Elm.application; ! try{ --- 1274,1280 ---- Application listener; listener = (Application)Elm.application; ! ! AddOutputBuffer(Elm, inPacket); ! try{ *************** *** 1287,1291 **** //NOT SYN-segment //check for FIN ! System.out.println(mParentStack.getHostName() + ":" + " !! 6 SEQ_numb==" + inPacket.get_sequence_number()); try{ if (inPacket.get_FIN_flag()) --- 1331,1335 ---- //NOT SYN-segment //check for FIN ! //System.out.println(mParentStack.getHostName() + ":" + " !! 6 SEQ_numb==" + inPacket.get_sequence_number()); try{ if (inPacket.get_FIN_flag()) *************** *** 1296,1302 **** Integer chk = (Integer)inPacket.get_sequence_number(); if (!(Elm.ReceivedSegments.contains(chk))) ! { ! ! if (Elm.isServer) { --- 1340,1344 ---- Integer chk = (Integer)inPacket.get_sequence_number(); if (!(Elm.ReceivedSegments.contains(chk))) ! { if (Elm.isServer) { *************** *** 1346,1350 **** listener = (Application)Elm.application; //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + "FIN-packet FIN not sent, BEFORE: I=" + inPacket.get_sequence_number()); --- 1388,1392 ---- listener = (Application)Elm.application; //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! AddOutputBuffer(Elm, inPacket); //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + "FIN-packet FIN not sent, BEFORE: I=" + inPacket.get_sequence_number()); *************** *** 1367,1371 **** Elm.isFIN_confirmed=true; int ack_num=chk+1; ! //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + "FIN-packet FIN sent, BEFORE: I=" + inPacket.get_sequence_number()); --- 1409,1413 ---- Elm.isFIN_confirmed=true; int ack_num=chk+1; ! AddOutputBuffer(Elm, inPacket); //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + "FIN-packet FIN sent, BEFORE: I=" + inPacket.get_sequence_number()); *************** *** 1386,1390 **** Application listener; listener = (Application)Elm.application; int ack_num=chk+1; ! //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + " FIN-receiver, BEFORE: I=" + inPacket.get_sequence_number()); --- 1428,1432 ---- Application listener; listener = (Application)Elm.application; int ack_num=chk+1; ! AddOutputBuffer(Elm, inPacket); //we are going to send ACK for received segment => adding it to SentACKs System.out.println(mParentStack.getHostName() + ":" + " FIN-receiver, BEFORE: I=" + inPacket.get_sequence_number()); *************** *** 1468,1471 **** --- 1510,1514 ---- Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received + AddOutputBuffer(Elm, inPacket); if (inPacket.get_ACK_flag()) *************** *** 1546,1550 **** // if (Elm.received_segments>2) ! listener.RecvData(inPacket.getTCP_message()); } --- 1589,1594 ---- // if (Elm.received_segments>2) ! // listener.RecvData(inPacket.getTCP_message()); ! PassUpstairs(listener, Elm); } *************** *** 1635,1639 **** public TCP_packet getTCPPacket_clone(String inDestIPAddress,String inSourceIPAddress, int indestPort, int insrcPort, String inMessage, boolean flags[], int acknow_num) throws TransportLayerException, LowLinkException { - //check if window is available TCP_HashTableElement Elm; Elm = (TCP_HashTableElement) PortTable.get(insrcPort); --- 1679,1682 ---- *************** *** 1836,1843 **** ResetReceiptCounters(); } - - - } //EOF --- 1879,1947 ---- ResetReceiptCounters(); } + /** + * This method sends to application all consequent segments from OutputBuffer + * @author gift (sourceforge.net user) + * @param listener target application + * @param Elm TCP_Hashtable contains necessary info + * @return Nothing. + * @exception LowLinkException + * @exception TransportLayerException + * @version v0.20 + * @see LowLinkException + * @see TransportLayerException + */ + private void PassUpstairs(Application listener, TCP_HashTableElement Elm) throws LowLinkException, TransportLayerException + { + Integer kkey=Elm.last_passed+1;//=new Integer(Elm.last_passed+1); + + while(Elm.OutputBuffer.containsKey(kkey)) + { + Elm.last_passed=kkey; + TCP_packet Packet=(TCP_packet) Elm.OutputBuffer.remove(kkey); + kkey++; + if((!Packet.get_ACK_flag()) && (!Packet.get_SYN_flag())) + listener.RecvData(Packet.getTCP_message()); + } + + + } + + /** + * This adds segment to OutputBuffer + * @author gift (sourceforge.net user) + * @param Elm TCP_Hashtable contains necessary info + * @param Packet TCP_packet which clone has to be stored in OutputBuffer + * @return Nothing. + * @exception TransportLayerException + * @version v0.20 + * @see TransportLayerException + */ + private void AddOutputBuffer(TCP_HashTableElement Elm, TCP_packet Packet) throws TransportLayerException + { + if (Elm.OutputBuffer.size()==200) + { + throw new TransportLayerException("TCP Error: maximum buffer size reached! Can not keep on receiving TCP segments. Bad connection to: " + Elm.connectedtoIP + ":" + Elm.connectedtoPort + "."); + } else + { + TCP_packet to_buff=new TCP_packet(Packet.getDestIPAddress(), Packet.getSourceIPAddress(), Packet.get_destPort(), Packet.get_srcPort()); + try { + to_buff.setTCP_message(Packet.getTCP_message()); + } catch(TransportLayerException e) {} //will never be thrown from here ;) + + to_buff.set_sequence_number(Packet.get_sequence_number()); + to_buff.set_acknowledgment_number(Packet.get_acknowledgment_number()); + + to_buff.set_URG_flag(Packet.get_URG_flag()); + to_buff.set_ACK_flag(Packet.get_ACK_flag()); + to_buff.set_PSH_flag(Packet.get_PSH_flag()); + to_buff.set_RST_flag(Packet.get_RST_flag()); + to_buff.set_SYN_flag(Packet.get_SYN_flag()); + to_buff.set_FIN_flag(Packet.get_FIN_flag()); + + Elm.OutputBuffer.put(new Integer(Packet.get_sequence_number()), to_buff); + } + } + } //EOF Index: TCP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/TCP_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TCP_packet.java 26 Nov 2005 16:25:38 -0000 1.1 --- TCP_packet.java 25 Feb 2006 01:11:54 -0000 1.2 *************** *** 115,449 **** ! /** ! * 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 --- 115,448 ---- ! /** ! * 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: QweR <qw...@us...> - 2006-02-25 00:00:10
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6308/core/protocolsuite/tcp_ip Modified Files: Telnet_client.java Telnet_server.java Log Message: Index: Telnet_client.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_client.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Telnet_client.java 24 Feb 2006 15:41:44 -0000 1.4 --- Telnet_client.java 25 Feb 2006 00:00:03 -0000 1.5 *************** *** 23,26 **** --- 23,27 ---- import guiUI.TelnetEmulator; + import core.ApplicationLayerDevice; /** *************** *** 31,41 **** public class Telnet_client extends Application{ ! private byte ConnectionAttempts=5; private TelnetEmulator terminal; private int counts; /** Creates a new instance of Telnet Server */ ! public Telnet_client(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); counts = 0; } --- 32,44 ---- public class Telnet_client extends Application{ ! private int ConnectionAttempts=1; ! private ApplicationLayerDevice mDevice; private TelnetEmulator terminal; private int counts; /** Creates a new instance of Telnet Server */ ! public Telnet_client(ApplicationLayerDevice dev, ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); + mDevice = dev; counts = 0; } *************** *** 78,82 **** LayerInfo protInfo2 = new LayerInfo(getClass().getName()); protInfo2.setObjectName(mParentStack.getParentNodeName()); ! protInfo2.setDataType("Echo Protocol Data"); protInfo2.setLayer("Application "); protInfo2.setDescription("Connecting to host " + Host + ":"+ port +". Please wait..."); --- 81,85 ---- LayerInfo protInfo2 = new LayerInfo(getClass().getName()); protInfo2.setObjectName(mParentStack.getParentNodeName()); ! protInfo2.setDataType("Telnet Protocol Data"); protInfo2.setLayer("Application "); protInfo2.setDescription("Connecting to host " + Host + ":"+ port +". Please wait..."); *************** *** 110,114 **** */ ! public void DisconnectEvent(){ } /** --- 113,119 ---- */ ! public void DisconnectEvent(){ ! System.out.print("\n---------------------------\n\nIT WORKS!!!\n\n----------------------------------\n"); ! } /** *************** *** 127,131 **** LayerInfo protInfo3 = new LayerInfo(getClass().getName()); protInfo3.setObjectName(mParentStack.getParentNodeName()); ! protInfo3.setDataType("Echo Protocol Data"); protInfo3.setLayer("Application "); if(appType==0){ --- 132,136 ---- LayerInfo protInfo3 = new LayerInfo(getClass().getName()); protInfo3.setObjectName(mParentStack.getParentNodeName()); ! protInfo3.setDataType("Telnet Protocol Data"); protInfo3.setLayer("Application "); if(appType==0){ *************** *** 172,176 **** LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); protInfo.setLayer("Application "); protInfo.setDescription("Recieving echo message '" + Data + "' from server."); --- 177,181 ---- LayerInfo protInfo = new LayerInfo(getClass().getName()); protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Telnet Protocol Data"); protInfo.setLayer("Application "); protInfo.setDescription("Recieving echo message '" + Data + "' from server."); *************** *** 185,189 **** if(Data.compareTo("\nQUIT")==0) { ! Close(); } terminal.recvData(Data); --- 190,194 ---- if(Data.compareTo("\nQUIT")==0) { ! Disconnect(); } terminal.recvData(Data); Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Telnet_server.java 24 Feb 2006 10:20:11 -0000 1.4 --- Telnet_server.java 25 Feb 2006 00:00:03 -0000 1.5 *************** *** 19,24 **** import core.Packet; ! import core.Simulation; /** --- 19,25 ---- import core.Packet; ! import core.ApplicationLayerDevice; import core.Simulation; + import java.util.regex.*; /** *************** *** 29,33 **** public class Telnet_server extends Application{ ! private byte ConnectionAttempts=5; private int counts; private String cmdline=""; --- 30,35 ---- public class Telnet_server extends Application{ ! private int ConnectionAttempts=1; ! private ApplicationLayerDevice mDevice; private int counts; private String cmdline=""; *************** *** 35,45 **** private boolean islogin=false; private boolean ispass=false; private String password = "123"; private String login = "root"; ! private String userlogin = ""; /** Creates a new instance of Telnet Server */ ! public Telnet_server(ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); counts = 0; } --- 37,50 ---- private boolean islogin=false; private boolean ispass=false; + private boolean isprompt=true; + private boolean isnewpass=false; private String password = "123"; private String login = "root"; ! private String temp = ""; /** Creates a new instance of Telnet Server */ ! public Telnet_server(ApplicationLayerDevice dev, ProtocolStack inParentStack, int listenPort, int appType, int UID) { super(inParentStack, listenPort, appType, UID); + mDevice = dev; counts = 0; } *************** *** 92,96 **** */ ! public void DisconnectEvent(){ } /** --- 97,117 ---- */ ! public void DisconnectEvent(){ ! LayerInfo protInfo3 = new LayerInfo(getClass().getName()); ! try{ ! Close(); ! printInfo("Server closing connection"); ! try{ ! Listen(); ! printInfo("Server listening on port " + listenPort); ! } ! catch(TransportLayerException e){ ! printInfo("Server can not listen on port " + listenPort); ! } ! } ! catch(TransportLayerException e){ ! printInfo("Server can not close connection"); ! } ! } /** *************** *** 105,120 **** }catch(Exception e){ ///*TODO*: here to catch ! } - LayerInfo protInfo3 = new LayerInfo(getClass().getName()); - protInfo3.setObjectName(mParentStack.getParentNodeName()); - protInfo3.setDataType("Echo Protocol Data"); - protInfo3.setLayer("Application "); if(appType==0){ ! protInfo3.setDescription("Application closing connection."); }else{ ! protInfo3.setDescription("Application closing connection. Now listening on " + listenPort + "."); } - Simulation.addLayerInfo(protInfo3); mParentStack.CloseTCP(this); --- 126,136 ---- }catch(Exception e){ ///*TODO*: here to catch ! } if(appType==0){ ! printInfo("Application closing connection."); }else{ ! printInfo("Application closing connection. Now listening on port" + listenPort + "."); } mParentStack.CloseTCP(this); *************** *** 151,178 **** //server processing recieve ! LayerInfo protInfo = new LayerInfo(getClass().getName()); ! protInfo.setObjectName(mParentStack.getParentNodeName()); ! protInfo.setDataType("Echo Protocol Data"); ! protInfo.setLayer("Application "); ! protInfo.setDescription("Recieving echo message '" + Data + "' from client."); ! Simulation.addLayerInfo(protInfo); ! ! LayerInfo protInfo2 = new LayerInfo(getClass().getName()); ! protInfo2.setObjectName(mParentStack.getParentNodeName()); ! protInfo2.setDataType("Echo Protocol Data"); ! protInfo2.setLayer("Application "); ! protInfo2.setDescription("Sending echo message '" + Data + "' to client."); ! Simulation.addLayerInfo(protInfo2); String outData=""; if(isenter && Data.compareTo("\n")==0) { ! outData = "\nlogin: "; islogin = true; isenter = false; } ! else { int ch = (char)Data.charAt(0); switch(ch) { - case 0x03: case 0x04: { outData = "\nQUIT"; --- 167,182 ---- //server processing recieve ! printInfo("Recieving echo message '" + Data + "' from client."); String outData=""; if(isenter && Data.compareTo("\n")==0) { ! outData = "login: "; islogin = true; isenter = false; } ! else ! { int ch = (char)Data.charAt(0); switch(ch) { case 0x04: { outData = "\nQUIT"; *************** *** 180,185 **** } case 0x08: { ! outData="\b"; ! cmdline = cmdline.substring(0,cmdline.length()-1); break; } --- 184,191 ---- } case 0x08: { ! if(cmdline.length() > 0) { ! outData="\b"; ! cmdline = cmdline.substring(0,cmdline.length()-1); ! } break; } *************** *** 187,191 **** if(islogin) { islogin = false; ! userlogin = cmdline; ispass = true; outData = "\npassword: "; --- 193,197 ---- if(islogin) { islogin = false; ! temp = cmdline; ispass = true; outData = "\npassword: "; *************** *** 193,198 **** else if(ispass) { ispass = false; ! if(userlogin.compareTo(login)==0 && cmdline.compareTo(password)==0) { ! outData = "\nWelcome to " + mParentStack.getParentNodeName() + "\n"; } else { --- 199,204 ---- else if(ispass) { ispass = false; ! if(temp.compareTo(login)==0 && cmdline.compareTo(password)==0) { ! outData = "\nWelcome to " + mParentStack.getParentNodeName() + "\n" + runcmd(""); } else { *************** *** 206,209 **** --- 212,232 ---- } } + else if(isnewpass) { + if(temp.compareTo("")==0) { + temp = cmdline; + outData = "\nRetype new password: "; + } + else { + if(temp.compareTo(cmdline)==0) { + password = temp; + outData = "\n" + runcmd(""); + } + else { + outData = "\n Password is not identical\n" + runcmd(""); + } + isnewpass = false; + temp=""; + } + } else { cmdline = removeSpaces(cmdline); *************** *** 214,230 **** } // case 0x1B: outData="ESC"; break; - case 0x20: { - if(ispass) { - outData="*"; - } - else { - outData=" "; - } - break; - } default: ! if(ch>=0x30 && ch<0x80) { ! if(ispass) { outData = "*"; } --- 237,244 ---- } // case 0x1B: outData="ESC"; break; default: ! if(ch>=0x20 && ch<0x80) { ! if(ispass || isnewpass) { outData = "*"; } *************** *** 239,246 **** } } ! try { SendData(outData); if(outData.compareTo("\nQUIT")==0) { Close(); isenter = true; } --- 253,262 ---- } } ! try { ! printInfo("Sending echo message '" + outData + "' to client."); SendData(outData); if(outData.compareTo("\nQUIT")==0) { Close(); + Listen(); isenter = true; } *************** *** 275,282 **** private String runcmd(String cmd) { ! if(cmd.compareToIgnoreCase("quit")==0) { return "QUIT"; } ! return "bad command\n"; } --- 291,396 ---- private String runcmd(String cmd) { ! String out=""; ! if(cmd.compareTo("")==0) { ! //nothing ! } ! else if(cmd.compareTo("?")==0) { ! out += "route \t\t show/edit route table\n"; ! out += "arp \t\t show/edit arp table"; ! out += "snmp \t\t on/off snmp agent\n"; ! out += "counters \t\t show network counters\n"; ! out += "passwd \t\t change password\n"; ! out += "quit \t\t close terminal session\n"; ! out += "? \t\t show this screen\n"; ! } ! else if(cmd.compareToIgnoreCase("quit")==0) { return "QUIT"; } ! else { ! String tokens[]=cmd.split(" "); ! Matcher m; ! // if(m.find()) { ! // if(m.group(1).compareTo("route")==0); ! // } ! if(tokens[0].compareTo("route")==0){ ! if((m=Pattern.compile(" +print$").matcher(cmd)).find()) { ! ! String routes[] = mParentStack.getRouteTableEntries(); ! out += "IP routing table:\n" + "Destination" + "\t" + "Gateway" + "\t" + "Genmask" + "\t" + "Type" + "\t" + "Iface\n"; ! for(int i=0; i<routes.length - 1; i++){ ! Route_entry r = mParentStack.getRouteTableEntry(routes[i]); ! out += routes[i] + "\t" + r.gateway + "\t" + r.genMask + "\t" + r.Type + "\t" + r.iFace + "\n"; ! } ! } ! else if((m=Pattern.compile(" +add +([^ ]+) +([^ ]+) +([^ ]+)( +([^ ]+|\\*))?$").matcher(cmd)).find()) { ! String a = m.group(5); ! String b = m.group(4); ! Route_entry r = new Route_entry(m.group(1), m.group(5), m.group(3), m.group(2), 0); ! mParentStack.addRoute(r); ! out+="Route added.\n"; ! } ! else if((m=Pattern.compile(" +del +([^ ]+)$").matcher(cmd)).find()) { ! mParentStack.removeRoute(m.group(1)); ! out+="Route to " + tokens[2] + "removed.\n"; ! } ! else{ ! out+="Unknown route command. Usage:\n"; ! out+="route add (host_ip|network_ip) target_interface netmask (gateway|*) \n"; ! out+="route del (host_ip|network_ip) \n"; ! out+="route print \n"; ! } ! } ! else if(tokens[0].compareTo("snmp")==0){ ! if((m=Pattern.compile(" +(on|\\d+)( +([^ ]+))?$").matcher(cmd)).find()) { ! int l_port=161; ! String l_pass="public"; ! if(m.group(1).compareTo("on")!=0) l_port = Integer.parseInt(m.group(1)); ! if(m.group(2).compareTo("")!=0) l_pass = m.group(2); ! SNMP snmpa = (SNMP) mDevice.getApp(161); ! snmpa.setPassword(l_pass); ! snmpa.setPort(l_port); ! try{ ! snmpa.Listen(); ! } ! catch(TransportLayerException e) { ! out+="Unable to open connection on SNMP agent\n"; ! } ! } ! else if((m=Pattern.compile(" +off$").matcher(cmd)).find()) { ! SNMP snmpa = (SNMP) mDevice.getApp(161); ! try{ ! snmpa.Close(); ! } ! catch(TransportLayerException e) { ! out+="Unable to close connection on SNMP agent\n"; ! } ! } ! } ! else if(tokens[0].compareTo("passwd")==0){ ! temp=""; ! isnewpass=true; ! out="Type new password: "; ! return out; ! } ! else if(tokens[0].compareTo("counters")==0){ ! out += " Recieved IP Packets: " + Integer.valueOf(mParentStack.getinputIPCount()).toString() + ! "\n Sent IP Packets: " + Integer.valueOf(mParentStack.getoutputIPCount()).toString() + ! "\n ARP Packets: " + Integer.valueOf(mParentStack.getARPCount()).toString() + ! "\n Recieved TCP segments: " + Integer.valueOf(mParentStack.getTCPinputCount()).toString() + ! "\n Sent TCP segments: " + Integer.valueOf(mParentStack.getTCPoutputCount()).toString() + ! "\n Sent TCP ACK's: " + Integer.valueOf(mParentStack.getTCPACKCount()).toString() + ! "\n Sent TCP Dublicates: " + Integer.valueOf(mParentStack.getTCPSDCount()).toString() + ! "\n Recieved TCP Dublicates: " + Integer.valueOf(mParentStack.getTCPRDCount()).toString() + ! "\n Recieved UDP segments: " + Integer.valueOf(mParentStack.getUDPinputCount()).toString() + ! "\n Sent UDP segments: " + Integer.valueOf(mParentStack.getUDPoutputCount()).toString() + ! "\n"; ! } ! else if(tokens[0].compareTo("arp")==0){ ! ! } ! else out = tokens[0] + ": command not found\n"; ! } ! out+=mParentStack.getParentNodeName() + " # "; ! return out; } *************** *** 286,289 **** --- 400,412 ---- return s; } + + private void printInfo(String s) { + LayerInfo protInfo3 = new LayerInfo(getClass().getName()); + protInfo3.setObjectName(mParentStack.getParentNodeName()); + protInfo3.setDataType("Telnet Protocol Data"); + protInfo3.setLayer("Application "); + protInfo3.setDescription(s); + Simulation.addLayerInfo(protInfo3); + } } |
From: QweR <qw...@us...> - 2006-02-25 00:00:10
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6308/core Modified Files: PC.java Log Message: Index: PC.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/PC.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PC.java 22 Feb 2006 20:04:27 -0000 1.9 --- PC.java 25 Feb 2006 00:00:02 -0000 1.10 *************** *** 116,122 **** SNMP snmpManager = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 0, 1, core.ProtocolStack.UIDGen++); ! Telnet_server telnetServer = new Telnet_server(NodeProtocolStack, 23, 1, core.ProtocolStack.UIDGen++); ! Telnet_client telnetClient = new Telnet_client(NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); addApp(echoServer, 7); --- 116,122 ---- SNMP snmpManager = new SNMP((ApplicationLayerDevice)this, NodeProtocolStack, 0, 1, core.ProtocolStack.UIDGen++); ! Telnet_server telnetServer = new Telnet_server((ApplicationLayerDevice)this, NodeProtocolStack, 23, 1, core.ProtocolStack.UIDGen++); ! Telnet_client telnetClient = new Telnet_client((ApplicationLayerDevice)this, NodeProtocolStack, 0, 0, core.ProtocolStack.UIDGen++); addApp(echoServer, 7); |
From: QweR <qw...@us...> - 2006-02-25 00:00:10
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6308/guiUI Modified Files: MainScreen.java TelnetEmulator.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** MainScreen.java 23 Feb 2006 23:25:19 -0000 1.34 --- MainScreen.java 25 Feb 2006 00:00:03 -0000 1.35 *************** *** 3175,3181 **** public void TelnetConnect(String inNodeName){ ! String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); if(ip!=null){ ! String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); if(port!=null) { try{ --- 3175,3181 ---- public void TelnetConnect(String inNodeName){ ! String ip = JOptionPane.showInputDialog(this, "Server IP:", "Telnet connect to...", JOptionPane.QUESTION_MESSAGE); if(ip!=null){ ! String port = JOptionPane.showInputDialog(this, "Server Port:", "Telnet connect to...", JOptionPane.QUESTION_MESSAGE); if(port!=null) { try{ Index: TelnetEmulator.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/TelnetEmulator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TelnetEmulator.java 23 Feb 2006 23:25:19 -0000 1.4 --- TelnetEmulator.java 25 Feb 2006 00:00:03 -0000 1.5 *************** *** 22,25 **** --- 22,26 ---- import javax.swing.JTextField; + import javax.swing.JScrollPane; import javax.swing.JTextArea; *************** *** 83,87 **** private final Telnet_client telnet; private JPanel panel; ! // private JLabel terminal; private JTextArea terminal; private String text; --- 84,88 ---- private final Telnet_client telnet; private JPanel panel; ! private JScrollPane scrollpane; private JTextArea terminal; private String text; *************** *** 106,109 **** --- 107,111 ---- terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); panel = new JPanel(); + scrollpane = new JScrollPane(); this.addKeyListener( kl = new KeyAdapter(){ *************** *** 115,118 **** --- 117,125 ---- printInfo(); } + else { + String s = String.valueOf(e.getKeyCode()).toString(); + sendData(s); + printInfo(); + } } }); *************** *** 140,145 **** this.setContentPane(panel); ! ! panel.add(terminal); try{ --- 147,152 ---- this.setContentPane(panel); ! panel.add(scrollpane); ! scrollpane.setViewportView(terminal); try{ |
From: gift <gi...@us...> - 2006-02-24 17:16:04
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14719/core/protocolsuite/tcp_ip Modified Files: Tcp.java Log Message: var numRET Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Tcp.java 24 Feb 2006 15:41:44 -0000 1.41 --- Tcp.java 24 Feb 2006 17:16:00 -0000 1.42 *************** *** 315,321 **** * Used in timer */ ! private static final long TCP_SERVER_TIME = 10000; //msec //server closing idle connection time private static final long TCP_CONNECT_SERVER_TIME = 250; //msec //server closing idle connection time ! private static final long TCP_SENDER_TIME = 10000; //msec time to resend all segments in SegmentsToresend queue private static final long TCP_CONNECT_TIME = 200; //msec time to resend all segments in SegmentsToresend queue whn connecting --- 315,321 ---- * Used in timer */ ! private static final long TCP_SERVER_TIME = 1000; //msec //server closing idle connection time private static final long TCP_CONNECT_SERVER_TIME = 250; //msec //server closing idle connection time ! private static final long TCP_SENDER_TIME = 1000; //msec time to resend all segments in SegmentsToresend queue private static final long TCP_CONNECT_TIME = 200; //msec time to resend all segments in SegmentsToresend queue whn connecting *************** *** 343,349 **** * @author gift (sourceforge.net user) * @param Elm TCP_HashTableElement * @version v0.10 */ ! public void TCPsetTimer(TCP_HashTableElement Elm) { if(Elm.timer==null) --- 343,350 ---- * @author gift (sourceforge.net user) * @param Elm TCP_HashTableElement + * @param int inRep * @version v0.10 */ ! public void TCPsetTimer(TCP_HashTableElement Elm, int inREP) { if(Elm.timer==null) *************** *** 351,355 **** System.out.println("Sender timer init!"); Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_CONNECT_TIME,this),TCP_CONNECT_TIME,TCP_CONNECT_TIME); } else { --- 352,356 ---- System.out.println("Sender timer init!"); Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_CONNECT_TIME,this, inREP),TCP_CONNECT_TIME,TCP_CONNECT_TIME); } else { *************** *** 358,362 **** Elm.timer=null; Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_SENDER_TIME,this), TCP_SENDER_TIME, TCP_SENDER_TIME); System.out.println(" Sender Timer REinit DONE!"); } --- 359,363 ---- Elm.timer=null; Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_SENDER_TIME,this, inREP), TCP_SENDER_TIME, TCP_SENDER_TIME); System.out.println(" Sender Timer REinit DONE!"); } *************** *** 367,380 **** public class TCPTask extends TimerTask { ! private int numRepeat=5; private TCP_HashTableElement Elm; private long repTime; private Tcp TCPptr; ! public TCPTask (TCP_HashTableElement inElm, long time, Tcp inTCP) { this.Elm=inElm; this.repTime=time; this.TCPptr=inTCP; } --- 368,382 ---- public class TCPTask extends TimerTask { ! private int numRepeat; //5 when connecting, 50 when working private TCP_HashTableElement Elm; private long repTime; private Tcp TCPptr; ! public TCPTask (TCP_HashTableElement inElm, long time, Tcp inTCP, int inREP) { this.Elm=inElm; this.repTime=time; this.TCPptr=inTCP; + this.numRepeat=inREP; } *************** *** 411,417 **** Elm.sent_duplicates++; ! System.out.println("trying to send in timer"); mParentStack.sendPacket((TCP_packet)Elm.SegmentsToResend.get(curkey)); ! System.out.println("never be here II."); } catch (Exception e) {System.out.println("Queue of segments to resend INNER ERROR: " + e.toString());} } --- 413,419 ---- Elm.sent_duplicates++; ! // System.out.println("trying to send in timer"); mParentStack.sendPacket((TCP_packet)Elm.SegmentsToResend.get(curkey)); ! // System.out.println("never be here II."); } catch (Exception e) {System.out.println("Queue of segments to resend INNER ERROR: " + e.toString());} } *************** *** 458,464 **** * @param Elm TCP_HashTableElement * @param inlocalPort int local port number * @version v0.10 */ ! public void TCPsetServerTimer(TCP_HashTableElement Elm, int inlocalPort) { if(Elm.Servertimer==null) --- 460,467 ---- * @param Elm TCP_HashTableElement * @param inlocalPort int local port number + * @param inREP int number of repeats * @version v0.10 */ ! public void TCPsetServerTimer(TCP_HashTableElement Elm, int inlocalPort, int inREP) { if(Elm.Servertimer==null) *************** *** 466,470 **** System.out.println("Server Timer init!"); Elm.Servertimer=new Timer(); ! Elm.Servertimer.schedule(new TCPServerTask(Elm,inlocalPort,TCP_CONNECT_SERVER_TIME,this),TCP_CONNECT_SERVER_TIME,TCP_CONNECT_SERVER_TIME); } else { --- 469,473 ---- System.out.println("Server Timer init!"); Elm.Servertimer=new Timer(); ! Elm.Servertimer.schedule(new TCPServerTask(Elm,inlocalPort,TCP_CONNECT_SERVER_TIME,this, inREP),TCP_CONNECT_SERVER_TIME,TCP_CONNECT_SERVER_TIME); } else { *************** *** 473,477 **** Elm.Servertimer=null; Elm.Servertimer=new Timer(); ! Elm.Servertimer.schedule(new TCPServerTask(Elm,inlocalPort,TCP_SERVER_TIME,this),TCP_SERVER_TIME,TCP_SERVER_TIME); System.out.println(" Server Timer REinit DONE!"); } --- 476,480 ---- Elm.Servertimer=null; Elm.Servertimer=new Timer(); ! Elm.Servertimer.schedule(new TCPServerTask(Elm,inlocalPort,TCP_SERVER_TIME,this, inREP),TCP_SERVER_TIME,TCP_SERVER_TIME); System.out.println(" Server Timer REinit DONE!"); } *************** *** 482,486 **** public class TCPServerTask extends TimerTask { ! private int numRepeat=6; private int localPort; private TCP_HashTableElement Elm; --- 485,489 ---- public class TCPServerTask extends TimerTask { ! private int numRepeat; //6 when connecting, 60 when working private int localPort; private TCP_HashTableElement Elm; *************** *** 489,493 **** private Tcp TCPptr; ! public TCPServerTask (TCP_HashTableElement inElm, int inlocalPort, long time, Tcp inTCP) { this.Elm=inElm; --- 492,496 ---- private Tcp TCPptr; ! public TCPServerTask (TCP_HashTableElement inElm, int inlocalPort, long time, Tcp inTCP,int inREP) { this.Elm=inElm; *************** *** 496,499 **** --- 499,503 ---- this.application=inElm.application; this.TCPptr=inTCP; + this.numRepeat=inREP; } *************** *** 961,964 **** --- 965,970 ---- int s_num; int a_num; + int reps=50; + TCP_packet tosend_clone = new TCP_packet(inDestIPAddress,inSourceIPAddress,indestPort,insrcPort); TCP_packet tosend = new TCP_packet(inDestIPAddress,inSourceIPAddress,indestPort,insrcPort); *************** *** 1003,1006 **** --- 1009,1014 ---- if (!flags[1] || a_num<=1) Elm.SegmentsToResend.put(new Integer(s_num), tosend_clone); + if (flags[4]) reps=5; + 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 { *************** *** 1013,1017 **** if (flags[5]) Elm.isFIN_sent=true; ! TCPsetTimer(Elm); Elm=null; --- 1021,1025 ---- if (flags[5]) Elm.isFIN_sent=true; ! TCPsetTimer(Elm,reps); Elm=null; *************** *** 1183,1188 **** { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort()); ! } else TCPsetTimer(Elm); }catch(NullPointerException e){ System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1162 " + e.toString()); --- 1191,1196 ---- { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort(), 6); ! } else TCPsetTimer(Elm, 5); }catch(NullPointerException e){ System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1162 " + e.toString()); *************** *** 1249,1254 **** { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort()); ! } else TCPsetTimer(Elm); Elm.received_duplicates++; if (!inPacket.get_ACK_flag()) --- 1257,1262 ---- { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort(), 6); ! } else TCPsetTimer(Elm, 5); Elm.received_duplicates++; if (!inPacket.get_ACK_flag()) *************** *** 1294,1299 **** { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort()); ! } else TCPsetTimer(Elm); Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received --- 1302,1307 ---- { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort(), 60); ! } else TCPsetTimer(Elm, 50); Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received *************** *** 1412,1417 **** { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort()); ! } else TCPsetTimer(Elm); Elm.received_duplicates++; if (!inPacket.get_ACK_flag()) --- 1420,1425 ---- { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort(), 60); ! } else TCPsetTimer(Elm, 50); Elm.received_duplicates++; if (!inPacket.get_ACK_flag()) *************** *** 1455,1460 **** { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort()); ! } else TCPsetTimer(Elm); Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received --- 1463,1468 ---- { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort(),60); ! } else TCPsetTimer(Elm, 50); Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received *************** *** 1547,1552 **** { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort()); ! } else TCPsetTimer(Elm); Elm.received_duplicates++; if (!inPacket.get_ACK_flag()) --- 1555,1560 ---- { //init ServerTask ! TCPsetServerTimer(Elm,inPacket.get_destPort(), 60); ! } else TCPsetTimer(Elm, 50); Elm.received_duplicates++; if (!inPacket.get_ACK_flag()) |
From: Alexander B. <da...@us...> - 2006-02-24 15:41:48
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4814/core/protocolsuite/tcp_ip Modified Files: ARP.java Echo_tcp.java ProtocolStack.java Tcp.java Telnet_client.java Log Message: Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** ProtocolStack.java 24 Feb 2006 10:20:11 -0000 1.42 --- ProtocolStack.java 24 Feb 2006 15:41:44 -0000 1.43 *************** *** 870,874 **** TCP_packet temp = (TCP_packet)inPacket; try{ ! mTCPprotocol.receiveTCPPacket(temp); }catch(TransportLayerException te){} catch(NullPointerException e){ --- 870,874 ---- TCP_packet temp = (TCP_packet)inPacket; try{ ! mTCPprotocol.receiveTCPPacket(temp); }catch(TransportLayerException te){} catch(NullPointerException e){ *************** *** 1888,1893 **** { //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); --- 1888,1895 ---- { //let's get first interface IP address ! SourceIPAddress=getIPAddress(FirstInterfaceName); ! System.out.println("try to send..."); TCP_packet tosend = mTCPprotocol.sendTCPPacket(DestIPAddress,SourceIPAddress,destPort,srcPort,inTCPMessage,flags,acknow_num); + System.out.println("never be here..."); //and sending out ;) sendPacket(tosend); *************** *** 1897,1903 **** //throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); }catch(Exception e){ ! //try { ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); TCP_Info.setObjectName(getParentNodeName()); --- 1899,1905 ---- //throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); }catch(Exception e){ ! System.out.println("catch..."); //try { ! System.out.println("never be here..."); LayerInfo TCP_Info = new LayerInfo(getClass().getName()); TCP_Info.setObjectName(getParentNodeName()); Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Tcp.java 24 Feb 2006 12:18:33 -0000 1.40 --- Tcp.java 24 Feb 2006 15:41:44 -0000 1.41 *************** *** 315,320 **** * Used in timer */ ! private static final long TCP_SERVER_TIME = 250; //msec //server closing idle connection time ! private static final long TCP_SENDER_TIME = 1000; //msec time to resend all segments in SegmentsToresend queue /** --- 315,322 ---- * Used in timer */ ! private static final long TCP_SERVER_TIME = 10000; //msec //server closing idle connection time ! private static final long TCP_CONNECT_SERVER_TIME = 250; //msec //server closing idle connection time ! private static final long TCP_SENDER_TIME = 10000; //msec time to resend all segments in SegmentsToresend queue ! private static final long TCP_CONNECT_TIME = 200; //msec time to resend all segments in SegmentsToresend queue whn connecting /** *************** *** 349,353 **** System.out.println("Sender timer init!"); Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_SENDER_TIME,this),TCP_SENDER_TIME,TCP_SENDER_TIME); } else { --- 351,355 ---- System.out.println("Sender timer init!"); Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_CONNECT_TIME,this),TCP_CONNECT_TIME,TCP_CONNECT_TIME); } else { *************** *** 356,360 **** Elm.timer=null; Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_SENDER_TIME,this),TCP_SENDER_TIME,TCP_SENDER_TIME); System.out.println(" Sender Timer REinit DONE!"); } --- 358,362 ---- Elm.timer=null; Elm.timer=new Timer(); ! Elm.timer.schedule(new TCPTask(Elm,TCP_SENDER_TIME,this), TCP_SENDER_TIME, TCP_SENDER_TIME); System.out.println(" Sender Timer REinit DONE!"); } *************** *** 365,369 **** public class TCPTask extends TimerTask { ! private int numRepeat=30; private TCP_HashTableElement Elm; private long repTime; --- 367,371 ---- public class TCPTask extends TimerTask { ! private int numRepeat=5; private TCP_HashTableElement Elm; private long repTime; *************** *** 409,413 **** --- 411,417 ---- Elm.sent_duplicates++; + System.out.println("trying to send in timer"); mParentStack.sendPacket((TCP_packet)Elm.SegmentsToResend.get(curkey)); + System.out.println("never be here II."); } catch (Exception e) {System.out.println("Queue of segments to resend INNER ERROR: " + e.toString());} } *************** *** 443,447 **** } } ! }catch(NullPointerException e){ System.out.println(e.toString()); } } } --- 447,451 ---- } } ! }catch(Exception e){ System.out.println(e.toString()); } } } *************** *** 462,466 **** System.out.println("Server Timer init!"); Elm.Servertimer=new Timer(); ! Elm.Servertimer.schedule(new TCPServerTask(Elm,inlocalPort,TCP_SERVER_TIME,this),TCP_SERVER_TIME,TCP_SERVER_TIME); } else { --- 466,470 ---- System.out.println("Server Timer init!"); Elm.Servertimer=new Timer(); ! Elm.Servertimer.schedule(new TCPServerTask(Elm,inlocalPort,TCP_CONNECT_SERVER_TIME,this),TCP_CONNECT_SERVER_TIME,TCP_CONNECT_SERVER_TIME); } else { *************** *** 478,482 **** public class TCPServerTask extends TimerTask { ! private int numRepeat=34; private int localPort; private TCP_HashTableElement Elm; --- 482,486 ---- public class TCPServerTask extends TimerTask { ! private int numRepeat=6; private int localPort; private TCP_HashTableElement Elm; *************** *** 1056,1069 **** public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { ! System.out.println(mParentStack.getHostName() + ":" + " !!!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number()); //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) --- 1060,1071 ---- public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { ! System.out.println(mParentStack.getHostName() + ":" + " !!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number()); //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) *************** *** 1071,1088 **** //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 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 try{ if (inPacket.get_SYN_flag()) { --- 1073,1093 ---- //let's check all the things dealing with destination port number ! TCP_HashTableElement Elm = null; Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); ! System.out.println(Elm.PortStatus); switch(Elm.PortStatus) { case 0: //port is free => Error: no application to receive TCP ! //have to disconnect listener from port ! System.out.println(mParentStack.getHostName() + ":" + " !! 0 SEQ_numb==" + inPacket.get_sequence_number()); throw new TransportLayerPortException("TCP Error: no 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 + System.out.println(mParentStack.getHostName() + ":" + " !! 1 SEQ_numb==" + inPacket.get_sequence_number()); try{ + if (inPacket.get_SYN_flag()) { *************** *** 1146,1156 **** 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 segment //everything is OK //Check for SYN if (inPacket.get_SYN_flag()) ! { try{ /* --- 1151,1164 ---- case 2: //busy port, let's check whether it's busy by sender ;) + System.out.println(mParentStack.getHostName() + ":" + " !! 2 SEQ_numb==" + inPacket.get_sequence_number()); if ((Elm.connectedtoIP.equals(inPacket.getSourceIPAddress())) && (Elm.connectedtoPort==inPacket.get_srcPort())) { + System.out.println(mParentStack.getHostName() + ":" + " !! 3 SEQ_numb==" + inPacket.get_sequence_number()); //now we decompose TCP segment //everything is OK //Check for SYN if (inPacket.get_SYN_flag()) ! { ! System.out.println(mParentStack.getHostName() + ":" + " !! 4 SEQ_numb==" + inPacket.get_sequence_number()); try{ /* *************** *** 1170,1173 **** --- 1178,1182 ---- if (!(Elm.ReceivedSegments.contains(chk))) { + System.out.println(mParentStack.getHostName() + ":" + " !! 5 SEQ_numb==" + inPacket.get_sequence_number()); try{ if (Elm.isServer) *************** *** 1270,1273 **** --- 1279,1283 ---- //NOT SYN-segment //check for FIN + System.out.println(mParentStack.getHostName() + ":" + " !! 6 SEQ_numb==" + inPacket.get_sequence_number()); try{ if (inPacket.get_FIN_flag()) Index: Telnet_client.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_client.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Telnet_client.java 24 Feb 2006 10:20:11 -0000 1.3 --- Telnet_client.java 24 Feb 2006 15:41:44 -0000 1.4 *************** *** 230,233 **** --- 230,234 ---- SendData("\n"); + //SendData("!"); //terminal.recvData("Connected!\n"); //connected.... Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Echo_tcp.java 24 Feb 2006 10:20:11 -0000 1.21 --- Echo_tcp.java 24 Feb 2006 15:41:44 -0000 1.22 *************** *** 29,33 **** public class Echo_tcp extends Application{ ! private byte ConnectionAttempts=5; private int counts; --- 29,33 ---- public class Echo_tcp extends Application{ ! private byte ConnectionAttempts=1; private int counts; Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ARP.java 3 Dec 2005 19:23:19 -0000 1.6 --- ARP.java 24 Feb 2006 15:41:43 -0000 1.7 *************** *** 308,311 **** --- 308,313 ---- * @author robert_hulford + + * @author key * @param String - The IP address to search for in the ARP table |
From: Alexander B. <da...@us...> - 2006-02-24 15:41:47
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4814/core Modified Files: EthernetLink.java Log Message: Index: EthernetLink.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/EthernetLink.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** EthernetLink.java 8 Dec 2005 18:07:39 -0000 1.4 --- EthernetLink.java 24 Feb 2006 15:41:43 -0000 1.5 *************** *** 87,91 **** if (!temp.getSourceName().equals(inSourceName)) { ! if( (sievingCoefficient/100)>Math.random()) temp.receivePacket(inPacket); else throw new LowLinkException("Packet lost due to physical link problems!"); --- 87,91 ---- if (!temp.getSourceName().equals(inSourceName)) { ! if( ((sievingCoefficient+10)/100)>Math.random()) temp.receivePacket(inPacket); else throw new LowLinkException("Packet lost due to physical link problems!"); |
From: Alouette <alo...@us...> - 2006-02-24 13:06:12
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3656/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java OSPF_lsatypeone.java Log Message: Index: OSPF_lsatypeone.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_lsatypeone.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OSPF_lsatypeone.java 23 Feb 2006 20:12:41 -0000 1.3 --- OSPF_lsatypeone.java 24 Feb 2006 13:05:57 -0000 1.4 *************** *** 69,71 **** --- 69,83 ---- return LinkCount; } + public Vector Getlinkslist() + { + return linkslist; + } + public String GetRouterByNumber(int innumber) + { + return ((LinkDeclaration)linkslist.elementAt(innumber)).LinkID; + } + public int GetMetricByNumber(int innumber) + { + return ((LinkDeclaration)linkslist.elementAt(innumber)).TOS0metric; + } } Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** OSPF.java 24 Feb 2006 10:55:32 -0000 1.8 --- OSPF.java 24 Feb 2006 13:05:57 -0000 1.9 *************** *** 364,369 **** //DDSN++; //!!! tosend.setDestIPAddress(DesignatedRouter); ! // mParentStack.sendPacket(tosend); ! } --- 364,369 ---- //DDSN++; //!!! tosend.setDestIPAddress(DesignatedRouter); ! /*mParentStack.sendPacket(tosend);*/ ! } *************** *** 386,393 **** } ! public void ReceiveLinkStateUpdatePacket (OSPFlinkstateupdate_packet inPacket) { // forward ! if (inPacket.GetRouterID() != DesignatedRouter) { inPacket.SetRouterID(this.RouterID); --- 386,393 ---- } ! public void ReceiveLinkStateUpdatePacket (OSPFlinkstateupdate_packet inPacket, int PhaseMessage) { // forward ! if ((inPacket.GetRouterID() != DesignatedRouter) && (PhaseMessage==1)) { inPacket.SetRouterID(this.RouterID); *************** *** 399,402 **** --- 399,449 ---- } // operate packet + if ((inPacket.GetRouterID() == DesignatedRouter) && (PhaseMessage ==2)) + { + // forward this message to neighbors if + int i=0; + int flag=0; + while ((i<Graf.size()) && (flag==0)) + { + if (((RouterRecord)Graf.elementAt(i)).RouterID.equals(this.RouterID)) + { + //to all neighbors + RouterRecord tempRouterRecord = new RouterRecord(); + tempRouterRecord = ((RouterRecord)Graf.elementAt(i)); + int j=0; + for (j=0; j<tempRouterRecord.NeighborRouters.size(); j++) + { + if (!((RouterLink)tempRouterRecord.NeighborRouters.elementAt(j)).RouterID.equals(DesignatedRouter) ) + { + // send message to neighbor + //OSPFlinkstateupdate_packet tosend = ; + inPacket.setDestIPAddress(((RouterLink)tempRouterRecord.NeighborRouters.elementAt(j)).RouterID); + ((OSPF_lsaheader)inPacket.GetLsaHeaderlist().elementAt(1)).SetLSsequencenumber(DDSN++); //!!!!!!! + SendQueue.addElement(inPacket); + try + { + mParentStack.sendPacket(inPacket); + }catch (Exception e) {} + } + } + } + flag=1; + } + // update own graf + OSPF_lsatypeone templsatypeone = new OSPF_lsatypeone(0); + templsatypeone=(OSPF_lsatypeone)inPacket.GetLsaAdvertismentlist().elementAt(1); + int k=0; + for (k=0; k<templsatypeone.Getlinkslist().size(); k++) + { + // see every record and update + AddRouter(this.RouterID, templsatypeone.GetRouterByNumber(k), templsatypeone.GetMetricByNumber(k)); + } + + + + } + // send acknowledgement + // to ALL message even if they are error messages + SendLinkAcknowledgement(inPacket); } |
From: gift <gi...@us...> - 2006-02-24 12:18:43
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7963/core/protocolsuite/tcp_ip Modified Files: Tcp.java Log Message: mmm Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** Tcp.java 24 Feb 2006 11:29:06 -0000 1.39 --- Tcp.java 24 Feb 2006 12:18:33 -0000 1.40 *************** *** 1378,1382 **** { Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } } else { --- 1378,1386 ---- { Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } ! ! Application client; ! client=(Application)Elm.application; ! client.DisconnectEvent(); } else { *************** *** 1384,1387 **** --- 1388,1392 ---- serv=(Application)Elm.application; ClosePort(serv); //FIN sent and confirmed!!! Closing connection in case isPassive==true + serv.DisconnectEvent(); serv.Listen(); } |
From: gift <gi...@us...> - 2006-02-24 11:29:15
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10305/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.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** Tcp.java 24 Feb 2006 10:55:31 -0000 1.38 --- Tcp.java 24 Feb 2006 11:29:06 -0000 1.39 *************** *** 1243,1258 **** } else TCPsetTimer(Elm); Elm.received_duplicates++; ! Elm.sent_ACK++; ! //Elm.sent_segments++; ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! //System.out.println("%%% - in here"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); ! Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); } catch(NullPointerException e){ --- 1243,1261 ---- } else TCPsetTimer(Elm); Elm.received_duplicates++; ! if (!inPacket.get_ACK_flag()) ! { ! Elm.sent_ACK++; ! //Elm.sent_segments++; ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! //System.out.println("%%% - in here"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); ! Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); ! } } catch(NullPointerException e){ *************** *** 1397,1414 **** } else TCPsetTimer(Elm); Elm.received_duplicates++; ! Elm.sent_ACK++; ! //Elm.sent_segments++; ! //System.out.println("t+++++++++t"); ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! //System.out.println("%%% - in here - !!!"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); ! Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); ! } catch(NullPointerException e){ System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1368 " + e.toString()); --- 1400,1419 ---- } else TCPsetTimer(Elm); Elm.received_duplicates++; ! if (!inPacket.get_ACK_flag()) ! { ! Elm.sent_ACK++; ! //Elm.sent_segments++; ! //System.out.println("t+++++++++t"); ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! //System.out.println("%%% - in here - !!!"); ! TCP_Info.setLayer("Transport"); ! TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); ! Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); ! } } catch(NullPointerException e){ System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1368 " + e.toString()); *************** *** 1523,1527 **** } else { //we have already received this segment ! try{ if (Elm.isServer) { --- 1528,1532 ---- } else { //we have already received this segment ! if (Elm.isServer) { *************** *** 1529,1558 **** TCPsetServerTimer(Elm,inPacket.get_destPort()); } else TCPsetTimer(Elm); ! Elm.received_duplicates++; ! Elm.sent_ACK++; ! }catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 11 " + e.toString()); ! } ! ! //Elm.sent_segments++; ! //System.out.println("t------t"); ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! TCP_Info.setLayer("Transport"); ! //System.out.println("%%% - in here ^^^"); ! TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); ! Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! Integer ik = (Integer)inPacket.get_sequence_number(); ! ! TCP_packet Tpl = (TCP_packet) Elm.SentACKs.get(ik); ! ! System.out.println(mParentStack.getHostName() + ":" + "I=" + ik); ! if (Tpl==null) {System.out.println(mParentStack.getHostName() + ":" + "Error: PACKET = null when I=" + ik); } ! ! mParentStack.sendPacket(Tpl); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PARASITE PLACE*/ } } --- 1534,1562 ---- TCPsetServerTimer(Elm,inPacket.get_destPort()); } else TCPsetTimer(Elm); ! Elm.received_duplicates++; ! if (!inPacket.get_ACK_flag()) ! { ! Elm.sent_ACK++; ! //Elm.sent_segments++; ! //System.out.println("t------t"); ! //Create Layer info ! LayerInfo TCP_Info = new LayerInfo(getClass().getName()); ! TCP_Info.setObjectName(mParentStack.getParentNodeName()); ! TCP_Info.setDataType("TCP Protocol"); ! TCP_Info.setLayer("Transport"); ! //System.out.println("%%% - in here ^^^"); ! TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); ! Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! Integer ik = (Integer)inPacket.get_sequence_number(); ! ! TCP_packet Tpl = (TCP_packet) Elm.SentACKs.get(ik); ! ! System.out.println(mParentStack.getHostName() + ":" + "I=" + ik); ! if (Tpl==null) {System.out.println(mParentStack.getHostName() + ":" + "Error: PACKET = null when I=" + ik); } ! ! mParentStack.sendPacket(Tpl); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PARASITE PLACE*/ ! } } } |
From: gift <gi...@us...> - 2006-02-24 10:55:42
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24093/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java Log Message: ........ Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OSPF.java 24 Feb 2006 10:37:38 -0000 1.7 --- OSPF.java 24 Feb 2006 10:55:32 -0000 1.8 *************** *** 364,368 **** //DDSN++; //!!! tosend.setDestIPAddress(DesignatedRouter); ! mParentStack.sendPacket(tosend); } --- 364,368 ---- //DDSN++; //!!! tosend.setDestIPAddress(DesignatedRouter); ! // mParentStack.sendPacket(tosend); } |
From: gift <gi...@us...> - 2006-02-24 10:55:42
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24093/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.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** Tcp.java 24 Feb 2006 10:20:11 -0000 1.37 --- Tcp.java 24 Feb 2006 10:55:31 -0000 1.38 *************** *** 1125,1132 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: SYN-flags I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags EVERYTHING IS OK 1-st place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1125,1132 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "Server received first SYN: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags EVERYTHING IS OK 1-st place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " FIRST SYN DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1219,1226 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: SYN-flags with ACK must be I=1, I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags with ACK EVERYTHING IS OK 2-nd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1219,1226 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "CLIENT, ANSWER FOR SYN, I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags with ACK EVERYTHING IS OK 2-nd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " CLIENT, ANSWER FOR SYN DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1327,1334 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 3-rd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 3-rd place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1327,1334 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "FIN-packet FIN not sent, BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 3-rd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " FIN-packet FIN not sent, 3-rd place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1348,1355 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 4-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 4-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1348,1355 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "FIN-packet FIN sent, BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 4-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " FIN-packet FIN sent, 4-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1367,1374 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 5-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 5-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1367,1374 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + " FIN-receiver, BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 5-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " FIN-receiver, 5-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1493,1500 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 6-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1493,1500 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + " Data exchange mode, BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " Data exchange mode, 6-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) |
From: Alouette <alo...@us...> - 2006-02-24 10:37:46
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14051/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java OSPF_Acknowledgement.java Log Message: Index: OSPF_Acknowledgement.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_Acknowledgement.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPF_Acknowledgement.java 23 Feb 2006 20:12:41 -0000 1.1 --- OSPF_Acknowledgement.java 24 Feb 2006 10:37:38 -0000 1.2 *************** *** 36,39 **** } ! } --- 36,42 ---- } ! public int GetDDSNnumber() ! { ! return (int)lsaheader.GetLSsequencenumber(); ! } } Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OSPF.java 23 Feb 2006 20:12:41 -0000 1.6 --- OSPF.java 24 Feb 2006 10:37:38 -0000 1.7 *************** *** 42,45 **** --- 42,46 ---- // graf net private Vector Graf = new Vector (); + private Vector SendQueue = new Vector(); //************************************************************************ // the following class describes each element of the graf - router id and vector of neighbor routers *************** *** 436,439 **** --- 437,442 ---- tosend.AddLsaHeader(a); tosend.AddLsaAdv(b); + // push packet to array + SendQueue.addElement(tosend); try { *************** *** 443,450 **** } ! public void SendLinkAcknowledgement(OSPF_lsaheader inheader) { OSPF_Acknowledgement tosend = new OSPF_Acknowledgement(); ! tosend.Setlsaheader(inheader); try { --- 446,454 ---- } ! public void SendLinkAcknowledgement(OSPFlinkstateupdate_packet inPacket) { OSPF_Acknowledgement tosend = new OSPF_Acknowledgement(); ! tosend.setDestIPAddress(inPacket.GetRouterID()); ! tosend.Setlsaheader((OSPF_lsaheader)inPacket.GetLsaHeaderlist().elementAt(1)); try { *************** *** 452,455 **** --- 456,475 ---- }catch (Exception e) {} } + + public void ReceiveLinkAcknowledgement(OSPF_Acknowledgement inPacket) + { + // check if in array exist incoming packet + int i=0; + int flag = 0; + while ((i<SendQueue.size()) && (flag==0)) + { + if (((OSPF_lsaheader)SendQueue.elementAt(i)).GetLSsequencenumber() == inPacket.GetDDSNnumber()) + { + SendQueue.removeElementAt(i); + flag=1; + } + i++; + } + } /* *this method to receive link statereqiest |
From: Alexander B. <da...@us...> - 2006-02-24 10:20:24
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31924/core/protocolsuite/tcp_ip Modified Files: Application.java Echo.java Echo_tcp.java IP_packet.java IpV4.java ProtocolStack.java SNMP.java Tcp.java Telnet_client.java Telnet_server.java Log Message: Index: Telnet_client.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_client.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Telnet_client.java 23 Feb 2006 23:25:19 -0000 1.2 --- Telnet_client.java 24 Feb 2006 10:20:11 -0000 1.3 *************** *** 105,108 **** --- 105,116 ---- /** + * This method is called when client disconnected from server. + * @author key + * @version v0.01 + */ + + public void DisconnectEvent(){ } + + /** * This method disconnects from server. * @author key Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Telnet_server.java 23 Feb 2006 23:25:19 -0000 1.3 --- Telnet_server.java 24 Feb 2006 10:20:11 -0000 1.4 *************** *** 87,90 **** --- 87,98 ---- /** + * This method is called when client disconnected from server. + * @author key + * @version v0.01 + */ + + public void DisconnectEvent(){ } + + /** * This method disconnects from server. * @author key *************** *** 227,231 **** } else { ! outData = "<" + (ch<16?"0":"") + Integer.toHexString(ch) + ">"; } } --- 235,239 ---- } else { ! outData = "<" + ( ch < 16 ? "0" : "" ) + Integer.toHexString(ch) + ">"; } } Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** ProtocolStack.java 23 Feb 2006 19:36:33 -0000 1.41 --- ProtocolStack.java 24 Feb 2006 10:20:11 -0000 1.42 *************** *** 177,181 **** } ! /** --- 177,183 ---- } ! public String getHostName(){ ! return mParentNode.getName(); ! } /** *************** *** 207,224 **** String destMAC = null; ! // try{ ! try{ ! String outInterface[] = mIPprotocol.router(inPacket.getDestIPAddress()); ! } ! catch(NullPointerException e){ ! System.out.println("ProtocolStack.java: 216 " + e.toString()); ! } ! ! String outInterface[] = mIPprotocol.router(inPacket.getDestIPAddress()); if(outInterface[0] == null) { //Create layer info --- 209,228 ---- String destMAC = null; ! String GatewayAddress = null; ! ! String outInterface[] = new String[2]; try{ ! ! ! outInterface = mIPprotocol.router(inPacket.getDestIPAddress()); ! ! try{ ! if(outInterface[0] == null) { + + try{ //Create layer info *************** *** 241,244 **** --- 245,252 ---- Simulation.addLayerInfo(protocolInfo); + }catch(NullPointerException e){ + System.out.println("ProtocolStack.java: SendPacket 1 " + e.toString()); + } + } *************** *** 246,255 **** { ! String sourceIP = mIPprotocol.getIPAddress(outInterface[0]); inPacket.setSourceIPAddress(sourceIP); ! String GatewayAddress = null; // test if on local of remote network --- 254,265 ---- { ! ! try{ ! String sourceIP = mIPprotocol.getIPAddress(outInterface[0]); inPacket.setSourceIPAddress(sourceIP); ! // test if on local of remote network *************** *** 274,278 **** } ! if(destMAC == null){ //if there is no matching entry in arp throw an error --- 284,288 ---- } ! if(destMAC == null){ //if there is no matching entry in arp throw an error *************** *** 304,314 **** Simulation.addLayerInfo(protocolInfo); ! try{ ! NetworkLayerDevice temp = (NetworkLayerDevice)mParentNode; ! temp.sendPacket(destMAC, inPacket, outInterface[0]); if(inPacket instanceof ARP_packet){ packetARPCounter++; --- 314,327 ---- Simulation.addLayerInfo(protocolInfo); ! }catch(NullPointerException e){ ! System.out.println("ProtocolStack.java: SendPacket 1 " + e.toString()); ! } try{ ! try{ NetworkLayerDevice temp = (NetworkLayerDevice)mParentNode; ! temp.sendPacket(destMAC, inPacket, outInterface[0]); + if(inPacket instanceof ARP_packet){ packetARPCounter++; *************** *** 316,319 **** --- 329,335 ---- packetoutputIPCounter++; } + }catch(NullPointerException e){ + System.out.println("ProtocolStack.java: SendPacket NLD " + e.toString()); + } }catch(InvalidNetworkInterfaceNameException ex){ *************** *** 321,329 **** throw new CommunicationException("The Interface " + outInterface + "was unable to send the Packet."); ! } } ! --- 337,347 ---- throw new CommunicationException("The Interface " + outInterface + "was unable to send the Packet."); ! }catch(NullPointerException e){ System.out.println("ProtocolStack.java: SendPacket 11! " + e.toString()); ! } } ! }catch(NullPointerException e){ System.out.println("ProtocolStack.java: SendPacket 1!!! " + e.toString()); ! } *************** *** 335,340 **** }catch(InvalidIPAddressException e){ //UGLY!!! FIXME!!! System.out.println(e.toString()); } ! } --- 353,361 ---- }catch(InvalidIPAddressException e){ //UGLY!!! FIXME!!! System.out.println(e.toString()); + }catch(NullPointerException e){ + System.out.println("::" + inPacket + "::"); + System.out.println("ProtocolStack.java: SendPacket " + e.toString()); } ! } *************** *** 849,854 **** TCP_packet temp = (TCP_packet)inPacket; try{ ! mTCPprotocol.receiveTCPPacket(temp); }catch(TransportLayerException te){} catch (CommunicationException ce) {} catch(TransportLayerPortException tpe){ --- 870,878 ---- TCP_packet temp = (TCP_packet)inPacket; try{ ! mTCPprotocol.receiveTCPPacket(temp); }catch(TransportLayerException te){} + catch(NullPointerException e){ + System.out.println("ProtocolStack.java: " + e.toString()); + } catch (CommunicationException ce) {} catch(TransportLayerPortException tpe){ Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Tcp.java 23 Feb 2006 19:36:34 -0000 1.36 --- Tcp.java 24 Feb 2006 10:20:11 -0000 1.37 *************** *** 385,388 **** --- 385,389 ---- public void run() { + try{ // System.out.println("Timer start!"); if(!Elm.SegmentsToResend.isEmpty() && numRepeat>0) *************** *** 442,445 **** --- 443,447 ---- } } + }catch(NullPointerException e){ System.out.println(e.toString()); } } } *************** *** 1054,1060 **** public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { ! ! System.out.println(" !!!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number()); ! //test: check sum of TCP packet if (inPacket.getCheck_Sum() == 1) { --- 1056,1062 ---- public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { ! System.out.println(mParentStack.getHostName() + ":" + " !!!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number()); ! ! //test: check sum of TCP packet if (inPacket.getCheck_Sum() == 1) { *************** *** 1072,1075 **** --- 1074,1079 ---- Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); + + switch(Elm.PortStatus) { *************** *** 1080,1083 **** --- 1084,1088 ---- case 1: // port is being listened to by a new application. //Check for SYN + try{ if (inPacket.get_SYN_flag()) { *************** *** 1120,1127 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: SYN-flags I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags EVERYTHING IS OK 1-st place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1125,1132 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: SYN-flags I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags EVERYTHING IS OK 1-st place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1135,1138 **** --- 1140,1146 ---- } else { //not a SYN packet - have to wait until SYN packet will come } + }catch(NullPointerException e){ + System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 1 " + e.toString()); + } break; *************** *** 1145,1148 **** --- 1153,1157 ---- if (inPacket.get_SYN_flag()) { + try{ /* if (Elm.isServer) *************** *** 1168,1172 **** } else TCPsetTimer(Elm); }catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1162 " + e.toString()); } --- 1177,1181 ---- } else TCPsetTimer(Elm); }catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1162 " + e.toString()); } *************** *** 1210,1217 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: SYN-flags with ACK must be I=1, I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags with ACK EVERYTHING IS OK 2-nd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1219,1226 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: SYN-flags with ACK must be I=1, I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags with ACK EVERYTHING IS OK 2-nd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1248,1259 **** } catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1235 " + e.toString()); } } ! } else { //NOT SYN-segment //check for FIN if (inPacket.get_FIN_flag()) { --- 1257,1271 ---- } catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1235 " + e.toString()); } } ! }catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 6 " + e.toString()); ! } } else { //NOT SYN-segment //check for FIN + try{ if (inPacket.get_FIN_flag()) { *************** *** 1265,1268 **** --- 1277,1281 ---- { + if (Elm.isServer) { *************** *** 1314,1321 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 3-rd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 3-rd place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1327,1334 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 3-rd place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 3-rd place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1335,1342 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 4-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 4-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1348,1355 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 4-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 4-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1354,1361 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 5-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 5-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1367,1374 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 5-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 5-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1399,1403 **** } catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1368 " + e.toString()); } } --- 1412,1416 ---- } catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1368 " + e.toString()); } } *************** *** 1406,1412 **** } catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1375 " + e.toString()); } } else { // no FIN flag, no SYN flag --- 1419,1426 ---- } catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1375 " + e.toString()); } + } else { // no FIN flag, no SYN flag *************** *** 1416,1420 **** Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); if (!(Elm.ReceivedSegments.contains(chk))) ! { if (Elm.isServer) { --- 1430,1435 ---- Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); if (!(Elm.ReceivedSegments.contains(chk))) ! { ! if (Elm.isServer) { *************** *** 1478,1485 **** //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 6-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) --- 1493,1500 ---- //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println(mParentStack.getHostName() + ":" + "BEFORE: I=" + inPacket.get_sequence_number()); if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(mParentStack.getHostName() + ":" + " 6-th place DONE I=" + inPacket.get_sequence_number()); if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) *************** *** 1505,1510 **** --- 1520,1527 ---- listener.RecvData(inPacket.getTCP_message()); } + } else { //we have already received this segment + try{ if (Elm.isServer) { *************** *** 1514,1517 **** --- 1531,1538 ---- Elm.received_duplicates++; Elm.sent_ACK++; + }catch(NullPointerException e){ + System.out.println("TCP.java: case 2 - 11 " + e.toString()); + } + //Elm.sent_segments++; //System.out.println("t------t"); *************** *** 1523,1526 **** --- 1544,1548 ---- //System.out.println("%%% - in here ^^^"); TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); + Simulation.addLayerInfo(TCP_Info); //now we have to resend our ACK again *************** *** 1529,1534 **** TCP_packet Tpl = (TCP_packet) Elm.SentACKs.get(ik); ! System.out.println("I=" + ik); ! if (Tpl==null) {System.out.println("Error: PACKET = null when I=" + ik); } mParentStack.sendPacket(Tpl); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PARASITE PLACE*/ --- 1551,1556 ---- TCP_packet Tpl = (TCP_packet) Elm.SentACKs.get(ik); ! System.out.println(mParentStack.getHostName() + ":" + "I=" + ik); ! if (Tpl==null) {System.out.println(mParentStack.getHostName() + ":" + "Error: PACKET = null when I=" + ik); } mParentStack.sendPacket(Tpl); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PARASITE PLACE*/ *************** *** 1536,1555 **** } catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1492 " + e.toString()); } } } ! } 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()+"\"."); --- 1558,1581 ---- } catch(NullPointerException e){ ! System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 1492 " + e.toString()); } } + }catch(NullPointerException e){ + System.out.println(mParentStack.getHostName() + ":" + "TCP.java: case 2 - 7 " + e.toString()); } ! } ! } 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()+"\"."); *************** *** 1559,1562 **** --- 1585,1589 ---- throw new TransportLayerException("TCP Error: incorrect checksum on receiving!"); //comment this line if you have implemented check sum tests :) } + } Index: IP_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IP_packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IP_packet.java 17 Nov 2005 20:13:56 -0000 1.2 --- IP_packet.java 24 Feb 2006 10:20:11 -0000 1.3 *************** *** 220,226 **** { ! ! return mDestIPAddress; ! } --- 220,224 ---- { ! return mDestIPAddress; } Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Application.java 10 Jan 2006 16:23:01 -0000 1.15 --- Application.java 24 Feb 2006 10:20:11 -0000 1.16 *************** *** 76,79 **** --- 76,87 ---- /** + * This method is called when client disconnected from server. + * @author key + * @version v0.01 + */ + + public abstract void DisconnectEvent(); + + /** * This method sends data to the other side. * @param data to send Index: Echo_tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo_tcp.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Echo_tcp.java 1 Feb 2006 21:38:59 -0000 1.20 --- Echo_tcp.java 24 Feb 2006 10:20:11 -0000 1.21 *************** *** 135,139 **** } ! /** * This method sends data to the other side. --- 135,146 ---- } ! /** ! * This method is called when client disconnected from server. ! * @author key ! * @version v0.01 ! */ ! ! public void DisconnectEvent(){ } ! /** * This method sends data to the other side. Index: IpV4.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/IpV4.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IpV4.java 3 Dec 2005 12:20:52 -0000 1.6 --- IpV4.java 24 Feb 2006 10:20:11 -0000 1.7 *************** *** 159,162 **** --- 159,164 ---- String FLAG[] = {null,null}; + try{ + Enumeration keys = ipAddress.keys(); while(keys.hasMoreElements()){ *************** *** 189,192 **** --- 191,199 ---- } } + }catch(NullPointerException e){ + System.out.println("IPV4.java: route 1 " + e.toString()); + + } + return FLAG; } Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Echo.java 1 Feb 2006 21:38:59 -0000 1.18 --- Echo.java 24 Feb 2006 10:20:11 -0000 1.19 *************** *** 87,90 **** --- 87,98 ---- /** + * This method is called when client disconnected from server. + * @author key + * @version v0.01 + */ + + public void DisconnectEvent(){ } + + /** * This method disconnects from server. * @author key Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** SNMP.java 23 Feb 2006 23:25:19 -0000 1.10 --- SNMP.java 24 Feb 2006 10:20:11 -0000 1.11 *************** *** 176,179 **** --- 176,187 ---- /** + * This method is called when client disconnected from server. + * @author key + * @version v0.01 + */ + + public void DisconnectEvent(){ } + + /** * This method disconnects from server. * @author QweR |
From: Alexander B. <da...@us...> - 2006-02-24 10:20:22
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31924/core Modified Files: Hub.java Log Message: Index: Hub.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/Hub.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Hub.java 23 Feb 2006 11:56:00 -0000 1.4 --- Hub.java 24 Feb 2006 10:20:10 -0000 1.5 *************** *** 99,103 **** --- 99,108 ---- NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); if(!tempInterface.getName().equals(inInterfaceName)){ + + try{ tempInterface.sendPacket(copyPacket); + }catch(NullPointerException e){ + System.out.println("Hub.java: " + e.toString()); + } } *************** *** 110,113 **** --- 115,119 ---- }else{ sz=1; + System.out.println(th.toString()); throw new LowLinkException("Hub buffer overflow (packet loop flood?)."); } |
From: QweR <qw...@us...> - 2006-02-23 23:25:25
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23168/core/protocolsuite/tcp_ip Modified Files: SNMP.java Telnet_client.java Telnet_server.java Log Message: Index: Telnet_client.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_client.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Telnet_client.java 22 Feb 2006 18:57:43 -0000 1.1 --- Telnet_client.java 23 Feb 2006 23:25:19 -0000 1.2 *************** *** 176,179 **** --- 176,182 ---- Simulation.addLayerInfo(protInfo);*/ + if(Data.compareTo("\nQUIT")==0) { + Close(); + } terminal.recvData(Data); *************** *** 219,223 **** SendData("\n"); ! terminal.recvData("Connected!"); //connected.... --- 222,226 ---- SendData("\n"); ! //terminal.recvData("Connected!\n"); //connected.... Index: Telnet_server.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Telnet_server.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Telnet_server.java 22 Feb 2006 19:56:58 -0000 1.2 --- Telnet_server.java 23 Feb 2006 23:25:19 -0000 1.3 *************** *** 31,34 **** --- 31,41 ---- private byte ConnectionAttempts=5; private int counts; + private String cmdline=""; + private boolean isenter=true; + private boolean islogin=false; + private boolean ispass=false; + private String password = "123"; + private String login = "root"; + private String userlogin = ""; /** Creates a new instance of Telnet Server */ *************** *** 134,138 **** public void RecvData(String Data) throws LowLinkException, TransportLayerException { //processing the protocol doings. - //server processing recieve --- 141,144 ---- *************** *** 150,161 **** protInfo2.setDescription("Sending echo message '" + Data + "' to client."); Simulation.addLayerInfo(protInfo2); ! try { ! SendData(Data); ! }catch(Exception e){ ///*TODO*: here to catch } - - } --- 156,244 ---- protInfo2.setDescription("Sending echo message '" + Data + "' to client."); Simulation.addLayerInfo(protInfo2); ! ! String outData=""; ! if(isenter && Data.compareTo("\n")==0) { ! outData = "\nlogin: "; ! islogin = true; ! isenter = false; ! } ! else { ! int ch = (char)Data.charAt(0); ! switch(ch) { ! case 0x03: ! case 0x04: { ! outData = "\nQUIT"; ! break; ! } ! case 0x08: { ! outData="\b"; ! cmdline = cmdline.substring(0,cmdline.length()-1); ! break; ! } ! case 0xA: { ! if(islogin) { ! islogin = false; ! userlogin = cmdline; ! ispass = true; ! outData = "\npassword: "; ! } ! else if(ispass) { ! ispass = false; ! if(userlogin.compareTo(login)==0 && cmdline.compareTo(password)==0) { ! outData = "\nWelcome to " + mParentStack.getParentNodeName() + "\n"; ! } ! else { ! try { ! SendData("\nLogin or password is incorrect"); ! outData = "\nQUIT"; ! } ! catch(Exception e) { ! //************* ! } ! } ! } ! else { ! cmdline = removeSpaces(cmdline); ! outData = "\n" + runcmd(cmdline); ! } ! cmdline = ""; ! break; ! } ! // case 0x1B: outData="ESC"; break; ! case 0x20: { ! if(ispass) { ! outData="*"; ! } ! else { ! outData=" "; ! } ! break; ! } ! default: ! if(ch>=0x30 && ch<0x80) ! { ! if(ispass) { ! outData = "*"; ! } ! else { ! outData = String.valueOf(Data.charAt(0)); ! } ! cmdline+=String.valueOf(Data.charAt(0)); ! } ! else { ! outData = "<" + (ch<16?"0":"") + Integer.toHexString(ch) + ">"; ! } ! } ! } try { ! SendData(outData); ! if(outData.compareTo("\nQUIT")==0) { ! Close(); ! isenter = true; ! } ! } ! catch(Exception e){ ///*TODO*: here to catch } } *************** *** 183,186 **** --- 266,281 ---- } + private String runcmd(String cmd) { + if(cmd.compareToIgnoreCase("quit")==0) { + return "QUIT"; + } + return "bad command\n"; + } + + private String removeSpaces(String s) { + while(s.startsWith(" ")) s = s.substring(1); + while(s.endsWith(" ")) s = s.substring(0, s.length()-1); + return s; + } } Index: SNMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/SNMP.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SNMP.java 22 Feb 2006 20:04:27 -0000 1.9 --- SNMP.java 23 Feb 2006 23:25:19 -0000 1.10 *************** *** 54,59 **** public final static int SNMP_ERROR_noError = 0; public final static int SNMP_ERROR_noSuchName = 2; ! public final static int SNMP_ERROR_badValue = 3; // == SNMP_ERROR_wrongValue ??? public final static int SNMP_ERROR_readOnly = 4; public final static int SNMP_ERROR_genErr = 5; --- 54,60 ---- public final static int SNMP_ERROR_noError = 0; + public final static int SNMP_ERROR_tooBig = 1; public final static int SNMP_ERROR_noSuchName = 2; ! public final static int SNMP_ERROR_badValue = 3; public final static int SNMP_ERROR_readOnly = 4; public final static int SNMP_ERROR_genErr = 5; *************** *** 62,66 **** public final static int SNMP_ERROR_wrongLength = 8; public final static int SNMP_ERROR_wrongEncoding = 9; ! public final static int SNMP_ERROR_wrongValue = 10; // this constant maybe uses instead SNMP_ERROR_badValue public final static int SNMP_GET = 1; public final static int SNMP_GETNEXT = 2; --- 63,67 ---- public final static int SNMP_ERROR_wrongLength = 8; public final static int SNMP_ERROR_wrongEncoding = 9; ! public final static int SNMP_ERROR_wrongValue = 10; //unused public final static int SNMP_GET = 1; public final static int SNMP_GETNEXT = 2; *************** *** 488,492 **** */ public boolean getResponse(String Host, int port, Vector<String> r,Vector<String> v,int es,int ei) throws LowLinkException, TransportLayerException, CommunicationException, InvalidNetworkLayerDeviceException { ! String pack = createSNMPHeader(getNextID(),SNMP_RESPONSE); pack += createSNMPError(es,ei); String tmp = createSNMPVarsValues(r,v); --- 489,493 ---- */ public boolean getResponse(String Host, int port, Vector<String> r,Vector<String> v,int es,int ei) throws LowLinkException, TransportLayerException, CommunicationException, InvalidNetworkLayerDeviceException { ! String pack = createSNMPHeader(m_id,SNMP_RESPONSE); pack += createSNMPError(es,ei); String tmp = createSNMPVarsValues(r,v); *************** *** 1190,1198 **** if(var.compareToIgnoreCase("test.test_1")==0) { if(val.compareTo("B")==0 || val.compareTo("C")==0) return 0; ! else return SNMP_ERROR_wrongValue; } else if(var.compareToIgnoreCase("test.test_2")==0) { if(Integer.parseInt(val,10)>0 && Integer.parseInt(val,10)<99) return 0; ! else return SNMP_ERROR_wrongValue; } else if(var.compareToIgnoreCase("IP.DefaultGateway")==0) { --- 1191,1199 ---- if(var.compareToIgnoreCase("test.test_1")==0) { if(val.compareTo("B")==0 || val.compareTo("C")==0) return 0; ! else return SNMP_ERROR_badValue; } else if(var.compareToIgnoreCase("test.test_2")==0) { if(Integer.parseInt(val,10)>0 && Integer.parseInt(val,10)<99) return 0; ! else return SNMP_ERROR_badValue; } else if(var.compareToIgnoreCase("IP.DefaultGateway")==0) { *************** *** 1234,1238 **** } catch(Exception e) { ! System.out.print(e.toString()); } return 0; --- 1235,1240 ---- } catch(Exception e) { ! //System.out.print(e.toString()); ! return SNMP_ERROR_badValue; } return 0; |
From: QweR <qw...@us...> - 2006-02-23 23:25:25
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23168/guiUI Modified Files: MainScreen.java TelnetEmulator.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** MainScreen.java 23 Feb 2006 15:13:53 -0000 1.33 --- MainScreen.java 23 Feb 2006 23:25:19 -0000 1.34 *************** *** 3175,3210 **** public void TelnetConnect(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); ! ! if(port!=null && ip!=null){ ! ! try{ ! ! printNetworkStart(); ! ! //Timer timer = null; ! //timer=new Timer(); ! //timer.schedule(new TTask(this, 1),4000,4000); ! //=<150 ! //((Echo_tcp)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30021)).SendEcho(msg, ip, Integer.valueOf(port).intValue(), Integer.valueOf(cnt).intValue()); ! TelnetEmulator t = new TelnetEmulator(this, ((Telnet_client)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30023)),ip,Integer.valueOf(port).intValue()); ! t.pack(); ! t.setVisible(true); ! // ! //this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); ! ! }catch(Exception e){ ! ! addToConsole(e.toString()); ! ! } addHeader(); printLayerInfo(false); ! ! } ! } --- 3175,3202 ---- public void TelnetConnect(String inNodeName){ + String ip = JOptionPane.showInputDialog(this, "Server IP:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); + if(ip!=null){ + String port = JOptionPane.showInputDialog(this, "Server Port:", "Send msg over Echo.", JOptionPane.QUESTION_MESSAGE); + if(port!=null) { + try{ + printNetworkStart(); + //Timer timer = null; + //timer=new Timer(); + //timer.schedule(new TTask(this, 1),4000,4000); + //=<150 + //((Echo_tcp)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30021)).SendEcho(msg, ip, Integer.valueOf(port).intValue(), Integer.valueOf(cnt).intValue()); + TelnetEmulator t = new TelnetEmulator(this, ((Telnet_client)((core.ApplicationLayerDevice)Sim.getNode(inNodeName)).getApp(30023)),ip,Integer.valueOf(port).intValue()); + t.pack(); + t.setVisible(true); + // + //this.addToConsole("Trying to send echo message '" + msg + "' from " + inNodeName + " to " + ip + ":" + port + "\n"); ! }catch(Exception e){ ! addToConsole(e.toString()); ! } addHeader(); printLayerInfo(false); ! } ! } } Index: TelnetEmulator.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/TelnetEmulator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TelnetEmulator.java 23 Feb 2006 15:13:53 -0000 1.3 --- TelnetEmulator.java 23 Feb 2006 23:25:19 -0000 1.4 *************** *** 23,26 **** --- 23,28 ---- import javax.swing.JTextField; + import javax.swing.JTextArea; + import java.awt.Insets; *************** *** 71,74 **** --- 73,79 ---- import core.TransportLayerException; + import java.awt.Font; + import java.awt.event.KeyListener; + /** * *************** *** 78,83 **** private final Telnet_client telnet; private JPanel panel; ! private JLabel terminal; private String text; MainScreen parent; --- 83,90 ---- private final Telnet_client telnet; private JPanel panel; ! // private JLabel terminal; ! private JTextArea terminal; private String text; + private KeyListener kl; MainScreen parent; *************** *** 90,109 **** text = ""; ! text += "Opening " + Host + ":" + Port + "..."; ! ! terminal = new JLabel(text); panel = new JPanel(); ! this.addKeyListener( new KeyAdapter(){ ! public void keyTyped(KeyEvent e) { ! ! char c = e.getKeyChar(); ! ! String s = String.valueOf(c).toString(); ! sendData(s); ! printInfo(); ! } }); --- 97,130 ---- text = ""; + text += "Opening " + Host + ":" + Port + "...\n"; ! //terminal = new JLabel(text); ! terminal = new JTextArea(text); ! terminal.setBackground(new Color(0)); ! terminal.setForeground(Color.WHITE); ! terminal.setEnabled(false); ! terminal.setFont(new Font("Courier New", Font.PLAIN, 12)); panel = new JPanel(); ! this.addKeyListener( kl = new KeyAdapter(){ ! public void keyPressed(KeyEvent e) { ! char c = e.getKeyChar(); ! if((int)c<65535) { ! String s = String.valueOf(c).toString(); ! sendData(s); ! printInfo(); ! } ! } }); + + // public void keyTyped(KeyEvent e) { + // + // char c = e.getKeyChar(); + // + // String s = String.valueOf(c).toString(); + // sendData(s); + // printInfo(); + // } + // }); *************** *** 116,120 **** panel.setLayout(new java.awt.BorderLayout()); ! panel.setPreferredSize(new java.awt.Dimension(600,100)); this.setContentPane(panel); --- 137,141 ---- panel.setLayout(new java.awt.BorderLayout()); ! panel.setPreferredSize(new java.awt.Dimension(600,500)); this.setContentPane(panel); *************** *** 155,160 **** public void recvData(String Data){ ! text += Data; ! terminal.setText(text); } --- 176,188 ---- public void recvData(String Data){ ! if(Data.compareTo("\nQUIT")==0) { ! this.removeKeyListener(kl); ! terminal.setText(text + "\nServer closed connection."); ! } ! else { ! if(Data.compareTo("\b")==0) text = text.substring(0, text.length()-1); ! else text += Data; ! terminal.setText(text + "_"); ! } } *************** *** 171,173 **** --- 199,205 ---- //!!!!!: add more headers here } + + public void exitWindow(){ + this.dispose(); + } } |
From: Alouette <alo...@us...> - 2006-02-23 20:12:47
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4499/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java OSPF_lsatypeone.java Added Files: OSPF_Acknowledgement.java Log Message: --- NEW FILE: OSPF_Acknowledgement.java --- (This appears to be a binary file; contents omitted.) Index: OSPF_lsatypeone.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_lsatypeone.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** OSPF_lsatypeone.java 23 Feb 2006 16:52:54 -0000 1.2 --- OSPF_lsatypeone.java 23 Feb 2006 20:12:41 -0000 1.3 *************** *** 18,22 **** private int[] VEB; //three main bits in octet. private int LinkCount; ! --- 18,22 ---- private int[] VEB; //three main bits in octet. private int LinkCount; ! *************** *** 48,51 **** --- 48,52 ---- } LinkCount=Count; + } public void OSPFaddlink(String inlinkID, String inLinkData, int intype, int inTos0metric) Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OSPF.java 23 Feb 2006 18:56:24 -0000 1.5 --- OSPF.java 23 Feb 2006 20:12:41 -0000 1.6 *************** *** 397,400 **** --- 397,402 ---- }catch (Exception e) {} } + // operate packet + } *************** *** 440,443 **** --- 442,455 ---- } } + + public void SendLinkAcknowledgement(OSPF_lsaheader inheader) + { + OSPF_Acknowledgement tosend = new OSPF_Acknowledgement(); + tosend.Setlsaheader(inheader); + try + { + mParentStack.sendPacket(tosend); + }catch (Exception e) {} + } /* *this method to receive link statereqiest |
From: gift <gi...@us...> - 2006-02-23 19:36:43
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14020/core/protocolsuite/tcp_ip Modified Files: ProtocolStack.java Tcp.java Log Message: vvv... Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ProtocolStack.java 22 Feb 2006 14:05:19 -0000 1.40 --- ProtocolStack.java 23 Feb 2006 19:36:33 -0000 1.41 *************** *** 210,216 **** try{ ! String outInterface[] = mIPprotocol.router(inPacket.getDestIPAddress()); ! if(outInterface[0] == null) --- 210,221 ---- try{ ! try{ String outInterface[] = mIPprotocol.router(inPacket.getDestIPAddress()); ! } ! catch(NullPointerException e){ ! System.out.println("ProtocolStack.java: 216 " + e.toString()); ! } ! ! String outInterface[] = mIPprotocol.router(inPacket.getDestIPAddress()); if(outInterface[0] == null) Index: Tcp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Tcp.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** Tcp.java 23 Feb 2006 14:03:10 -0000 1.35 --- Tcp.java 23 Feb 2006 19:36:34 -0000 1.36 *************** *** 295,299 **** private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private int window_size=10; // private int total_received=0; // private int total_sent=0; --- 295,299 ---- private Hashtable PortTable = new Hashtable(); private ProtocolStack mParentStack; ! private int window_size=25; // private int total_received=0; // private int total_sent=0; *************** *** 393,413 **** Enumeration HTkeys; Integer curkey; ! HTkeys = Elm.SegmentsToResend.keys(); ! while (HTkeys.hasMoreElements()) ! { ! curkey= (Integer) HTkeys.nextElement(); ! try{ ! //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("Resending packet due to timer out: " + repTime + " msec has passed."); ! Simulation.addLayerInfo(TCP_Info); ! ! Elm.sent_duplicates++; ! mParentStack.sendPacket((TCP_packet)Elm.SegmentsToResend.get(curkey)); ! } catch (Exception e) {} ! } } else { --- 393,416 ---- Enumeration HTkeys; Integer curkey; ! try{ ! HTkeys = Elm.SegmentsToResend.keys(); ! while (HTkeys.hasMoreElements()) ! { ! curkey= (Integer) HTkeys.nextElement(); ! try{ ! //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("Resending packet due to timer out: " + repTime + " msec has passed."); ! Simulation.addLayerInfo(TCP_Info); ! ! Elm.sent_duplicates++; ! mParentStack.sendPacket((TCP_packet)Elm.SegmentsToResend.get(curkey)); ! } catch (Exception e) {System.out.println("Queue of segments to resend INNER ERROR: " + e.toString());} ! } ! ! } catch (Exception e) {System.out.println("Queue of segments to resend OUTER ERROR: " + e.toString());} } else { *************** *** 1051,1054 **** --- 1054,1059 ---- public void receiveTCPPacket(TCP_packet inPacket) throws TransportLayerPortException, TransportLayerException, LowLinkException, CommunicationException { + + System.out.println(" !!!!!!!!!!! SEQ_numb==" + inPacket.get_sequence_number()); //test: check sum of TCP packet if (inPacket.getCheck_Sum() == 1) *************** *** 1112,1121 **** boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ Application listener;int ack_num=1; ! listener = (Application)Elm.application; ! if (mParentStack.sendTCPSegment(listener,msg,flags,ack_num)) { ! //we have sent ACK for received segment => adding it to SentACKs ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(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 --- 1117,1132 ---- boolean flags[]={false,true,false,false,true,false}; /* URG, !ACK!, PSH, RST, !SYN!, FIN */ Application listener;int ack_num=1; ! listener = (Application)Elm.application; ! ! //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: SYN-flags I=" + inPacket.get_sequence_number()); ! if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags EVERYTHING IS OK 1-st place I==1"); ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" DONE I=" + inPacket.get_sequence_number()); ! ! if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) { ! Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet } else { //we have already received this segment *************** *** 1150,1154 **** if (!(Elm.ReceivedSegments.contains(chk))) { ! if (Elm.isServer) { --- 1161,1165 ---- if (!(Elm.ReceivedSegments.contains(chk))) { ! try{ if (Elm.isServer) { *************** *** 1156,1160 **** TCPsetServerTimer(Elm,inPacket.get_destPort()); } else TCPsetTimer(Elm); ! Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received --- 1167,1174 ---- TCPsetServerTimer(Elm,inPacket.get_destPort()); } else TCPsetTimer(Elm); ! }catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1162 " + e.toString()); ! } ! Elm.received_segments++; Elm.ReceivedSegments.addElement(chk); //adding seq_number that we have received *************** *** 1178,1184 **** 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); ! // if (Elm.SegmentsToResend.remove((Integer)our_ack-1)==null) {System.out.println("Error here");} //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) --- 1192,1202 ---- Simulation.addLayerInfo(TCP_Info); + try{ //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 (Elm.SegmentsToResend.remove((Integer)our_ack-1)==null) {System.out.println("Error here");} ! }catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1191 " + e.toString()); ! } //now we have to send last ACK-segment (with SYN=false, seq_num=1, ack_num=1) *************** *** 1189,1201 **** listener = (Application)Elm.application; ! if (mParentStack.sendTCPSegment(listener,msg,flags,ack_num)) { ! //we have sent ACK for received segment => adding it to SentACKs ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(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 //System.out.println("tttttttt"); if (Elm.isServer) { --- 1207,1231 ---- listener = (Application)Elm.application; ! try{ ! ! //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: SYN-flags with ACK must be I=1, I=" + inPacket.get_sequence_number()); ! if (inPacket.get_sequence_number() == 1) System.out.println("SYN-flags with ACK EVERYTHING IS OK 2-nd place I==1"); ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" DONE I=" + inPacket.get_sequence_number()); ! ! if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) { ! Elm.SentACKs.remove(inPacket.get_sequence_number()); } + + }catch(NullPointerException e){ + System.out.println("TCP.java: case 2 - 1208 " + e.toString()); + } //listener.RecvData(inPacket.getTCP_message()); we do not receive segment because this is a SYN-packet } else { //we have already received this segment //System.out.println("tttttttt"); + try{ if (Elm.isServer) { *************** *** 1216,1219 **** --- 1246,1253 ---- //now we have to resend our ACK again mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); + } + catch(NullPointerException e){ + System.out.println("TCP.java: case 2 - 1235 " + e.toString()); + } } *************** *** 1224,1232 **** if (inPacket.get_FIN_flag()) { //FIN flag! Last segment was received. //Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); Integer chk = (Integer)inPacket.get_sequence_number(); if (!(Elm.ReceivedSegments.contains(chk))) ! { if (Elm.isServer) { --- 1258,1268 ---- if (inPacket.get_FIN_flag()) { + try{ //FIN flag! Last segment was received. //Elm=(TCP_HashTableElement)PortTable.get(inPacket.get_destPort()); Integer chk = (Integer)inPacket.get_sequence_number(); if (!(Elm.ReceivedSegments.contains(chk))) ! { ! if (Elm.isServer) { *************** *** 1276,1284 **** listener = (Application)Elm.application; //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! if (mParentStack.sendTCPSegment(listener,msg,flags,ack_num)) ! { ! //we have sent ACK for received segment => adding it to SentACKs ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! } } else { --- 1312,1326 ---- listener = (Application)Elm.application; //Elm.isFIN_sent=true; - will be set in "sendTCPSegment" ! ! //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); ! if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 3-rd place I==1"); ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 3-rd place DONE I=" + inPacket.get_sequence_number()); ! ! if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) ! { ! Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } } else { *************** *** 1291,1299 **** Elm.isFIN_confirmed=true; int ack_num=chk+1; ! if (mParentStack.sendTCPSegment(listener,msg,flags,ack_num)) ! { ! //we have sent ACK for received segment => adding it to SentACKs ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! } } else { --- 1333,1347 ---- Elm.isFIN_confirmed=true; int ack_num=chk+1; ! ! //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); ! if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 4-th place I==1"); ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 4-th place DONE I=" + inPacket.get_sequence_number()); ! ! if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) ! { ! Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } } else { *************** *** 1304,1312 **** Application listener; listener = (Application)Elm.application; int ack_num=chk+1; ! if (mParentStack.sendTCPSegment(listener,msg,flags,ack_num)) ! { ! //we have sent ACK for received segment => adding it to SentACKs ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! } } else { --- 1352,1366 ---- Application listener; listener = (Application)Elm.application; int ack_num=chk+1; ! ! //we are going to send ACK for received segment => adding it to SentACKs ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); ! if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 5-th place I==1"); ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 5-th place DONE I=" + inPacket.get_sequence_number()); ! ! if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) ! { ! Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } } else { *************** *** 1320,1326 **** } ! } ! } else { //we have already received this segment if (Elm.isServer) { --- 1374,1381 ---- } ! } } else { //we have already received this segment + + try { if (Elm.isServer) { *************** *** 1342,1354 **** //now we have to resend our ACK again mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); } ! ! } else { // no FIN flag, no SYN flag //just normal mode. Have to check ACK flag, decompose, send acknowledgement ! Integer chk = (Integer)inPacket.get_sequence_number(); Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); --- 1397,1416 ---- //now we have to resend our ACK again mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); + } + catch(NullPointerException e){ + System.out.println("TCP.java: case 2 - 1368 " + e.toString()); + } } ! } ! catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1375 " + e.toString()); ! } ! } else { // no FIN flag, no SYN flag //just normal mode. Have to check ACK flag, decompose, send acknowledgement ! try{ Integer chk = (Integer)inPacket.get_sequence_number(); Integer our_ack = (Integer)inPacket.get_acknowledgment_number(); *************** *** 1414,1422 **** // if ((our_ack!=2 || Elm.sent_segments!=2) && Elm.PortStatus!=1) //{ ! if (mParentStack.sendTCPSegment(listener,msg,flags,ack_num)) ! { ! //we have sent ACK for received segment => adding it to SentACKs ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! } //} --- 1476,1490 ---- // if ((our_ack!=2 || Elm.sent_segments!=2) && Elm.PortStatus!=1) //{ ! //we are going to send ACK for received segment => adding it to SentACKs ! ! System.out.println("BEFORE: I=" + inPacket.get_sequence_number()); ! if (inPacket.get_sequence_number() == 1) System.out.println("EVERYTHING IS OK, ready 6-th place I==1"); ! Elm.SentACKs.put(new Integer(inPacket.get_sequence_number()), (TCP_packet) mParentStack.getTCPSegment_clone(listener,msg,flags,ack_num)); ! System.out.println(" 6-th place DONE I=" + inPacket.get_sequence_number()); ! ! if (!(mParentStack.sendTCPSegment(listener,msg,flags,ack_num))) ! { ! Elm.SentACKs.remove(inPacket.get_sequence_number()); ! } //} *************** *** 1456,1463 **** TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! mParentStack.sendPacket((TCP_packet) Elm.SentACKs.get((Integer)inPacket.get_sequence_number())); } ! } } --- 1524,1542 ---- TCP_Info.setDescription("Resending ACK packet due to duplicate arrival. Total duplicates received: " + Elm.received_duplicates + "."); Simulation.addLayerInfo(TCP_Info); ! //now we have to resend our ACK again ! Integer ik = (Integer)inPacket.get_sequence_number(); ! ! TCP_packet Tpl = (TCP_packet) Elm.SentACKs.get(ik); ! ! System.out.println("I=" + ik); ! if (Tpl==null) {System.out.println("Error: PACKET = null when I=" + ik); } ! ! mParentStack.sendPacket(Tpl); /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PARASITE PLACE*/ } ! } ! catch(NullPointerException e){ ! System.out.println("TCP.java: case 2 - 1492 " + e.toString()); ! } ! } } |
From: Alouette <alo...@us...> - 2006-02-23 18:56:33
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18278/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java Log Message: Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** OSPF.java 23 Feb 2006 16:52:53 -0000 1.4 --- OSPF.java 23 Feb 2006 18:56:24 -0000 1.5 *************** *** 387,391 **** public void ReceiveLinkStateUpdatePacket (OSPFlinkstateupdate_packet inPacket) { ! } --- 387,400 ---- public void ReceiveLinkStateUpdatePacket (OSPFlinkstateupdate_packet inPacket) { ! // forward ! if (inPacket.GetRouterID() != DesignatedRouter) ! { ! inPacket.SetRouterID(this.RouterID); ! inPacket.setDestIPAddress(DesignatedRouter); ! try ! { ! mParentStack.sendPacket(inPacket); ! }catch (Exception e) {} ! } } |
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2663/core/protocolsuite/tcp_ip/ospf Modified Files: OSPF.java OSPFDTBdescription_packet.java OSPF_lsaheader.java OSPF_lsatypeone.java OSPFlinkstateupdate_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.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** OSPFDTBdescription_packet.java 22 Feb 2006 14:05:53 -0000 1.5 --- OSPFDTBdescription_packet.java 23 Feb 2006 16:52:54 -0000 1.6 *************** *** 62,66 **** return DDSequenceNumber; } ! /*public String GetRouterID() { --- 62,69 ---- return DDSequenceNumber; } ! public void SetDDsequencenumber(int inDDsequencenumber) ! { ! DDSequenceNumber = inDDsequencenumber; ! } /*public String GetRouterID() { Index: OSPF_lsatypeone.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_lsatypeone.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPF_lsatypeone.java 10 Feb 2006 18:01:56 -0000 1.1 --- OSPF_lsatypeone.java 23 Feb 2006 16:52:54 -0000 1.2 *************** *** 39,43 **** /** Creates a new instance of OSPF_lsatypeone */ ! public OSPF_lsatypeone(int b, int v, int e, int Count) { VEB=new int[8]; --- 39,43 ---- /** Creates a new instance of OSPF_lsatypeone */ ! public OSPF_lsatypeone(int Count) { VEB=new int[8]; *************** *** 47,59 **** VEB[i]=0; } - VEB[0]=b; - VEB[1]=e; - VEB[2]=v; LinkCount=Count; } ! public void OSPFaddlink(String inlinID, String inLinkData, int intype, int inTos0metric) { LinkDeclaration t = new LinkDeclaration(); ! t.LinkID=inlinID; t.LinkData=inLinkData; t.Type=intype; --- 47,56 ---- VEB[i]=0; } LinkCount=Count; } ! public void OSPFaddlink(String inlinkID, String inLinkData, int intype, int inTos0metric) { LinkDeclaration t = new LinkDeclaration(); ! t.LinkID=inlinkID; t.LinkData=inLinkData; t.Type=intype; *************** *** 61,63 **** --- 58,70 ---- this.linkslist.addElement(t); } + + public void SetLinkCount(int incount) + { + LinkCount=incount; + } + + public int GetLinkCount () + { + return LinkCount; + } } Index: OSPFlinkstateupdate_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPFlinkstateupdate_packet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OSPFlinkstateupdate_packet.java 10 Feb 2006 18:01:56 -0000 1.1 --- OSPFlinkstateupdate_packet.java 23 Feb 2006 16:52:54 -0000 1.2 *************** *** 29,33 **** --- 29,53 ---- } + public Vector GetLsaHeaderlist() + { + return lsa_headers; + } + + public Vector GetLsaAdvertismentlist() + { + return lsa_advert; + } + + public void AddLsaHeader(OSPF_lsaheader inheader) + { + lsa_headers.addElement(inheader); + } + + public void AddLsaAdv(OSPF_lsatypeone inlsa) + { + lsa_advert.addElement(inlsa); + } + } Index: OSPF.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OSPF.java 22 Feb 2006 14:05:53 -0000 1.3 --- OSPF.java 23 Feb 2006 16:52:53 -0000 1.4 *************** *** 39,42 **** --- 39,43 ---- private String BackupDesignatedRouter; private int Priority; // Administrator task; + private static int DDSN = -32768; // sequence number // graf net private Vector Graf = new Vector (); *************** *** 55,58 **** --- 56,60 ---- public String RouterID; public int Metric; + public String AdvertisingRouter; public RouterLink() { } }// end *************** *** 216,220 **** // send hello packet AddRouter(inPacket.GetRouterID(), RouterID, 1); ! SendospfHelloPacket(inPacket.GetRouterID()); } --- 218,222 ---- // send hello packet AddRouter(inPacket.GetRouterID(), RouterID, 1); ! SendospfHelloPacket(inPacket.GetRouterID(), ""); } *************** *** 233,238 **** //SendHelloPacket(); ! SendospfHelloPacket(inPacket.GetRouterID()); } } } --- 235,249 ---- //SendHelloPacket(); ! SendospfHelloPacket(inPacket.GetRouterID(), ""); ! } ! } ! else ! { ! if (inPacket.GetPriority()>Priority) ! { ! BackupDesignatedRouter = DesignatedRouter; ! DesignatedRouter = inPacket.GetRouterID(); } + } } *************** *** 243,251 **** *method to send hello packet */ ! public /*OSPFhello_packet*/ void SendospfHelloPacket(String inDestIPAddress) { OSPFhello_packet tosend = new OSPFhello_packet(); tosend.Setpriority(Priority); tosend.SetRouterID(RouterID); int i; for (i=1; i<=Graf.size(); i++) --- 254,263 ---- *method to send hello packet */ ! public /*OSPFhello_packet*/ void SendospfHelloPacket(String inDestIPAddress, String inDesignatedRouter) { OSPFhello_packet tosend = new OSPFhello_packet(); tosend.Setpriority(Priority); tosend.SetRouterID(RouterID); + tosend.SetDesignatedRouter(inDesignatedRouter); int i; for (i=1; i<=Graf.size(); i++) *************** *** 317,321 **** * */ ! public OSPFDTBdescription_packet SendDescriptionPacket(int a, int b, int c, int num, int islist) { OSPFDTBdescription_packet tosend = new OSPFDTBdescription_packet(a,b,c, num); --- 329,333 ---- * */ ! public void SendDescriptionPacket(int a, int b, int c, int num, int islist) { OSPFDTBdescription_packet tosend = new OSPFDTBdescription_packet(a,b,c, num); *************** *** 323,330 **** if (islist>0) // need to send full packet so need to copy all lsa headers { ! //copy all list ! // need to copy from router to the packet } ! return tosend; } --- 335,368 ---- if (islist>0) // need to send full packet so need to copy all lsa headers { ! // find line in graf there are all neighbors of current router ! int flag=0; ! int i=0; ! int j=0; ! while ((flag==0) && (i<Graf.size())) ! { ! if (((RouterRecord)Graf.elementAt(i)).RouterID.equals(RouterID)) ! { ! flag=1; ! } ! } ! if (flag==1) ! { ! // cycle ! for (j=0; j<((RouterRecord)Graf.elementAt(i)).NeighborRouters.size(); j++) ! { ! // create lsa header to each neighbor of router ! OSPF_lsaheader t =new OSPF_lsaheader(); ! tosend.OSPFAddHeader(t); /*!!!*/ ! ! ! } ! } } ! // send packet to designated router ! tosend.SetDDsequencenumber(DDSN); ! //DDSN++; //!!! ! tosend.setDestIPAddress(DesignatedRouter); ! mParentStack.sendPacket(tosend); ! } *************** *** 352,358 **** } ! public OSPFlinkstateupdate_packet SendLinkStateUpdatePacket() { ! return null; } /* --- 390,433 ---- } ! public void SendLinkStateUpdatePacket() { ! if (DesignatedRouter != "") ! { ! OSPFlinkstateupdate_packet tosend = new OSPFlinkstateupdate_packet(); ! tosend.setDestIPAddress(DesignatedRouter); ! // find line of current router neighbors ! int i=0; ! int j=0; ! int flag=0; ! while ((flag==0) && (i<Graf.size())) ! { ! if (((RouterRecord)Graf.elementAt(i)).RouterID == RouterID) ! { ! flag=1; ! } ! i++; ! } ! // create lsa header ! OSPF_lsaheader a = new OSPF_lsaheader(); ! // create lsa message ! OSPF_lsatypeone b = new OSPF_lsatypeone(((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.size()); ! a.SetLStype(1); ! a.SetLSID(DesignatedRouter); ! a.SetLSsequencenumber(DDSN); ! DDSN++; ! for (j=0; j<((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.size(); j++) ! { ! // full all link declaration ! String tempRouterId = ((RouterLink)((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.elementAt(j)).RouterID; ! int tempmetric = ((RouterLink)((RouterRecord)Graf.elementAt(i-1)).NeighborRouters.elementAt(j)).Metric; ! b.OSPFaddlink(tempRouterId, tempRouterId, 1, tempmetric); ! } ! tosend.AddLsaHeader(a); ! tosend.AddLsaAdv(b); ! try ! { ! mParentStack.sendPacket(tosend); ! }catch (Exception e) {} ! } } /* Index: OSPF_lsaheader.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ospf/OSPF_lsaheader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OSPF_lsaheader.java 22 Feb 2006 14:05:53 -0000 1.3 --- OSPF_lsaheader.java 23 Feb 2006 16:52:54 -0000 1.4 *************** *** 86,90 **** *v1.0 */ ! public int SetLStype() { return LS_type; --- 86,90 ---- *v1.0 */ ! public int GetLStype() { return LS_type; |
From: Alexander B. <da...@us...> - 2006-02-23 15:14:09
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8697/guiUI Modified Files: MainScreen.java TelnetEmulator.java Log Message: Index: MainScreen.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/MainScreen.java,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** MainScreen.java 22 Feb 2006 20:04:27 -0000 1.32 --- MainScreen.java 23 Feb 2006 15:13:53 -0000 1.33 *************** *** 1052,1056 **** public void printLayerInfo(boolean header){ ! pnlConsole.append("\n"); Vector vecRecordedInfo = Sim.getRecordedInfo(); --- 1052,1056 ---- public void printLayerInfo(boolean header){ ! if(header) pnlConsole.append("\n"); Vector vecRecordedInfo = Sim.getRecordedInfo(); *************** *** 1893,1897 **** System.out.println("testitng code open"); ! chooser.setDialogTitle("Open File ..."); --- 1893,1897 ---- System.out.println("testitng code open"); ! printLayerInfo(false); chooser.setDialogTitle("Open File ..."); Index: TelnetEmulator.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/TelnetEmulator.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TelnetEmulator.java 23 Feb 2006 14:46:59 -0000 1.2 --- TelnetEmulator.java 23 Feb 2006 15:13:53 -0000 1.3 *************** *** 103,106 **** --- 103,107 ---- String s = String.valueOf(c).toString(); sendData(s); + printInfo(); } }); |
From: Alexander B. <da...@us...> - 2006-02-23 14:47:05
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25704/guiUI Modified Files: TelnetEmulator.java Log Message: Index: TelnetEmulator.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/TelnetEmulator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TelnetEmulator.java 22 Feb 2006 17:42:34 -0000 1.1 --- TelnetEmulator.java 23 Feb 2006 14:46:59 -0000 1.2 *************** *** 97,102 **** this.addKeyListener( new KeyAdapter(){ ! public void keyPressed(KeyEvent e) { ! char c = (char)e.getKeyCode(); String s = String.valueOf(c).toString(); sendData(s); --- 97,104 ---- this.addKeyListener( new KeyAdapter(){ ! public void keyTyped(KeyEvent e) { ! ! char c = e.getKeyChar(); ! String s = String.valueOf(c).toString(); sendData(s); |