[Javanetsim-cvs] javaNetSim/core WiFiPort.java, 1.8, 1.9 WirelessAP.java, 1.4, 1.5
Status: Beta
Brought to you by:
darkkey
|
From: Alexander B. <da...@us...> - 2008-10-05 20:20:38
|
Update of /cvsroot/javanetsim/javaNetSim/core In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv29460/core Modified Files: WiFiPort.java WirelessAP.java Log Message: Index: WirelessAP.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WirelessAP.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** WirelessAP.java 5 Oct 2008 13:03:47 -0000 1.4 --- WirelessAP.java 5 Oct 2008 20:20:32 -0000 1.5 *************** *** 93,105 **** super.turnOn(); ! ifacesUP(); } public void turnOff() { super.turnOff(); - ifacesDOWN(); - } public String getCache(){ --- 93,106 ---- super.turnOn(); ! //ifacesUP(); } public void turnOff() { + + ifacesDOWN(); + super.turnOff(); } public String getCache(){ Index: WiFiPort.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/core/WiFiPort.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** WiFiPort.java 5 Oct 2008 18:41:06 -0000 1.8 --- WiFiPort.java 5 Oct 2008 20:20:32 -0000 1.9 *************** *** 57,60 **** --- 57,61 ---- protected int state; protected String apBSSID; + protected boolean lineFree; // AP block *************** *** 87,90 **** --- 88,93 ---- failed = false; //channel = 0; + + lineFree=false; } *************** *** 96,99 **** --- 99,104 ---- state = PROBE; + lineFree=false; + sendProbeReq(); } *************** *** 104,112 **** void sendWirelessConfirmPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! sendWirelessPacket(inWP); } --- 109,127 ---- void sendWirelessConfirmPacket(W80211_packet inWP, long resendTime) throws LowLinkException{ + boolean canSend = true; + ResendPacket p = new ResendPacket(inWP, resendTime); ResendPackets.put(p.packet.getID(), p); ! if(Mode == MODE_STATION && inWP.Type == 2){ ! canSend = checkLineFree(); ! if(!canSend) ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", ! "Link", "Can't resend packet: no CTS -> medium is busy?Resending packet from interface " + name + " due to timeout."); ! } ! ! if(canSend) ! sendWirelessPacket(inWP); } *************** *** 118,122 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, "FF:FF:FF:FF:FF:FF", 0, 4, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending probe req packet from interface "+ name); --- 133,137 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, "FF:FF:FF:FF:FF:FF", 0, 4, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending probe req packet from interface "+ name); *************** *** 127,131 **** 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); --- 142,146 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 5, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending probe reply packet to " + inBSSID + " from interface "+ name); *************** *** 136,140 **** 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); --- 151,155 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 11, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending auth req packet from interface "+ name); *************** *** 145,149 **** W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 0, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending assoc req packet from interface "+ name); --- 160,164 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 0, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending assoc req packet from interface "+ name); *************** *** 156,160 **** 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); --- 171,175 ---- W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 0, 1, SSID); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Management Packet", "Link", "Sending assoc reply packet from interface "+ name); *************** *** 167,175 **** tempWiFi.setID(seq); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", "Link", "Sending ack packet from interface "+ name); sendWirelessPacket(tempWiFi); } public void Timer(int temp){ --- 182,223 ---- tempWiFi.setID(seq); ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", "Link", "Sending ack packet from interface "+ name); sendWirelessPacket(tempWiFi); } + + void sendCTS(String inBSSID) throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, inBSSID, 1, 12, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Sending CTS packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + + void sendRTS() throws LowLinkException{ + W80211_packet tempWiFi = new W80211_packet(null, BSSID, apBSSID, 1, 11, SSID); + + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Sending RTS packet from interface "+ name); + + sendWirelessPacket(tempWiFi); + } + + boolean checkLineFree() throws LowLinkException{ + boolean actlineFree = false; + + sendRTS(); + + try{ + Thread.sleep(100); + }catch(Exception e){ } + + actlineFree = lineFree; + lineFree = false; + + return actlineFree; + } public void Timer(int temp){ *************** *** 188,197 **** p.nextTime = System.currentTimeMillis() + p.period; ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Resending packet from interface " + name + " due to timeout."); ! try{ ! sendWirelessPacket(p.packet); }catch(LowLinkException ex){ } --- 236,257 ---- p.nextTime = System.currentTimeMillis() + p.period; ! boolean canSend = true; ! try{ ! if(Mode == MODE_STATION && p.packet.Type == 2){ ! canSend = checkLineFree(); ! ! if(!canSend) ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Data Packet", ! "Link", "Can't resend packet: no CTS -> medium is busy?Resending packet from interface " + name + " due to timeout."); ! } ! ! if(canSend){ ! ! Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Packet", ! "Link", "Resending packet from interface " + name + " due to timeout."); + sendWirelessPacket(p.packet); + } }catch(LowLinkException ex){ } *************** *** 325,329 **** if(Mode == MODE_STATION){ try{ ! associate(); }catch(Exception e){} } --- 385,389 ---- if(Mode == MODE_STATION){ try{ ! associate(); }catch(Exception e){} } *************** *** 440,445 **** "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); associated = true; } - }else if(Mode == MODE_AP){ --- 500,508 ---- "Link", "Associated at AP " + apBSSID + "/" + SSID + "."); associated = true; + }else if(state == DATA && tempWiFi.Type == 1 && tempWiFi.subType == 12){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Recieved CTS packet from " + tempWiFi.getSrcBSSID() + " on interface "+ name + "."); + lineFree=true; } }else if(Mode == MODE_AP){ *************** *** 471,474 **** --- 534,546 ---- } + }else if(tempWiFi.Type == 1 && tempWiFi.subType == 11){ + if(APClients.get(tempWiFi.getSrcBSSID()) != null){ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control Packet", + "Link", "Recieved RTS packet from " + tempWiFi.getSrcBSSID() + " on interface "+ name + "."); + sendCTS(tempWiFi.getSrcBSSID()); + }else{ + Simulation.addLayerInfo(getClass().getName(), parentNode.getName(), "802.11 Control packet", "Link", "Wrong 802.11 protocol action!"); + } + } |