Skip to content

maxshine/sensorSimulator

Repository files navigation

General Introduction
--------------------

This is a small tool to compose network packet for specific purpose of WiFi sensor testing. WiFi sensor is a normal interface device running in Monitor mode, which will capture all data packets reaching it in the air. To test it, it needs a simulator tool to generate any amount of packets at will to give the device desired workload. The main business of tested WiFi sensor is to capture MAC addresses from the packets it receives, so there are following factors to define the "workload" against target tested sensor devices:
	- Quantity of devices moving around sensor simultaneously
	- Packet size
	- Tx power level of WiFi signal carrying sent packet 

So this tool make these factor as configurable. It can compose UDP-based packets with desired size, and vary the MAC address data in the data frame. It make used of pthread API to send data concrrently. The workload is simple as: read in the configuration, create threads, each threads send out desired amount composed packets at desired interval, clean up and exit.

Pre-requisites:
---------------

To compile the source code of this tool, you need a Linux-based build and runtime environment, with required tools and development libraries installed. i.e. if you are using Debian-based distribution like Ubuntu, just use following command to install them:
	apt-get install gcc libc6 libc6-dev libnet1 libnet1-dev

For other distribution with different package management system, refer their manual to do this.

The tool also make use of iw-based wireless tool to manipulate WiFi interface at low level. Please ensure it's installed correctly, and check it by command `iwconfig`, see if it could list all wireless interface in the box.

The tool needs a wireless interface connected with any WiFi network. So the interface mode should be `managed` and associated a AP(access point). You could check this with `iwconfig` command.

Compile instructions:
--------------------

macDataGenerator.c - This is a small utility to help generate MAC address into a data file for future usage. To compile it's simple as:
	gcc macDataGenerator.c -o macDataGenerator
	
sensorSimulator.c - This is the main program of simulation tool, all-in-one source file. To compile use following command:
	gcc sensorSimulator.c -o sensorSimulator -lnet -pthread

Please note, MUST use -pthread link parameter, to ensure POSIX API so linked to thread-safe version.

Usage:
------

macDataGenerator - the command gramma is :
	macDataGenerator <MAC address prefix> <quantity to be generated> <output data file>

i.e.	macDataGenerator 00:06:09 1000 macid.data
The MAC address in macid.data would be like: 
	00:06:09:00:00:01
	00:06:09:00:00:02
	00:06:09:00:00:03
	.....
	00:06:09:00:03:ef
The prefix parameter should have at least one digit, like 10 or fe. The tool prints out generated entry in low case. It could do parameters check automatically, like the quantity input should not exceeds possible upper limit.  Please note, the tool omits the entries will all-zero and all-FF ones.

sensorSimulator - the command could be issued :
	sensorSimulator -c <configuration file>

About configuration file details, please refer to the sample one in the package.

Tips:
-----

One thing to highlighted here is about the tx power parameter in the configuration properties file. Before running this tool, you could connect the wireless interface with any network and run command `iwconfig <interface name>`, then find a line with tx-power value. That's the default value for the interface hardware, usually it's the 100% power capability and you should use as the baseline. Note in the output of `iwconfig`, the unit is 'dB', which means decibel. You could convert it into unit as 'milli-watt' as used in configuration properties file, with below formula:
	milli_watt = 10^(dB_value/10)

The tool uses milli-watt as unit because it has better resolution than decibel, although it's hardware's matter how to handle it eventually.

Another thing is about high volume usage. In the development, it's noticed that the process stack is a limit to create enough threads, i.e. 1000 threads. Therefore, if you are noted with the following message, try with command "ulimit -s unlimit" and then rerun the program to see any luck.
	The 995th thread creation fails, error code is 11. Reason is : Cannot allocate memory

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages