[Javanetsim-cvs] javaNetSim/core/protocolsuite/tcp_ip ARP.java,1.3,1.4 Application.java,1.7,1.8 Echo
Status: Beta
Brought to you by:
darkkey
From: Alexander B. <da...@us...> - 2005-11-19 21:53:58
|
Update of /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5833/core/protocolsuite/tcp_ip Modified Files: ARP.java Application.java Echo.java ICMP.java ProtocolStack.java Udp.java Log Message: Index: Udp.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Udp.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Udp.java 19 Nov 2005 20:13:07 -0000 1.6 --- Udp.java 19 Nov 2005 21:53:51 -0000 1.7 *************** *** 182,186 **** */ ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { --- 182,186 ---- */ ! public void receiveUDPPacket(UDP_packet inPacket) throws TransportLayerException, LowLinkException { *************** *** 297,301 **** */ ! public UDP_packet sendUDPPacket(Object application,String inDestIPAddress,String inFirstInterfaceName, int indestPort, String inMessage) throws TransportLayerException { int srcPort; --- 297,301 ---- */ ! public UDP_packet sendUDPPacket(Object application,String inDestIPAddress,String inFirstInterfaceName, int indestPort, String inMessage) throws TransportLayerException, LowLinkException { int srcPort; *************** *** 327,331 **** Simulation.addLayerInfo(UDP_Info); ! return tosend; } --- 327,332 ---- Simulation.addLayerInfo(UDP_Info); ! return tosend; ! } *************** *** 538,543 **** UDP_HashTableElement Elm = new UDP_HashTableElement(); ! if ( (Elm = (UDP_HashTableElement)PortTable.get(inPort)) !=null ) ! { switch(Elm.PortStatus) { --- 539,546 ---- UDP_HashTableElement Elm = new UDP_HashTableElement(); ! ! if ( (UDP_HashTableElement)PortTable.get(inPort) !=null ) ! { ! Elm = (UDP_HashTableElement)PortTable.get(inPort); switch(Elm.PortStatus) { Index: ProtocolStack.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ProtocolStack.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ProtocolStack.java 19 Nov 2005 20:13:07 -0000 1.7 --- ProtocolStack.java 19 Nov 2005 21:53:51 -0000 1.8 *************** *** 191,195 **** */ ! public void sendPacket(IP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = null; --- 191,195 ---- */ ! public void sendPacket(IP_packet inPacket) throws LowLinkException, CommunicationException{ String destMAC = null; *************** *** 289,299 **** }catch(LowLinkException ex){ throw new LowLinkException(ex.toString()); - - - }catch(CommunicationException ex){ - throw ex; - } --- 289,294 ---- *************** *** 324,328 **** */ ! public void forwardPacket(IP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = null; --- 319,323 ---- */ ! public void forwardPacket(IP_packet inPacket) throws CommunicationException, LowLinkException{ String destMAC = null; *************** *** 416,420 **** */ ! public void broadcastPacket(IP_packet inPacket, String interfaceName) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destMAC = "FF:FF:FF:FF:FF:FF"; --- 411,415 ---- */ ! public void broadcastPacket(IP_packet inPacket, String interfaceName) throws CommunicationException, LowLinkException{ String destMAC = "FF:FF:FF:FF:FF:FF"; *************** *** 530,534 **** */ ! public void sendPing(String inDestIPAddress) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { if(IPV4Address.validateDecIP(inDestIPAddress)){ --- 525,529 ---- */ ! public void sendPing(String inDestIPAddress) throws CommunicationException, LowLinkException { if(IPV4Address.validateDecIP(inDestIPAddress)){ *************** *** 686,690 **** */ ! public void receivePacket(Packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ --- 681,685 ---- */ ! public void receivePacket(Packet inPacket) throws LowLinkException{ *************** *** 740,746 **** if (ipPacket instanceof ICMP_packet){ ! ICMP_packet temp = (ICMP_packet)inPacket; ! mICMPprotocol.receiveICMPPacket(temp); }else if(ipPacket instanceof ARP_packet){ --- 735,741 ---- if (ipPacket instanceof ICMP_packet){ ! ICMP_packet temp = (ICMP_packet)inPacket; ! mICMPprotocol.receiveICMPPacket(temp); }else if(ipPacket instanceof ARP_packet){ *************** *** 754,758 **** UDP_packet temp = (UDP_packet)inPacket; ! mUDPprotocol.receiveUDPPacket(temp); }else{ --- 749,757 ---- UDP_packet temp = (UDP_packet)inPacket; ! try{ ! mUDPprotocol.receiveUDPPacket(temp); ! }catch(TransportLayerException e){ ! //here *TODO*: insert catcher here ! } }else{ *************** *** 1308,1312 **** */ ! public void sendUDP(Object application, String inUDPMessage) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { --- 1307,1311 ---- */ ! public void sendUDP(Object application, String inUDPMessage) throws LowLinkException, CommunicationException { *************** *** 1318,1325 **** Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); - - DestIPAddress=mUDPprotocol.getApplicationDestIP(application); - destPort=mUDPprotocol.getApplicationDestPortNumber(application); if (FirstInterfaceName!=null) { --- 1317,1325 ---- Node temp = (Node)mParentNode; FirstInterfaceName = temp.getFirstInterfaceName(); + try{ + DestIPAddress=mUDPprotocol.getApplicationDestIP(application); + destPort=mUDPprotocol.getApplicationDestPortNumber(application); + if (FirstInterfaceName!=null) { *************** *** 1330,1336 **** }else throw new CommunicationException("Packet dropped host unreachable: " + DestIPAddress); ! } else ! throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! } --- 1330,1338 ---- }else throw new CommunicationException("Packet dropped host unreachable: " + DestIPAddress); ! } //else ! //throw new InvalidNetworkLayerDeviceException("Network interface unavailable on host \"" + temp.getName() +"\"."); ! }catch(Exception e){ ! //*TODO*: here we shall put some layerinfo for TransportException ! } } Index: ARP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ARP.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ARP.java 19 Nov 2005 20:13:07 -0000 1.3 --- ARP.java 19 Nov 2005 21:53:51 -0000 1.4 *************** *** 75,82 **** import core.LayerInfo; - import core.TransportLayerException; - - import core.InvalidNetworkLayerDeviceException; - --- 75,78 ---- *************** *** 321,325 **** */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { --- 317,321 ---- */ ! public String getMACAddress(String IPAddress, String inInterfaceKey) throws LowLinkException { *************** *** 429,433 **** ! public void receiveARPPacket(ARP_packet inARPpacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ // test if this packet is for a local Address. --- 425,429 ---- ! public void receiveARPPacket(ARP_packet inARPpacket) throws LowLinkException{ // test if this packet is for a local Address. Index: Application.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Application.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Application.java 19 Nov 2005 20:13:07 -0000 1.7 --- Application.java 19 Nov 2005 21:53:51 -0000 1.8 *************** *** 19,23 **** * @author key */ ! public class Application { protected String protocolName; --- 19,23 ---- * @author key */ ! public abstract class Application { protected String protocolName; *************** *** 32,40 **** --- 32,44 ---- protected int UID; /** Creates a new instance of ApplicationProtocol */ + public Application(ProtocolStack inParentStack, int listenPort, int appType, int UID){ this.listenPort = listenPort; this.mParentStack = inParentStack; + this.appType = appType; + this.UID = UID; } + /** * This method start to listen on application port *************** *** 42,48 **** * @version v0.01 */ ! public void Listen() throws TransportLayerException{ ! //throw new TransportLayerException("Cannot bind port " + listenPort + "."); ! } /** --- 46,50 ---- * @version v0.01 */ ! public abstract void Listen() throws TransportLayerException; /** *************** *** 53,57 **** * @version v0.01 */ ! public void Close() throws TransportLayerException{} /** --- 55,59 ---- * @version v0.01 */ ! public abstract void Close() throws TransportLayerException; /** *************** *** 63,67 **** */ ! public void Connect(String Host, int port) throws TransportLayerException {} /** --- 65,69 ---- */ ! public abstract void ClientConnect(String Host, int port) throws TransportLayerException, InvalidNetworkLayerDeviceException; /** *************** *** 71,75 **** */ ! public void Disconnect()throws TransportLayerException{} /** --- 73,77 ---- */ ! public abstract void Disconnect()throws TransportLayerException; /** *************** *** 80,84 **** */ ! public void SendData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException {} /** --- 82,86 ---- */ ! public abstract void SendData(String Data) throws LowLinkException, TransportLayerException, CommunicationException; /** *************** *** 88,93 **** * @version v0.01 */ ! public void RecvData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException {} public void setPort(int port){ this.listenPort = port; --- 90,96 ---- * @version v0.01 */ ! public abstract void RecvData(String Data) throws LowLinkException, TransportLayerException; + public void setPort(int port){ this.listenPort = port; Index: ICMP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/ICMP.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ICMP.java 19 Nov 2005 20:13:07 -0000 1.3 --- ICMP.java 19 Nov 2005 21:53:51 -0000 1.4 *************** *** 73,82 **** import core.Simulation; - import core.TransportLayerException; - - import core.InvalidNetworkLayerDeviceException; - - - --- 73,76 ---- *************** *** 149,153 **** */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException { --- 143,147 ---- */ ! public void receiveICMPPacket(ICMP_packet inPacket) throws LowLinkException { *************** *** 201,205 **** */ ! private void echoRequest(ICMP_packet inPacket) throws TransportLayerException, CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException{ String destIPAddress = inPacket.getSourceIPAddress(); --- 195,199 ---- */ ! private void echoRequest(ICMP_packet inPacket) throws LowLinkException{ String destIPAddress = inPacket.getSourceIPAddress(); *************** *** 239,243 **** //TODO Once the recording of a sim process is implemented this should record the error. ! }//catch(LowLinkException e){ //This exception is caught but not acted upon as the --- 233,238 ---- //TODO Once the recording of a sim process is implemented this should record the error. ! } ! //catch(LowLinkException e){ //This exception is caught but not acted upon as the Index: Echo.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/protocolsuite/tcp_ip/Echo.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Echo.java 19 Nov 2005 20:13:07 -0000 1.6 --- Echo.java 19 Nov 2005 21:53:51 -0000 1.7 *************** *** 25,29 **** /** Creates a new instance of Echo */ public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); } --- 25,29 ---- /** Creates a new instance of Echo */ public Echo(ProtocolStack inParentStack, int listenPort, int appType, int UID) { ! super(inParentStack, listenPort, appType, UID); } *************** *** 92,98 **** */ ! public void SendData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { ! mParentStack.sendUDP(this, Data); //processing the protocol doings. } --- 92,100 ---- */ ! public void SendData(String Data) throws LowLinkException, TransportLayerException, CommunicationException { ! ! mParentStack.sendUDP(this, Data); ! //processing the protocol doings. } *************** *** 106,110 **** * @version v0.01 */ ! public void RecvData(String Data) throws CommunicationException, LowLinkException, InvalidNetworkLayerDeviceException, TransportLayerException { //processing the protocol doings. if(appType == 0){ --- 108,112 ---- * @version v0.01 */ ! public void RecvData(String Data) throws LowLinkException, TransportLayerException { //processing the protocol doings. if(appType == 0){ *************** *** 114,120 **** --- 116,126 ---- }else{ //server processing recieve + try{ SendData(Data); Close(); Listen(); + }catch(Exception e){ + ///*TODO*: here to catch + } } } *************** *** 132,134 **** --- 138,142 ---- SendData(Data); } + + } |