Thread: [Javanetsim-cvs] javaNetSim/core W80211_packet.java, 1.2, 1.3 WiFiPort.java, 1.6, 1.7 WirelessAP.ja
Status: Beta
Brought to you by:
darkkey
|
From: Alexander B. <da...@us...> - 2008-10-05 13:08:16
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10499/core Modified Files: W80211_packet.java WiFiPort.java WirelessAP.java Log Message: Index: WirelessAP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WirelessAP.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** WirelessAP.java 28 Sep 2008 17:11:47 -0000 1.3 --- WirelessAP.java 5 Oct 2008 13:03:47 -0000 1.4 *************** *** 170,174 **** // if it is skip that interface NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); ! if(!tempInterface.getName().contains("eth")){ try{ --- 170,174 ---- // if it is skip that interface NetworkInterface tempInterface = (NetworkInterface)it.nextElement(); ! if(!(tempInterface.getName().equals(inInterfaceName) && !inInterfaceName.contains("wrl"))){ try{ *************** *** 177,181 **** System.out.println("WirelessAP.java: " + e.toString()); } ! } } --- 177,181 ---- System.out.println("WirelessAP.java: " + e.toString()); } ! } } Index: W80211_packet.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/W80211_packet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** W80211_packet.java 3 Oct 2008 14:49:54 -0000 1.2 --- W80211_packet.java 5 Oct 2008 13:03:47 -0000 1.3 *************** *** 20,23 **** --- 20,27 ---- } + public void setID(Long nID){ + pID = nID; + } + public void Cypher(String inWEP, int inkeyNum){ WEP = inWEP; *************** *** 25,29 **** } ! public W80211_packet(Packet inPacket, String inDst, String inSrc, int inType, int inSubType, String inSSID) { dstBSSID = inDst; --- 29,33 ---- } ! public W80211_packet(Packet inPacket, String inSrc, String inDst, int inType, int inSubType, String inSSID) { dstBSSID = inDst; Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** WiFiPort.java 3 Oct 2008 14:49:54 -0000 1.6 --- WiFiPort.java 5 Oct 2008 13:03:47 -0000 1.7 *************** *** 93,111 **** associated = false; ! Mode = PROBE; sendProbeReq(); } ! void sendWirelessPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! Simulation.Sim.sendWirelessPacket(this, inWP, channel); } ! void sendWirelessPacket(W80211_packet inWP) throws LowLinkException{ ! sendWirelessPacket(inWP, 100); } --- 93,115 ---- associated = false; ! state = PROBE; sendProbeReq(); } ! void sendWirelessPacket(W80211_packet inWP) throws LowLinkException{ ! Simulation.Sim.sendWirelessPacket(this, inWP, channel); ! } ! ! void sendWirelessConfirmPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! sendWirelessPacket(inWP); } ! void sendWirelessConfirmPacket(W80211_packet inWP) throws LowLinkException{ ! sendWirelessConfirmPacket(inWP, 100); } *************** *** 116,127 **** "Link", "Sending probe req packet from interface "+ name); ! sendWirelessPacket(tempWiFi, 5000); } ! void sendProbeReply(String inBSSID) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 4, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending probe reply packet from interface "+ name); sendWirelessPacket(tempWiFi); --- 120,131 ---- "Link", "Sending probe req packet from interface "+ name); ! sendWirelessConfirmPacket(tempWiFi, 5000); } ! void sendProbeReply(String inBSSID, Long seq) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 5, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending probe reply packet to " + inBSSID + " from interface "+ name); sendWirelessPacket(tempWiFi); *************** *** 129,138 **** void sendAuthReq(String inBSSID) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 4, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending auth req packet from interface "+ name); ! sendWirelessPacket(tempWiFi); } --- 133,142 ---- void sendAuthReq(String inBSSID) throws LowLinkException{ ! W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending auth req packet from interface "+ name); ! sendWirelessConfirmPacket(tempWiFi); } *************** *** 143,146 **** --- 147,172 ---- "Link", "Sending assoc req packet from interface "+ name); + sendWirelessConfirmPacket(tempWiFi); + } + + + + void sendAssocReply(String inBSSID, Long seq) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 1, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", + "Link", "Sending assoc reply packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + + void sendACK(String inBSSID, Long seq) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 1, 13, SSID); + + tempWiFi.setID(seq); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", + "Link", "Sending ack packet from interface "+ name); + sendWirelessPacket(tempWiFi); } *************** *** 170,174 **** public void setBSSID(String bssid) { ! BSSID = bssid; } --- 196,201 ---- public void setBSSID(String bssid) { ! if(Mode != MODE_STATION) ! BSSID = bssid; } *************** *** 214,219 **** this.MACAddress = macAddress; } ! // if(BSSID==null || BSSID.equals("")) ! // this.BSSID = this.MACAddress; } --- 241,246 ---- this.MACAddress = macAddress; } ! if(Mode == MODE_STATION) ! this.BSSID = this.MACAddress; } *************** *** 259,270 **** protected void receiveDataPacket( W80211_packet tempWiFi) throws LowLinkException { ! if((tempWiFi.getDstBSSID() != BSSID && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF") || tempWiFi.SSID!=SSID || tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); ! ! return; ! } ! ! if(tempWiFi.SSID!=SSID || tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet: Wrong 802.11 protocol params."); return; --- 286,293 ---- protected void receiveDataPacket( W80211_packet tempWiFi) throws LowLinkException { ! //&& ! ! if(tempWiFi.WEP != WEP_keys[tempWiFi.keyNum] ){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet: Wrong WEP params."); return; *************** *** 295,298 **** --- 318,323 ---- } } + + sendACK(tempWiFi.getDstBSSID(), tempWiFi.getID()); if(allowReceive) *************** *** 302,306 **** //Packet is not for the Interface Drop Packet and record something in //the Layerinfo object ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "Ethernet Packet", "Link", "Recieved and dropped packet at interface " + MACAddress); } --- 327,331 ---- //Packet is not for the Interface Drop Packet and record something in //the Layerinfo object ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "Ethernet Packet", "Link", "Recieved and dropped packet at interface " + MACAddress); } *************** *** 309,366 **** protected void receivePacket(Packet inPacket) throws LowLinkException { if(!parentNode.On) return; ! ! W80211_packet tempWiFi = (W80211_packet) inPacket; if(tempWiFi.Type == 2 && tempWiFi.subType == 0){ ! receiveDataPacket(tempWiFi); }else{ if(Mode == MODE_STATION){ ! if(tempWiFi.getDstBSSID() != BSSID || tempWiFi.SSID != SSID){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); ! ! return; } ! if(state == PROBE && tempWiFi.Type == 0 && tempWiFi.Type == 5){ ResendPackets.remove(tempWiFi.getID()); apBSSID = tempWiFi.getSrcBSSID(); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); state = ASSOC; sendAssocReq(apBSSID); ! }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.Type == 1){ ResendPackets.remove(tempWiFi.getID()); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Recieved assoc reply from " + apBSSID + " on interface "+ name + ". Association successfull."); state = DATA; associated = true; } }else if(Mode == MODE_AP){ - if((tempWiFi.getDstBSSID() != BSSID && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF") || tempWiFi.SSID != SSID){ - Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); - - return; - } ! if(tempWiFi.Type == 0 && tempWiFi.Type == 4){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Recieved probe req from " + tempWiFi.getSrcBSSID() + " on interface "+ name); if(APClients.get(tempWiFi.getSrcBSSID()) != null){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Connection state with " + tempWiFi.getSrcBSSID() + " cleared."); APClients.remove(tempWiFi.getSrcBSSID()); } ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending probe reply to " + tempWiFi.getSrcBSSID() + " on interface "+ name); ! APClients.put(tempWiFi.getSrcBSSID() , new APClient(tempWiFi.getSrcBSSID())); ! sendProbeReply(tempWiFi.getSrcBSSID()); } --- 334,413 ---- protected void receivePacket(Packet inPacket) throws LowLinkException { if(!parentNode.On) return; ! W80211_packet tempWiFi = (W80211_packet) inPacket; + if((tempWiFi.getDstBSSID() != BSSID || tempWiFi.SSID != SSID) && tempWiFi.getDstBSSID()!="FF:FF:FF:FF:FF:FF"){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); + + return; + } + if(tempWiFi.Type == 2 && tempWiFi.subType == 0){ ! receiveDataPacket(tempWiFi); ! }else if(tempWiFi.Type == 1 && tempWiFi.subType == 13){ ! ! ResendPackets.remove(tempWiFi.getID()); + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Recieved ack from " + tempWiFi.getSrcBSSID() + " on interface "+ name); + }else{ if(Mode == MODE_STATION){ ! ! if(tempWiFi.getDstBSSID() == "FF:FF:FF:FF:FF:FF"){ Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Recieved and discarded packet at interface " + name); ! ! return; } ! if(state == PROBE && tempWiFi.Type == 0 && tempWiFi.subType == 5){ ResendPackets.remove(tempWiFi.getID()); apBSSID = tempWiFi.getSrcBSSID(); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved probe reply from " + apBSSID + " on interface "+ name); state = ASSOC; + ResendPackets.remove(tempWiFi.getID()); sendAssocReq(apBSSID); ! }else if(state == ASSOC && tempWiFi.Type == 0 && tempWiFi.subType == 1){ ResendPackets.remove(tempWiFi.getID()); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved assoc reply from " + apBSSID + " on interface "+ name + ". Association successfull."); state = DATA; + ResendPackets.remove(tempWiFi.getID()); + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", + "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); associated = true; } }else if(Mode == MODE_AP){ ! if(tempWiFi.Type == 0 && tempWiFi.subType == 4){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Recieved probe req from " + tempWiFi.getSrcBSSID() + " on interface "+ name); if(APClients.get(tempWiFi.getSrcBSSID()) != null){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11", "Link", "Connection state with " + tempWiFi.getSrcBSSID() + " cleared."); APClients.remove(tempWiFi.getSrcBSSID()); } ! APClients.put(tempWiFi.getSrcBSSID() , new APClient(tempWiFi.getSrcBSSID())); ! sendProbeReply(tempWiFi.getSrcBSSID(), tempWiFi.getID()); ! }else if(tempWiFi.Type == 0 && tempWiFi.subType == 0){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", ! "Link", "Recieved assoc req from " + tempWiFi.getSrcBSSID() + " on interface "+ name); ! ! if(APClients.get(tempWiFi.getSrcBSSID()) != null){ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11", ! "Link", "Station " + tempWiFi.getSrcBSSID() + " associated."); ! ! APClients.get(tempWiFi.getSrcBSSID()).state = DATA; ! sendAssocReply(tempWiFi.getSrcBSSID(), tempWiFi.getID()); ! }else{ ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 packet", "Link", "Wrong 802.11 protocol action!"); ! } ! } *************** *** 378,381 **** --- 425,439 ---- if(Mode == MODE_AP){ + Ethernet_packet tempPacket = (Ethernet_packet)outPacket; + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "Ethernet Packet", + "Link", "Sending packet from interface "+ MACAddress); + + W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, tempPacket.getDestinationMACAddress(), 2, 0, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", + "Link", "Sending packet from interface "+ name); + + sendWirelessConfirmPacket(tempWiFi, 200); }else if(Mode == MODE_STATION){ *************** *** 403,412 **** "Link", "Sending packet from interface "+ MACAddress); ! //W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, "FF:FF:FF:FF:FF:FF"); ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Sending packet from interface "+ name); ! //Simulation.Sim.sendWirelessPacket(this, tempWiFi, channel); } --- 461,470 ---- "Link", "Sending packet from interface "+ MACAddress); ! W80211_packet tempWiFi = new W80211_packet(tempPacket, BSSID, apBSSID, 2, 0, SSID); ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", ! "Link", "Sending packet from interface " + name + " to " + tempWiFi.getDstBSSID()); ! sendWirelessConfirmPacket(tempWiFi, 200); } |