Thursday, 4 September 2014

Wireless client mode , can it work in bridge with Ethernet ?

Lets say we have below setup :


   PC1----Eth0-- (Linux-1)----Wifi client ~~~~~~~Wifi AP------(Linux-2)---Eth0--PC2


Setup details:

1) Linux-1 and Linux-2 are two devices with each having wireless interface and an ethernet interface.

2) Linux-1 wireless interface is defined as client and Linux-2 wireless interface as  AP

3) Create bridge in Linux devices and add both the interface to the bridge. For L-1 it is Client and eth0 and L-2 its AP interface and eth0.

4) Ping from PC1 to PC2 -> will it be successful , all ip address are in same subnet.

Note : Wifi client and Wifi AP are just wireless interfaces on which mode is configured as Client and AP with proper Bandwidth, channel etc to make wireless link between the two interfaces.

Refer below links and see if you can find any answer for this question.

 http://wiki.openwrt.org/doc/howto/clientmode
http://wiki.mikrotik.com/wiki/Manual:Wireless_Station_Modes

Answer:


Explanation-1 :

The 802.11 standard only uses three MAC addresses for frames transmitted between the Access Point and the Station. Frames transmitted from the Station to the AP don't include the ethernet source MAC of the requesting host and response frames are missing the destination ethernet MAC to address the target host behind the client bridge.
  1. Bridged Host sends a packet to the Target host
  2. Frame is relayed via the W-LAN Client and the MAC address of the transmitting wireless adapter is used as source MAC, the sending ethernet MAC is discarded
  3. W-LAN AP receives the frame and redirects it to the Target
  4. Target receives the frame and generates a response
  5. Target responds to the received frame using the (wrong) source MAC as destination
  6. W-LAN AP relays the frame to the W-LAN Client with the given destination MAC
  7. W-LAN Client receives the frame and assumes it is the final destination since it's wireless MAC is used in the frame, the packet is not forwarded
  8. Bridged Host never sees a response frame since the W-LAN Client became the destination, no connection is possible
 Explanation-2:

Historically 802.11 AP devices were supposed to be able to bridge frames between wired network segment and wireless, but station device was not supposed to do L2 bridging.

Consider the following network:
[X]---[AP]-(     )-[STA]---[Y]
 
where X-to-AP and STA-to-Y are Ethernet links, but AP-to-STA are connected using wireless. According to 802.11, AP can transparently bridge traffic between X and STA, but it is not possible to bridge traffic between AP and Y, or X and Y.
802.11 standard specifies that frames between station and AP device must be transmitted in so called 3 address frame format, meaning that header of frame contains 3 MAC addresses. Frame transmitted from AP to station has the following addresses:
  • destination address - address of station device, also radio receiver address
  • radio transmitter address - address of AP
  • source address - address of originator of particular frame
Frame transmitted from station to AP has the following addresses:
  • radio receiver address - address of AP
  • source address - address of station device, also radio transmitter address
  • destination address
Considering that every frame must include radio transmitter and receiver address, it is clear that 3 address frame format is not suitable for transparent L2 bridging over station, because station can not send frame with source address different from its address - e.g. frame from Y, and at the same time AP can not format frame in a way that would include address of Y.

Analysis:

As per above explanation it is clear that we cannot bridge the station device.

Solution:

  For this to work, both the client and the AP need to transmit 4-address frames, containing both source and destination MAC addresses.

"iwpriv ath0 wds 1"

From Madwifi Documentation 

# create and configure AP interface
wlanconfig ath0 create wlandev wifi0 wlanmode ap
iwconfig ath0 essid "my_ap_essid" channel <X>

# create first WDS interface, tell about WDS partner, enable WDS mode
wlanconfig wdsath10 create wlandev wifi0 wlanmode wds
iwpriv wdsath10 wds_add <mac_address_of_wds_partner_1>
iwpriv wdsath10 wds 1

# create second WDS interface, tell about WDS partner, enable WDS mode
wlanconfig wdsath11 create wlandev wifi0 wlanmode wds
iwpriv wdsath11 wds_add <mac_address_of_wds_partner_2>
iwpriv wdsath11 wds 1

# bring all interfaces up
# NOTE: Bringing up the AP interface first is important at this time
ifconfig ath0 up
ifconfig wdsath10 up
ifconfig wdsath11 up

# create the bridge and enslave all needed interfaces
brctl addbr br0
brctl addif br0 ath0
brctl addif br0 wdsath10
brctl addif br0 wdsath11

# bring up the bridge
ifconfig br0 up
}}}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...