First I want to appologise to moderators for the double thread but seeing that nobody answered on the "script help" topic I'm trying my luck with a few quick questions, which in some part overlaps with the scipt, please do not delete. Thank you.
But just to be clear, your other posts was way to vague for me to see what you actually wanted. It is far more easier for me to answer some clear questions like you do in this topic, than investigate a complete script trying to find out what exactly you need and what might be done better.
1. What is the normal/best way of configuring the rt73 card at boot (at boot, after modprobe rt73usb, the interface is DOWN)
a. iwconfig wlan0 essid "myessid"; ifconfig wlan0 up (first iwconfig then bring the interface up)
b. ifconfig wlan0 up; iwconfig wlan0 essid "myessid" (first bring the interface up)
Doesn't matter, both are fine.
2 notes about iwconfig
- Setting the 'ap' (bssid) value should only be done while the interface is up. (it is possible to set it while interface is down though).
- Setting the 'mode' (managed, infra, monitor...) can only be done while the interface is down
2. If I want to scan for the network first I must bring the interface up (ifconfig wlan0 up) after that what is the normal/best way to configure it
a. iwconfig wlan0 essid "myessid" (with the interface still up)
b. ifconfig wlan0 down; iwconfig wlan0 essid "myessid"; ifconfig wlan0 up
The easy way. Just keep the interface up when you want to switch essid.
However and this is _very_ important an association will not start until you set 'iwconfig wlan0 ap ...' for each association attempt you must set the ap.
3. If I for some reason lose physical connectivity (go to far from ap) while connected (interface up, iwconfig shows connected), how do I reconnect to the network
a. do nothing, the driver will reconnect automaticlly
b. just iwconfig wlan0 essid "myessid", keep the interface up and dhcpcd running
c. ifconfig wlan0 down; killall dhcpcd; rm -f dhcpcd_files; iwconfig wlan0 essid "myessid"; ifconfig wlan0 up; dhcpcd -t 30 wlan0[/quote1qrfz0l7]
The driver will do nothing automatically, all actions must come from userspace. Basically all three options above are wrong, to trigger a reassociation you must call 'iwconfig wlan0 ap ...' there is no need to bring down the interface.
Why are you using dhcpd? If you want a fast connect/reconnect in such quick times that wpa_supplicant isn't usable for you, you might want to switch to static IPs to reduce the required time for DHCP requests.
About what you said, I allways run my iwconfig like "iwconfig wlan0 essid "mynet" ap any", but know I understand why I have to use the "ap any" part. I never set the mode, since is always managed.
No you shouldn't use 'ap any' you should use the BSSID value from the beacon. The 'ap' value will trigger the association with the AP you passed as argument so the value you pass to it is important.
1. Now speaking about DHCP, do I have to kill the dhcpcd every time I reconnect???
I don't think so, but it might force DHCP to send out a new dhcp request faster that way. You need to check the dhcpd docs for that.
2. The simple algorithm of connecting would be
[code16argew8] 1-load modules, bring the interface up.
2-scan for the network. repet while not available.
3-attempt connect by "iwconfig essid ... ap any"
5-test connection[/code16argew8] Is it correct?
Except for the 'ap any' part, it looks fine. Resetting the essid can be skipped unless it has changed.
3. If I issue once the "iwconfig essid ..."(boot script for example) do I have to include it again every time I attempt an association?
Setting the essid only has to happen once, so during boot is sufficient.
3. If I'm already connected (associated) and I issue the "iwconfig ap any" command what is the result?
Setting the 'ap' while associated will probably trigger a reassociation
1. What the ap anny does??? I use wds so I thought the ap any will associate with the best (strongest) ap from the myessid net.
No, the driver will not choose the best AP to connect to, that is work done by userspace (this is something why wpa_supplicant is always usefull )
"iwconfig wlan0 ap any" shouldn't do anything in particular, perhaps that for some drivers it does something, but mac80211 based drivers shouldn't do anything (perhaps it triggers a reassociation or disassociation, but it should never try to auto-associate to a random AP from the scan results.).
2. How do I discover the BSSID? from the "iwlist wlan0 scan" output???[/quote2p0mz3m7]
Consider the following scan result
Cell 01 - Address: 00:16:B6:12:5E:5C
Frequency:2.437 GHz (Channel 6)
Quality=48/100 Signal level=-68 dBm
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s
6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
36 Mb/s; 48 Mb/s; 54 Mb/s
The BSSID is the MAC address of the AP, so in this case 0016B6125E5C