Thread: [Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip ICMP.java, 1.7, 1.8 ProtocolStack.java, 1.68,
Status: Beta
Brought to you by:
darkkey
|
From: QweR <qw...@us...> - 2008-10-03 22:29:28
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29998/core/protocolsuite/tcp_ip Modified Files: ICMP.java ProtocolStack.java Log Message: ICMP unreacheable in ping correct sh run toString for DeviceConfig Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** ProtocolStack.java 28 Sep 2008 17:11:47 -0000 1.68 --- ProtocolStack.java 3 Oct 2008 22:29:10 -0000 1.69 *************** *** 654,658 **** * @throws CommunicationException * ! * @return ICMP message ID * * @version v0.20 --- 654,658 ---- * @throws CommunicationException * ! * @return ICMP packet * * @version v0.20 *************** *** 660,687 **** */ ! public int sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException { ! int result = -1; if (IPV4Address.validateDecIP(inDestIPAddress)) { ! ICMP_packet pingPacket = mICMPprotocol.sendPing(inDestIPAddress); ! result = pingPacket.getMessageID(); sendPacket(pingPacket); } else throw new CommunicationException("Packet dropped host unreachable " + inDestIPAddress); ! return result; } /** ! * This method returns receive time of ICMP packet with messageID. * * @author QweR * @param messageID - * ICMP packet message ID ! * @return receive time of ICMP packet or zero if packet was not received * @version v0.21 */ ! public long getTimeICMPPacketReceived(int messageID) { ! return mICMPprotocol.getTimeICMPPacketReceived(messageID); } --- 660,699 ---- */ ! public ICMP_packet sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException { ! ICMP_packet pingPacket = null; if (IPV4Address.validateDecIP(inDestIPAddress)) { ! pingPacket = mICMPprotocol.sendPing(inDestIPAddress); sendPacket(pingPacket); } else throw new CommunicationException("Packet dropped host unreachable " + inDestIPAddress); ! return pingPacket; } /** ! * This method returns received ICMP packet with messageID. * * @author QweR * @param messageID - * ICMP packet message ID ! * @return received ICMP packet or null if packet was not received * @version v0.21 */ ! public ICMP_packet getReceivedICMPPacket(int messageID) { ! return mICMPprotocol.getReceivedICMPPacket(messageID); ! } ! ! /** ! * This method remove and returns received ICMP packet with messageID. ! * ! * @author QweR ! * @param messageID - ! * ICMP packet message ID ! * @return received ICMP packet or null if packet was not received ! * @version v0.21 ! */ ! public ICMP_packet removeReceivedICMPPacket(int messageID) { ! return mICMPprotocol.removeReceivedICMPPacket(messageID); } *************** *** 896,899 **** --- 908,913 ---- .getSourceIPAddress()); pingPacket.setMessageCode(ICMP_packet.TIME_EXCEEDED); + if(ipPacket instanceof ICMP_packet) + pingPacket.setMessageID(((ICMP_packet)ipPacket).getMessageID()); Simulation.addLayerInfo(getClass().getName(), Index: ICMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ICMP.java 3 Oct 2008 14:49:55 -0000 1.7 --- ICMP.java 3 Oct 2008 22:29:10 -0000 1.8 *************** *** 61,66 **** private ProtocolStack mParentStack; ! private Hashtable<Integer, Long> receivedMessageID; // Message ID and ! // received time of // received packets. --- 61,65 ---- private ProtocolStack mParentStack; ! private Hashtable<Integer, ICMP_packet> receivedPackets; // Message ID and // received packets. *************** *** 86,90 **** mParentStack = inParentStack; ! receivedMessageID = new Hashtable<Integer, Long>(); } --- 85,89 ---- mParentStack = inParentStack; ! receivedPackets = new Hashtable<Integer, ICMP_packet>(); } *************** *** 119,124 **** }else if (inPacket.getMessageCode() == 0) { ! receivedMessageID.put(inPacket.getMessageID(), System ! .currentTimeMillis()); // Create Layer info --- 118,122 ---- }else if (inPacket.getMessageCode() == 0) { ! receivedPackets.put(inPacket.getMessageID(), inPacket); // Create Layer info *************** *** 138,141 **** --- 136,140 ---- }else if (inPacket.getMessageCode() == ICMP_packet.DESTINATION_UNREACHABLE){ + receivedPackets.put(inPacket.getMessageID(), inPacket); Simulation.addLayerInfo(getClass().getName(), mParentStack.getParentNodeName(), "ICMP Dst Unreach", "Network", *************** *** 143,146 **** --- 142,146 ---- + inPacket.getSourceIPAddress()); }else if (inPacket.getMessageCode() == ICMP_packet.TIME_EXCEEDED){ + receivedPackets.put(inPacket.getMessageID(), inPacket); Simulation.addLayerInfo(getClass().getName(), mParentStack.getParentNodeName(), "ICMP Time Exceeded", "Network", *************** *** 164,168 **** * * @param inPacket - ! * The original packet recived by this Node * * @exception CommunicationException --- 164,168 ---- * * @param inPacket - ! * The original packet received by this Node * * @exception CommunicationException *************** *** 269,276 **** } ! public long getTimeICMPPacketReceived(int messageID) { ! if (receivedMessageID.containsKey(messageID)) ! return receivedMessageID.get(messageID); ! return 0; } --- 269,282 ---- } ! public ICMP_packet getReceivedICMPPacket(int messageID) { ! if (receivedPackets.containsKey(messageID)) ! return receivedPackets.get(messageID); ! return null; ! } ! ! public ICMP_packet removeReceivedICMPPacket(int messageID) { ! if (receivedPackets.containsKey(messageID)) ! return receivedPackets.remove(messageID); ! return null; } |