Establish direct peer-to-peer Wi-Fi connection between laptops

TL; DR available below

I was trying to figure out how to get two laptops (both of which are running Ubuntu) to be able to send basic messages back and forth without having to connect them wirelessly, either using an AP, or for that case. I want to reiterate here that ad-hoc networking is not what I'm looking for, I've seen many similar questions here as an answer.

I guess what I am asking is: how do I achieve this? I really need one computer to be able to send a packet and then another to pick it up via a packet sniffer.

Currently: I have both laptops in monitor mode (via the mon0 interface built from aircrack-ng airmon-ng) so they can sniff nearby traffic (using Wireshark, tcpdump, sample libpcap code and opening a raw socket and just print all the packages. I tried each one just because I thought I could do something differently / leave something). I also have a very simple program which is to open a raw socket to send the processed Ethernet frames over the air, but I cannot get my two machines to see other packets. A sniffer running on each machine can only see packets coming out of that machine (in addition to neighboring beacons / control traffic with Wi-Fi in the area).

Some important points to note:

- the packets I'm sending show up in Wireshark (on the sending machine only) as incorrect 802.11 packets (probably because I'm just filling them with junk data). I was under the impression that my other laptop will also see the wrong packets in them, but it gets nothing

- the sockets I am using is a call from a socket (PF_PACKET, SOCK_RAW, ETH_P_ALL). Raw sockets are something I was aware of recently, so I might not understand how they work, but my impression is that I can create a Layer 2 packet manually and send it straight to wire / air.

If you're wondering why I want to do something like this, it's part of the curiosity, part of the research for a project I'm working on. I want to optimize / automate my ad-hoc network setup process and what I'm trying to do here is that laptops do a little exchange to figure out the specifics of the adhoc network they are about to create and then create / join that network automatically , and not to one person, by explicitly setting up the network OR if both people have previously determined the name, etc. network, and both computers are constantly trying to connect to this particular one.

I am more interested in whether I am doing this process correctly and whether my code is working or not, if someone thinks that I am posting my (very simple, taken from another post on Stack Overflow) raw socket code will help, I can ...

Edit: I'm more than happy to post a complete set of code with instructions if I can get this to work. I couldn't find much useful information on this topic on the internet, and I would like to express it to future people trying to do the same.

TL; DR I want to send a packet from one laptop and pick it up by another via a packet sniffer. No Wi-Fi or ad-hoc network. Something similar to spoofing an AP beacon frame (or similar) in order to send small amounts of data.

Edit 2: After some thought, maybe what I'm looking for is some kind of 802.11 usage? Directly control the Wi-Fi radio? Is it possible?


source to share

2 answers

I found out that I was able to send packets through my monitor mode interface as long as I had the correct 802.11 with heatsink headers. I think the problem I initially ran into (not being able to sniff the packets) was because they were garbled and therefore not actually sent.

I was able to accomplish this by adapting the example code found here, courtesy of someone named Evan Jones , except I didn't need to use the Atheros card or Madwifi drivers, everything worked fine with the mon0 interface created with aircrack- ng.



I'm pretty sure Apple Mac does it. Apple called it "bonjour". There may well be a suitable IETF specification for that. This is a Bonjour article , this is a Wikipedia open source component of bonjour that can help you get going.



All Articles