# FreeBSD : Wireless Ad-hoc Networking with IP alias



## Govind (Jun 17, 2011)

Hello friends,

I'm a newbie to FreeBSD. Trying to implement a IEEE paper: Energy consumption models for ad-hoc terminals (computers).

The test setup with three computers and wireless NIC goes as follows:


```
Transmitter (A) -------------> Forwarder (B) --------------> Receiver (C)
10.0.1.1/24 ------------------ 10.0.1.2/24 (10.0.2.2/24) --- 10.0.2.1/24
```

Here laptop B acts as a forwarder. It has one wireless NIC. I use an IP alias to create a virtual NIC to forward the data to receiver. But laptop B is not forwarding the packet.

My /etc.rc.conf file is as follows:

*Laptop A (Transmitter)*:

```
wlans_ath0="wlan0"
create_args_wlan0="wlanmode adhoc"
ifconfig_wlan0="inet 10.0.1.1 netmask 255.255.255.0 ssid energy"
```

*Laptop B (Forwarder)*:

```
wlans_ath0="wlan0"
create_args_wlan0="wlanmode adhoc"
ifconfig_wlan0="inet 10.0.1.1 netmask 255.255.255.0 ssid energy"
ifconfig_wlan0_alias0="inet 10.0.2.2 netmask 255.255.255.0 ssid energy"
```

*Laptop C (Receiver)*:

```
wlans_ath0="wlan0"
create_args_wlan0="wlanmode adhoc"
ifconfig_wlan0="inet 10.0.2.1 netmask 255.255.255.0 ssid energy"
```

Can some one tell me why laptop B is not forwarding the packets? Thanks in advance.


----------



## SirDice (Jun 17, 2011)

Add to /etc/rc.conf on the forwarding machine:

```
gateway_enable="YES"
```

This turns on routing, which is disabled by default.


----------



## Govind (Jun 29, 2011)

Hello friend,

Thanks for your reply.. After adding 
	
	



```
gateway_enable="YES"
```
 into my /etc/rc.conf, it didn't work. Then I added 
	
	



```
defaultrouter=10.0.1.2
```
 in Host A. Then it started transferring the data. Please confirm, is it correct or not? Thanks for your kind, swift reply.

I want to transfer the data @ 2Mbps throughput between Host A and Host C. How to do this in FreeBSD?  How to fix or specify the throughput? Thanks in advance.


----------



## SirDice (Jun 29, 2011)

Both host A and C will need a default gateway, and it will point to their respective addresses on host B. 

The default gateway is used when the destination address isn't found on the local (sub)network. The packet will get sent to the default gateway which in turn will try and figure out where to route it next.

I assume you want to prioritize or limit the traffic going in/out of host B? This can be done with IPFW/Dummynet or PF/ALTQ.


----------

