 We are going to talk about Wi-Fi or wireless in general, okay? So just to know who is talking with you, I'm Kiran Divaker. Worked in IT industry for more than 50 years. In companies like EMC, Marvel, Paraspan. And I'm currently Vice President of KEEP, which is a non-profit organization related to software professionals in Pune. And I was one of the major contributors of Marvel's Wi-Fi driver. Okay, so these are some of the Wi-Fi devices. Nowadays, every device is having Wi-Fi. The majority of them are the laptops, the mobile phones, printers and cell phones and access points. Now access points are basically devices which are receiving Wi-Fi data and so on. So we'll look into details about all these things, how Wi-Fi gets connected, how Wi-Fi works at, let's say the chip level or at a Linux software level and all those internals. Okay, that's the main agenda of my talk. So everybody over here, I'm sure might have connected a Wi-Fi device to a Wi-Fi access point. Okay, in general, a Wi-Fi device, something like a laptop connects to an access point and access point is generally connected to some uplink. Okay, what is uplink? Uplink is nothing but a modem which has ability to connect to internet. So as a result, your Wi-Fi device gets access to internet. For example, in this case, I have some laptops, those can be connected to different access points and you can see that the backbone of access points is wired to each other. Okay, wherein you can might have some, this is like an enterprise notation where you might have file servers, PCs and so on, which are connected to internet. But the backbone of access points is wired and you can have devices which can be connected to those access points using wireless. Okay, so in Wi-Fi terminology, these are called as a station and AP. Okay, access point, station and in basically advanced Wi-Fi terms, there is something called as authentication server. Okay, in day to day use, when I'm using Wi-Fi based mobile phone, Android phone, in that case, this kind of setup is not there. But if you are using a complex enterprise server setup, in that case, this kind of setup is required. Now let's see how this works in a Linux based laptop or Linux based Android phone or any other devices. Okay, now what all things I need, if I want to get it running on, let's say my Linux based laptop, I got a Linux based laptop, I want to make sure that I can run Wi-Fi on this. Okay, what do you need? You need Linux kernel. Okay, I just noted for your information, some things which are by default enabled in any Linux distribution, any latest Linux kernel distribution that this, these are the requirements that you need to have the radio parameter so that your Wi-Fi, your Bluetooth and all radios can work. There is a term called as CFG 8.0 to 11, which is a recent development in Wi-Fi and we'll talk about this in details. Okay, you need a Wi-Fi access point. Okay, you need a Wi-Fi access point which can beacon, which should be there and we should be able to beacon. Now what is beaconing and so on? We'll see. Let's say if I start scanning over here, are there any Wi-Fi access points that I can connect to? I can see that some names are there. Okay, so those are called as SSIDs. Okay, those are called as the Wi-Fi device names. Okay, and what we need to, in order to connect to them is called as a supplicant. Okay, the supplicant is the one which sits on the station or which sits on the laptop, which sits on the Android phone. Okay, while access points are the one which are actually beaconing and which are transmitting, which are transmitting that I'm access point having this name and so on. Okay, so in order to connect to an access point, I need something called as a supplicant. Now this supplicant is a robust software which is, which is seen across all platforms right from laptops to phones and so on. Okay, if you don't know about supplicant or what I'm talking about, you might have seen at least this thing which is called as a graphical user interface named network manager. Have you seen network manager? I mean, you use network manager to connect to the access points, but that network manager internally uses the WPA supplicant or the supplicant. The supplicant is the core part of the network manager and network manager is just giving you graphical capabilities. Okay, just to tell you about some core things about Wi-Fi, what is the technology behind Wi-Fi in early 2002, 2003, all these things started with Wi-Fi 802.11 specification. Okay, and there were different, there are different specifications and various variants of that. So you might have heard of 802.11 A, B or G and what is the latest one? That is the N, 802.11.N. So that N specifies that it is having higher speeds and so on. There are latest, even the future variants of 802.11 N which are called as .11 AC, which are still yet to come to market, but those are already being developed and their testing is going on. Okay, so we are going to look at the concepts about Wi-Fi. What is the terminology? It is 802.11. Okay, you have different types of Wi-Fi networks. One is the infrastructure. Okay, other is ad hoc. What is the infrastructure network? In infrastructure network, you have access points and a device connecting to that access point. While in case of ad hoc network, any device can directly connect to another device. Okay, in that case, there is no ad hoc, there is no access point required. The major use of access point is that everybody connects to that access point, then only they can interact with each other. Let's say I have a laptop, he has a laptop and if we both want to connect to each other using wireless, I need to connect to access point which is located over there and then only we can communicate. While in case of ad hoc network, that is not required. We can directly connect to each other. Okay, but ad hoc networks are not that common because of the security reasons and so on. Okay, so all we use using access points are nothing but the infrastructure networks. So you can see in details something like this. So you need access points so that you can connect to each other. Okay, now let's say another use case that we generally see in real auditory life is that I have access point which is located over here and let's say I have access point which is located 10 meters down the line. Now 10 meters is a general distance that access points or Wi-Fi devices can catch a signal. Okay, now if both of them need to be part of the same network, then they can be wirely connected and then they can have same SSIDs and this can be part of the same infrastructure network. You can see advanced use of access points and how devices can connect to each other. Okay, so this is what we are seeing just now access point is a device that is basically central hub of all wireless data communication. Okay, then SSID whatever names you see whenever you scan from your home or whenever you scan from here, you see a lot of names which are saying that okay this is the name of the network that is available that is basically SSID of that device. Then BSSID is required if you want to know the MAC address of the device and so on in order to know the details about that you need to know about the MAC address and lower level details. As we go ahead I will talk about these things in detail. Mode we just saw about mode which is the infrastructure mode or the attack mode everybody uses the infrastructure mode for reliable communications and channels. Okay, another thing that every everyone who is basically using Wi-Fi I should know that what kind of channels we are using. Okay, let's say okay one of the predefined channels go from 1 to 16 in terms of frequency range from 2.4 gigahertz to 2.5 gigahertz and so on. Now what is this? This is basically the range in which your devices are going to operate. Now this is called as the BG channel. Okay, this is called the B or G channel. Okay, which is having range in 2.4 gigahertz and so on. And the channels are numbered as 1 to 16 in ideal but in India and in America and so on it's basically 1 to 11. Okay, now why I need to know all these things. Let's say I'll give you an example. Let's say whenever you set up your router or whenever you set up your Wi-Fi router what you do is that the router comes with the default settings. What is the default setting of a router channel is decided as auto. What do you mean by auto? The channel will be decided as automatically chosen by the device. Now as a result what happens the channel chosen by the device is generally 1 or 11 or 6. Now I'll not go in details about why 1, 6 and 11 but most of the times the device will select this kind of channels. Now as a result if you are having your access point on let's say channel number 1 and if your neighbor's access point is also beginning on channel number 1 you are going to have a conflict. You are going to have a conflict. So it's always better to have a fixed channel so that you know that your neighboring devices are not interfering with you. That's one of the things that you can set up in your router. I mean it's not good idea to set it up to auto channel. That's why as a Wi-Fi engineer or as a Wi-Fi I'll say person I should at least know what is a channel and what channel should I use and how this channel interferes with each other and so on. Okay if you use a A band I mean many I think none of the devices in India are basically using A band but A bands are a different band of devices and those are only required for certification. They have different kind of advantages and disadvantages as well. Okay I'll tell you why everybody uses BG channel is that they have a good penetration rate. Even if I'm sitting over here and there is a glass or there's a wall in between I can penetrate or the rays can penetrate and I can see the beacons and I can see the device over there. That's the advantage of using a BG device or a channel 1 to 11 range. Okay so understand the concept of a channel. Okay now these are some things that are required to know one is the encryption. Now if I start my network manager and I start looking for the Wi-Fi devices across me I see that some devices are having a lock on them and some devices are not having a lock on them. Okay have you seen this kind of behavior? What does this mean? A lock means that the access point is secure. Okay you need a password to connect to that access point. Okay and if it is not having a lock that means it's an open network. If you're having an open network anybody can connect to that device and there can be problems. Okay some intruder can always see the data that is going through between the access point and your device. Okay so it's always better or it's always recommended to have a security in between your access point and a device. Okay so there are various methods of security which are called as web, WPA, RSN which stands for WPA2. This is a standard one that everybody uses which is called as the WPA2. Okay so we call this as WPA2 PSK. So whenever if you are configuring a network and you see that what is WPA2 PSK that means you have to specify the password over there. Okay and then there is something called as PSK and EAP and all advanced terms. EAP stands for enterprise authentication. Okay and PSK stands for pre-shared key which is used in WPA2. Okay if you have any questions in between you can ask. Okay now let's try to see from the next perspective if I want to use this on if I can how can I use basically to connect to access points. I mean can I use network manager if yes I hope everybody uses network manager but I'll tell you what happens in between and knowing this internals whenever you connect to an access point gives you ability to debug problems. Okay because the world is very good but 99% of the time things work but there are some 1% of the times where things fail to work and if you want to debug those things we need to know the internals. So let's see the internals. Now this is the output of basically your device configuration whenever it is powered on or this is the default configuration of a device. Okay my device is double and zero. Okay have you seen basically what is the name of your device? The name of my device is generally double and zero. Okay double and zero stands for the wireless device. Okay what is it zero? It zero is your Ethernet device. Similarly double and zero is your wireless device. On boot I want it to be bootable as soon as the system boots. Boot protocols should be static or it can be DSCP. I can get the address from DSCP. Then hardware address is like a MAC address, then Netmass, IP address and so on. Then domain, type it's wireless and where it wants to connect to which is the ESSID. It can be any name that you want. Channel. I can specify the channel instead of auto and so on. And mode is managed which is nothing but your infrastructure mode. Okay so this is the default configuration. So whenever your system boots up this reads this kind of configuration so that it understands that I want to start a network manager and use this configuration to connect to access point having name links. Okay and it should be basically the links access point should be configured on channel number six so that I can automatically make a connection to that. Okay now in my case where I used my access point was not able to give the DSCP IP addresses so I can I use the static IP address. If your access point is able to give dynamic IP addresses you can use DSCP IP addresses. Okay so this is what the network manager reads at a good time. Okay now this might be familiar to you. A network manager. Yeah I am coming to that basically. IW configs are basically your command line interface. I will tell all IW config or even IW. I mean IW config was the older one. Nowadays people use IW which is a better command and I will tell you why better as well. Okay now this might be a bit familiar to you. Where your network manager is looking at devices. It's having some devices which are insecure in nature. I can connect to that if it is a secure device. Okay then it will be prompted. I will get prompted for the password. I can type in the password and once the password verification is done I can connect to the wireless access point. Okay now this is what we have come up to from where what is Wi-Fi what is access point to what wireless it gets connected to. Now let's look at the in between layers or let's try to read between the lines. Okay so this is what will be what you are asking. So what does the network manager do? Okay like I mentioned whenever at the boot hub it's going to basically look at your device configuration and start connecting to the access point. Now how the network manager is going to understand that okay there is a access point with this name and so on. Okay so for that there are some steps required in between. Now those steps are called as scanning, authentication and connection. Okay the first step is basically scanning. What do you mean by scanning? Scanning is basically you want to see how many access points are there. Okay you want to see how many access points are there or how many access points are beaconing in this area. What is the meaning of beaconing? Beaconing means that they are at a frequency of let's say 100 milliseconds or so on. They are sending that I am allowing kind of message and this is a wireless message that a wireless device can capture. Okay and then once this message is captured there is a field which says that SSID and SSID name is over there. So an equivalent command is IWList double land zero scan. Okay you can see IWList double land zero scan. So if I want to scan using my device I can use this command and see the names of all the access points. Okay now like I mentioned IW config is basically kind of getting deprecated and a new term that is coming into picture is called as IW. There is a similar command that you can use IW zero scan. Now I will get into details about why this is getting deprecated and so on in some time. Okay for backward compatibility in all distros we still have IW config and so on. Okay so you can see as soon as the device gets scanned I can see some information like this. So this is the name of the device. The ESS ID is the name of the device. It is beckoning in master mode that means in infrastructure mode. Then it is beckoning on channel number 6. Channel number 6 is having a frequency of 2.4, 2.437 gigahertz to be specific and its encryption is on that means it is a secure device. That is how network managers understand that this is an access point having this kind of security and so on. Okay and when it finds that I want to connect to this access point then only it will try to connect the access point. It will find all the access points which are in the vicinity. Okay so this is done by scanning. Okay now once the device is scanned what you need to do is you need to connect to that device. Okay so what it will do once it finds that there is the device is having security it will ask for the password. Then you can type in the password whatever password is specified. Okay and then the device the wireless device can connect to the access point. Now this command which can do this is IW config double line zero ESSID linksys. That means using the double line zero device I want to connect to the linksys access point. Now what is the use of this command? This command is going to connect to that access point having linksys name and specifying that password whatever you have entered. Since that access point says that the encryption is on I want to connect to that access point using the password. Okay so there is a concept called as 4-way handshake. So the password is authenticated properly using 4-way handshake. And once the 4-way handshake is successful then only the device gets connected. Now like I mentioned about the WPA2 encryption this is a very powerful encryption which is very hard to crack and so on. So it's always recommended to have basically combination of your special characters and so on in the password. There are tools in Wi-Fi where you can use, these tools can be used for cracking the Wi-Fi and so on. So it's always better to use the password rather than let's say Kiran like a password which is an external name. It's always better to use passwords which are very difficult to guess and so on. Otherwise there are tools like air crack I can tell you the name of the tools and so on which can be used to crack this kind of passwords. So beware about when you are choosing your Wi-Fi password. And once the connection is successful then you can see that if I see the output of IW config WLAN0 then I can see this is what it shows. It shows that the WLAN0 device which is having name WLAN0 which is the Wi-Fi device is connected to the access point links and it's connected in managed mode with this frequency and the bit rate and so on and these are some advanced Wi-Fi parameters and so on. At this point I have created a virtual wire between my device and access point. This is very important. See if you look at Wi-Fi there is no difference as compared to wire device and Wi-Fi device except that there is a virtual wire created between the Wi-Fi device and access point. The moment your wire breaks that virtual wire breaks the virtual wire breaks because you are moving away from the access points and so on. So what happens because of that? Because of the virtual wire breakage your disconnection gets broken. This is as good as you are removing the wire from your Ethernet port. This is basically what you configured the Wi-Fi and in short these are the commands used for connecting. One is the scanning command, other is authenticated into one access point. Then the four-way handshake like I mentioned and then you can check the access point of IP address of AP which is network connectivity and so on. So at this point your connection between your Wi-Fi device and access point is ready. Whether your access point is able to access the internet and so on that's a different matter. That's basically the router configuration. So what all applications we use over here? Network manager. So this is a defector or the standard application which is available in every Linux distro which is used for connecting to Wi-Fi networks, creating ad-hoc networks. We are doing Wi-Fi direct and so on and all other kind of even it can be used to connect to using wire device as well. So network manager is basically capable of handling any type of network devices. Then the WPS supplicant which was used for connection between your device and access point. Then host APD, I'll talk about host APD, what is this in some time. And there are other things like K Wi-Fi manager, connection manager which are similar to your network managers. Let's see sometimes what happens if, I mean all these things wherever I was talking, I was talking about the 99% of the things where things are working fine. Now what happens sometimes things doesn't work. At a result I need to do something. So where is my Wi-Fi device? My Wi-Fi device whether I can't do anything without that. So that means I need to have at least the Wi-Fi device. Now even if you can't see double down zero device, where to see the Wi-Fi device? You can see your Wi-Fi device, it is generally a PCI device or a USB device. For example, I have output of LS PCI command on my system where you can see the lower, I mean I don't know whether it's visible. There is a Broadcom cooperation device, which is a Wi-Fi device. We can figure out whether it's a ABGN device and whether it's a Wi-Fi device. Looking at that you can figure out, okay at least the Wi-Fi device is present in my system. Now I can get it working. So in order to get your Wi-Fi device working, you might need to basically get your Linux driver working. So driver might be part of the Linux kernel or you might have a vendor supplied driver. If you have a vendor supplied driver, you might want to recompile the driver against your kernel. Okay, so those kind of things are required. And once your driver is recompiled, it may be using make commands and so on, 99% of the things, for example the device I showed, they have a vendor supplied driver. There is no driver which is coming out of the box from Linux kernel. Intel works out of the box. Broadcom, this device has an issue. Special 4132, that has an issue. They supply a vendor compatible driver. In that case, you need to recompile your driver. Pardon me? Most of the devices work out of the box. Some devices might have issues. In that case, I'll tell you the details about it. They don't want to submit their code to the Linux kernel tree and so on. There are different things in the internals. What is that? Okay, other thing that you should know is basically something called as RFKill. RFKill is basically a way where whether your device is blocked or unblocked. For example, some devices have a hardware switch. Once the hardware switch is set to on, then only your Wi-Fi starts scanning or Wi-Fi starts working. If your hardware switch is off, then you can't... I mean it's very difficult generally that I forgot to keep my Wi-Fi switch to on position and so on. So there is a tool called as RFKill where you can check whether what is the blocking status of your Wi-Fi device. Whether it's a soft block or hard block. If it is hard block, it will be blocked using the switch. Or if it is a soft block, it will be blocked using some command like RFKill. Okay, so note this command which can be used. See, this is what is the output of RFKill list. So it shows what kind of device it is able to control, which is the SCI... Sorry. The SCI0 is your Bluetooth device, then 50 is your Wi-Fi device and there is a Broadcom device that I am using. So basically RFKill can be used for these kind of things. One more thing that I would like to tell you is sometimes if you are working with command lines and so on, what happens is network manager is basically fishy in terms of basically tries to get the control of the device every time. Okay, if you don't want your network manager to get the control of the device, you can just turn it off using service. Network manager, stop. Say that don't interfere. I can handle these things myself. Okay, that's one note. As a common pitfall, you can note. Okay. A couple of things that I would like to cover over here are the host APD and so on things that I was talking about. Most of your Android phones, take out your Android phones. They are having a mode where you can start a access point in the phone. That is nothing but host APD mode or the access point mode. I can start access point mode within my device. Now, why you are able to start access point mode on your device? It depends on basically whether your Wi-Fi chip on the phone is having a capability or not. They need to have it requires AP stay Wi-Fi device capability. AP stay, it can act as an access point and station simultaneously. Okay, so all most of the device, I mean, which are in market nowadays have this capability where you can have access point and station both working out of the box out of a one single chip. Okay, one single chip on the same channel. You can note the last point, which says that features simultaneous operations on the same channels. So if your access point is beginning on channel number six, you can connect to access point, which is different as a client on the same channel. Okay, it can't be different channel. Okay, because the same radio is there. Okay, same Wi-Fi device is there. So that's why you can use access point station capability and that can be used for connection and you can even start access point of your own. Okay, so that is available in your Wi-Fi phones. It is available in your laptops and so on. Another thing is basically what something called as Wi-Fi direct. Now what is Wi-Fi direct? I don't want to basically make a publicity of Sony Wi-Fi brand over here, but have you seen Sony, Bravio TVs and so on? They have this mode called as Wi-Fi direct where you can connect your laptop to the TV and you can play your things from your play your music or play your videos from your laptop directly onto the TV. So that uses Wi-Fi direct. So what is Wi-Fi direct? They make connection between the access point acting inside the TV and the station which is acting inside the device or the laptop and make the connection. No, I didn't get the question. It can also be done in the licensed spectrum, which is there. No, I don't think there is nothing with the license over here. What I'm talking about is basically the terminology Wi-Fi direct where you can have access point and a station. Yes, what I'm just saying this could also be done without using any brand name. This could also be done. Okay, I just gave an example. I just gave an example where I saw as a market one of these products and I was working in Marvel, we were basically working on this technology with the Wi-Fi direct and so on. Okay, so let's go ahead. If you want to debug, you want to capture the frames and so on. Since I'm running out of time, I'm just running ahead. Okay, so in internals, I just cover one slide and then I'll stop basically. Any internals, it's in Linux. He makes use of a simple system called architecture where from application, you take the control to the corner space corner. It goes to the actual device. In this case over here, it will go to the actual Wi-Fi device. It will talk to the Wi-Fi chip on which is underneath and then it will do the operation on the Wi-Fi chip. For the Wi-Fi chip, there is a software required in order to basically transmit and so on and so forth. That is called as the microcode or that is called as the firmware code in vendor terms. So every firmware code is distributed as a binary even for all Linux distributions and it is generally kept in some directory like libfirmware. If you see a slash lib slash firmware directory, you will find the microcodes. Even Intel and so on, all those are microcodes which no vendor basically distributes as a source. Those are binary things. That's their IPA. But Linux kernel as a result of that has moved ahead and all these MLME operations, all these Wi-Fi operations are basically now at the part of Linux kernel and very little things can be done at the chip level. So that's basically the new stack in Wi-Fi which stands for Mac 8.0.11 and there is a configuration stack called as CFG 8.0.11 because of this problem where people were having huge firmware bloats or huge firmware microcodes which are proprietary. Most of the things are done at the Mac 8.0.11 level or CFG 8.0.11 level of the Linux kernel and then very little needs to be done at the chip level and very little needs to be done at the application layer or the network manager level. Given that, I will just stop over here and open up for questions. Any more questions? Yeah, Android uses HostAPD. HostAPD source code, if you look at HostAPD and WPS Applicant is a common source code and that is part of your, even the laptop, even the phones and so on. Everybody, WPS Applicant for Connecting to Access Point HostAPD for Acting as Access Point. All they do is basically they connect to the kernel kernel talks to the actual driver and if the driver needs to talk to the microcode he will talk to the microcode he will do the beginnings, transmission, reception and so on. T7630E By default, most Linux operating system when we install, they support this Wi-Fi and Bluetooth automatically, we don't need to install any drivers but it is not showing anything actually neither the Wi-Fi it's connecting if we click on that Wi-Fi it shows enabled networking only, no Wi-Fi devices or Bluetooth. So look at, I mean, maybe I'll share these slides look at those slides where I have mentioned if your device is not seen first see whether your device is there I mean, your vendor has supplied a Wi-Fi device it's there because it was in Windows. Okay, if it is shown in LSPCI okay, then you can see that you can for sure say that I can make it work in Linux, okay first thing is that look at whether there is a vendor supplied driver because if it is not coming out of the box from Venus kernel could be the reason that there is no Venus kernel inbuilt driver look if there is a vendor supplied driver you'll most probably find the driver you might want to recompile that driver for example, once what I had to do I was basically recompiling a new kernel and the vendor supplied driver was not compiling in that case you might want to make small changes to the kernel, okay now these changes are not that difficult from the point of view of basically kernel understanding you don't have to understand anything about Wi-Fi because if you want to port a kernel from let's say 2.6 to 3.0 you just have to port the APIs because there are some kernel changes that are happening so you can make similar change and make it work but every time if I update the kernel suppose I am using Ubuntu and there is the latest release for kernel every time I update the kernel then every time I have to recompile the driver for it yes, I mean unfortunately basically you have got a device which is not supplied or basically which doesn't have a Linux kernel supplied driver in that case we have to basically deal with this problem actually I got a driver from Github someone provided it but what is happening is once my laptop starts I have to recompile it every time I start my laptop no, no that is not required because it's happening because after I recompile the driver it shows Wi-Fi and Bluetooth for this session until I turn off my computer but after I turn off and again turn it on it's back to it basically every time you just need to load the driver you don't have to compile it and the loading of the driver can be done in some initialization script like your ATC modprobe.com and so on where you can tell that for this device use this driver and so on that's the one line activity I am talking about thanks for the talk I got a question you mentioned that on an android device you can turn it on as an access point and simultaneously connect as a client to another access point or to somebody connecting to your access point in the android device if your device is having access point and station compatibility okay so let's say how would I know that I mean it will become obvious to you or is it basically nowadays from my experience nowadays everybody supports that because of the let's say peer compressor and so on every device has this access point and station compatibility if they want to keep the price of the android phone down they might have not basically had that kind of chip in the device so you will have to basically look which chip is there in the phone and then see whether maybe search on the net whether it's having access point and station compatibility assuming that I mean if it is in the software really simple commands where you can make it enable like a root the phone for that no you don't have to I mean even during the loading of the device you can just say that there are some basically modes something like I mean it's like a bitwise oring bit number zero is for station mode bit number one is for access point mode by default you load with bit number one set that means it is coming up as a station mode if you just set bit number two as well you come as an AP plus station mode let's say I gave you the example of the device that we used okay so given that the access point and station is going to work you can have access point let's say coming up on channel number six and beaconing as android AP okay I can connect from my station to that android AP that you are having now he can have access point where that is beaconing as something else and your station can connect to that access point so simultaneous AP stays in your device okay okay so if there are any more questions maybe you can contact me offline thanks for attending the talk thank you