4

TL;DR available at the bottom

I've been trying to figure out a way to get two laptops (both running Ubuntu) to be able to pass basic messages back and forth without the need for them to be connected via a wireless network,either by an AP or ad-hoc. I want to reiterate here that ad-hoc networking is not what I'm looking for, I've seen many similar questions here with that as the answer.

I guess what I'm asking is: how do I achieve this? All I really need is for one computer to be able to send a packet, and then for another to pick it up via a packet sniffer of some kind.

Currently: I have both laptops in monitor mode (via a mon0 interface created from aircrack-ng's airmon-ng)so that they can sniff nearby traffic (with Wireshark, tcpdump,tcpcump.org's sample libpcap code, and opening a raw socket and just printing out all the packets. I tried each just because I thought one could be doing something differently/leaving something out). I also have a very basic program that consists of opening a raw socket to send crafted ethernet frames out to the air, but I can't get my two machines to see the other's packets. The sniffer running on each machine can only see the packets going out of that machine (in addition to nearby beacons/control traffic from wifi in the area).

Some things to note that might be important are:

-the packets I'm sending out appear in Wireshark (only on the sending machine) as malformed 802.11 packets (probably because I'm just filling them with junk data for now). I was under the impression that my other laptop would also see them as malformed packets, but it gets nothing

-the sockets I'm using are from a call to socket(PF_PACKET,SOCK_RAW,ETH_P_ALL). Raw sockets are something I just recently was aware of, so I could be misunderstanding how they work, but my impression is that I can craft a layer 2 packet by hand and ship out straight out to the wire/air.

If you're curious as to why I want to do something like this, it's part curiosity, part research for a project I'm working on. I want to streamline / automate the process of setting up an ad-hoc network, and what I'm trying to do here is for the laptops to do a small exchange to figure out the specifics of the adhoc network they are about to create and then make/join that network automatically, instead of either one person explicitly setting up the network OR having both people pre-decide the name, etc of the network and have both computers constantly trying to connect to that specific one.

I'm more interested if I'm going about this process in the right way rather than if my code works or not, if someone thinks me posting my (very basic, taken from another post on Stack Overflow) raw socket code will help, I can.

Edit: I am more than happy to post a complete set of code with instructions if I can get this working. I couldn't find much helpful info on this topic on the internet, and I'd love to put it up for future people trying to do the same thing.

TL;DR I want to send out a packet from one laptop and pick it up on another via a packent sniffer of some sort. No wifi network or ad-hoc network involved. Something akin to spoofing an AP's beacon frame (or similar) for the purpose of sending small amounts of data.

Edit 2:After some thought, perhaps what I'm looking for is some kind of raw 802.11 use? Having direct control of the wifi radio? Is such a thing possible?

Kaz
  • 143
  • 1
  • 9
  • 1
    May I advise you to narrow this question down? It's a bit tl;dr at the moment (IMHO) and what you're actually asking is somewhat hidden. You don't have to do anything about it, but I feel it might help. – Bart Mar 20 '12 at 20:50
  • Yeah my post is kind of thick. I appended a summary to the end, I hope that's more clear? – Kaz Mar 20 '12 at 21:14
  • @Kaz - "looking for is some kind of raw 802.11 use", clearly this is 'possible', but I don't know the state of Linux WiFi hardware interfaces. My only knowledge is based on using an H&D Wifi SD card on a training course. We were provided with closed source code to load onto the card, and we could only talk to that :-( I assume someone somewhere has a more open approach. Can you change laptops if necessary? – gbulmer Mar 20 '12 at 22:54

2 Answers2

2

I found out I was able to send packets out through my monitor mode interface as long as I had correct 802.11 with radiotap headers. I think the problem I was originally experiencing (not being able to sniff the packets) was because they were malformed and thus not actually getting sent out.

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

Rafał Rawicki
  • 22,324
  • 5
  • 59
  • 79
Kaz
  • 143
  • 1
  • 9
1

I am certain that Apple Mac do this. Apple call it 'bonjour'. There may well be a proper IETF spec for it. This is an Article on Bonjour this is Wikipedia on an open component of bonjour which might help get you moving.

gbulmer
  • 4,210
  • 18
  • 20
  • Hmm. That's very interesting, but from those two articles it seems that the devices must already be networked in some way. I'm trying to find out how to do raw, network-less communication. The latter one, although a useful protocol, also requires a device that acts as a proxy for other devices, and I would need to solve this network-less aspect of my problem before I could start bringing proxy devices into the equation. – Kaz Mar 20 '12 at 22:21
  • It used to be the case that two Macs could start 'talking' on a 'plane. I checked at the time (3+ years ago, so I apologise if I am misremembering), and I believe it didn't need a third network device. – gbulmer Mar 20 '12 at 22:28
  • Oh, bottoms - I wonder if it relies on IPv6? I know that other wireless networking, like 6loWPAN uses some nifty IPv6 'ping' enhancements to support routing - I will try to find out. Sorry for wasting your time – gbulmer Mar 20 '12 at 22:32
  • Not at all, I think I'll actually take a look at that later. I'm sort of in a networking "phase" of all my programming project interests right now, and I can probably use Bonjour for some interesting network stuff. Thanks! – Kaz Mar 20 '12 at 22:35
  • @Kaz - If you can use IPv6, it would be worth looking at the enhancements to ping. [Contiki Wireless networking](http://www.contiki-os.org/) makes extensive use of it to build its mesh network routing. So if you can wire-in IP addresses for now, there may be some inspiration/ideas/solutions in Contiki. Please 'ping' if you get anywhere, it's an interesting problem. – gbulmer Mar 20 '12 at 22:48
  • Wow, the project I'm working now is directly based on "The Internet of Things". This might be what I need. I'll take a look. – Kaz Mar 20 '12 at 23:01
  • @Kaz - talk about coincidence - I was talking earlier today to a person who was an expert in the 'Internet of Things', and he hadn't heard of Contiki either. I think they need to work on their marketing. Their is a pretty good book on it called [Interconnecting Smart Objects with IP](http://www.amazon.com/Interconnecting-Smart-Objects-IP-Internet/dp/0123751659/ref=sr_1_1?s=books&ie=UTF8&qid=1332285144&sr=1-1) They have a VMWare virtual image, which you can install and run on free VMWare, so very easy to get started, – gbulmer Mar 20 '12 at 23:13