Wireless network programming in Unix (question)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Wireless network programming in Unix (question)
# 1  
Old 08-21-2010
Wireless network programming in Unix (question)

Greetings everyone,

I've been using OpenWRT for some time primarly for research in the University. I've also started with some basic network programming (sending UDP packets for instance). But since most of the available tutorials on unix network programming are more related to ethernet programming, I'm not sure if using it for wireless interfaces would be the same. I would like to know if there's any difference between ethernet and wireless raw socket programming.

I would also like to do some raw packets sniffing on a wireless interface "eth1". What structures should I use in order to read the prism headers in monitor mode? I've taken a look here and I can see that it's ok to use these structures:

Code:
struct prism_value
{
  uint32 did;
  uint16 status;
  uint16 len;
  uint32 data;
};

struct prism_header
{
  uint32 msgcode;
  uint32 msglen;
  u8char devname[16];
  struct prism_value hosttime;
  struct prism_value mactime;
  struct prism_value channel;
  struct prism_value rssi;
  struct prism_value sq;
  struct prism_value signal;
  struct prism_value noise;
  struct prism_value rate;
  struct prism_value istx;
  struct prism_value frmlen;
};

Has anyone done some wireless network programming/scripting?

I'm running OpenWRT on a WRT54G-TM, Broadcom BCM5352 chip, Linux 2.4.35.4.

thank you
# 2  
Old 08-22-2010
Quote:
But since most of the available tutorials on unix network programming are more related to ethernet programming, I'm not sure if using it for wireless interfaces would be the same. I would like to know if there's any difference between ethernet and wireless raw socket programming.
If by "ethernet" programming you mean opening a file descriptor and binding it to a socket in order to establish a TCP connection, or send UDP (connectionless) datagrams, then whether the underlying datalink layer is ethernet (802.3) or wireless (802.11) makes no difference. This is commonly what is referred to as "socket programming."

Capturing 'raw' datalink layer packets using something like BPF (Berkeley Packet Filter) doesn't require any special knowledge about the underlying datalink layer as the BPF device interface takes care of the differences. You will need to know how to parse the packets that the filter delivers. I'm assuming that the library you referenced (libpcap) provides a similar interface and from the brief look at the documentation it provides the necessary header files to make the interpretation of the data straight forward. My experience is limited to using BPF on both 802.3 and 802.11, so I cannot speak to your question about libpcap structures; sorry.

Two links that might provide some good information:
http://en.wikipedia.org/wiki/OSI_model The OSI networking model
http://www.gsp.com/cgi-bin/man.cgi?section=9&topic=bpf BPF man page
# 3  
Old 08-23-2010
The computer gets to control which network it connects to, which is very different from ethernet over copper, but once it's actually connected it acts just like any network. UDP tutorials and the like all apply perfectly fine to wireless --as well it should, otherwise we'd all need special new wireless-enabled clients and servers for mundane things like browsing the web!

This is because it's done in layers. The only program on your computer that needs to care whether it's wireless ethernet or not is the one that picks which wireless network connection your card connects to. Other programs just treat it like any other ethernet connection.

Last edited by Corona688; 08-23-2010 at 03:40 PM..
# 4  
Old 08-23-2010
Thank you very much for replying.

So sending data over sockets is a very low level approach. Structures are used to organize the data (bits or hex values).

Now, what if I'm unable to "organize" or "cast" such incomming traffic (in the case of packet sniffing with raw sockets) to a structure, but instead having to manually interpret the hex values in C? How can I "cast" these values in such case? (ie. I get: 77 6c 30 00 00 1c 10 c4 2d 70 08 00 45..." in hex, how do I convert it to actual data?)

thank you
# 5  
Old 08-23-2010
You can convert a string to a byte like this:

Code:
const char *hex="5d";
unsigned char byte;

sscanf(hex, "%02hhx", &byte);

[COLOR="#738fbf"]

---------- Post updated at 03:21 PM ---------- Previous update was at 03:19 PM ----------

As for putting the card into monitor mode, your information's as good as mine.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

UNIX network programming execution problem

I have started reading the book Unix Network Programming, Volume 1: The Sockets Networking API. I downloaded all the source code and performed all the steps present in README file.Now when i compile my first program it give the following error. sainandan@nandan:~/unpv13e/intro$ ./daytimetcpcli... (1 Reply)
Discussion started by: bsainandan
1 Replies

2. Programming

UNIX Network Programming making files problem

I have started reading the book Unix Network Programming, Volume 1: The Sockets Networking API. I downloaded all the source code and the readme says I must make the files. zuro@zuro:~/book/unpv12e$ cd lib zuro@zuro:~/book/unpv12e/lib$ make gcc -g -O2 -D_REENTRANT -Wall -c -o... (5 Replies)
Discussion started by: xuro
5 Replies

3. IP Networking

Network programming on UNIX env on windows

Hi, I have to start doing network programming in C/Unix but I have windows installed. Could someone please guide me how to set up the environment best suited for the networking programming? Regards Vinayak (1 Reply)
Discussion started by: vinayakj20
1 Replies

4. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

5. Programming

Unix Network Programming

I have written a client-server program which does some data from a file in server to the client. In this I don't want the client to wait indefinitely if server is not running. For this I am using SELECT system call, in this system call we can specify timings as an argument, which tells the client... (2 Replies)
Discussion started by: naresh046
2 Replies

6. Programming

Unix network programming

Hi! I am working on fedora.. trying to execute BSD4.4 client-server program which includes "unp.h" header file... While executing make command, I got error like, " expected " , " , " ; ",or ")" in connect_nonb file...ERROR 1 " I tried to change mode of makefile but I can't get... (4 Replies)
Discussion started by: nisha_vaghela
4 Replies

7. UNIX for Dummies Questions & Answers

Unix and Linux Network Programming

I want to develop a hybrid IM application which will consist of a chat and an offline messaging (BBS) part. Server must support Multiple connection (concurrent) Arguments should not be hard coded (code will be checked at different machines) No input at the command line Must run in the... (3 Replies)
Discussion started by: never mind
3 Replies

8. Programming

Network Programming in Unix

Good day everyone, Please help if you are interested in. I need to do a chat client-server program. Does anyone know where I can get references or sample programs? Thank you very much for your time Eric (2 Replies)
Discussion started by: powermind
2 Replies

9. UNIX for Dummies Questions & Answers

Unix Network Programming

I am going to purchase Unix Network Programming by Stevens. The only question I have is which edition to buy. The older (early 90's) edition, or the newer (late 90's) edition. I know conventional thinking would point to the latest ( and greatest?), but I wanted to get some feedback from the forum.... (3 Replies)
Discussion started by: dangral
3 Replies

10. Linux

question about accepr() in network programming

I'm working on my homework to write a chatroom program. Different users can be on-line at the same and talk to each other. I found that each time I invoked the accept function. A new socket was created. I don't how can I receive message from the client who is already on-line and send it to others.... (0 Replies)
Discussion started by: niukun
0 Replies
Login or Register to Ask a Question