了解了解什么是-capwap协议?

来源:互联网 发布:微信红包埋雷人工算法 编辑:程序博客网 时间:2024/05/01 22:27

具体参见:capwap协议规范

其中可以到网络上面下载到capwap的代码,我没有研究,有时间的话,一定会看的,主要是linux下面的C代码,其中代码主要有:socket,thread的使用,研究可以对linux下面的应用程序代码的编写有帮助。

我这里提供一份代码:在linux下面可以直接编译通过,但是没有研究AC和WTP的代码。

之前在网络上面找的代码在编译的时候有一下错误信息:

gcc AC.o ACConfigFile.o ACMainLoop.o ACDiscoveryState.o ACJoinState.o ACConfigureState.o ACDataCheckState.o ACRunState.o ACProtocol_User.o ACRetransmission.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWList.o CWLog.o ACMultiHomedSocket.o  ACProtocol.o CWSafeList.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o ACBinding.o ACInterface.o ACSettingsFile.o timerlib.o  ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT -o AC  
/usr/bin/ld: ./static/libssl.a(d1_srvr.o): Relocations in generic ELF (EM: 40)
/usr/bin/ld: ./static/libssl.a(d1_srvr.o): Relocations in generic ELF (EM: 40)
./static/libssl.a: could not read symbols: File in wrong format
collect2: ld returned 1 exit status
make: *** [AC] Error 1

出现上面的错误是由于库文件的不匹配造成的,把capwap目录下面的static中的

[root@mini /test/capwap/static]$ls
libcrypto.a  libssl.a 这俩个文件替换成虚拟机中./usr/lib/目录中的相应的文件之后编译通过。

root@mini /src/capwap]$make
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o AC.o AC.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACConfigFile.o ACConfigFile.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACMainLoop.o ACMainLoop.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACDiscoveryState.o ACDiscoveryState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACJoinState.o ACJoinState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACConfigureState.o ACConfigureState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACDataCheckState.o ACDataCheckState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACRunState.o ACRunState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACProtocol_User.o ACProtocol_User.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACRetransmission.o ACRetransmission.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWCommon.o CWCommon.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWConfigFile.o CWConfigFile.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWErrorHandling.o CWErrorHandling.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWList.o CWList.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWLog.o CWLog.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACMultiHomedSocket.o ACMultiHomedSocket.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACProtocol.o ACProtocol.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWSafeList.o CWSafeList.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWNetwork.o CWNetwork.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWProtocol.o CWProtocol.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWRandom.o CWRandom.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWSecurity.o CWSecurity.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWOpenSSLBio.o CWOpenSSLBio.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWStevens.o CWStevens.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWThread.o CWThread.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o CWBinding.o CWBinding.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACBinding.o ACBinding.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACInterface.o ACInterface.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o ACSettingsFile.o ACSettingsFile.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o timerlib.o timerlib.c
gcc AC.o ACConfigFile.o ACMainLoop.o ACDiscoveryState.o ACJoinState.o ACConfigureState.o ACDataCheckState.o ACRunState.o ACProtocol_User.o ACRetransmission.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWList.o CWLog.o ACMultiHomedSocket.o  ACProtocol.o CWSafeList.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o ACBinding.oACInterface.o ACSettingsFile.o timerlib.o  ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT -o AC  
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTP.o WTP.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPFrameReceive.o WTPFrameReceive.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPConfigFile.o WTPConfigFile.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPProtocol.o WTPProtocol.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPProtocol_User.o WTPProtocol_User.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPDiscoveryState.o WTPDiscoveryState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPJoinState.o WTPJoinState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPConfigureState.o WTPConfigureState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPDataCheckState.o WTPDataCheckState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPRunState.o WTPRunState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPRunStateCheck.o WTPRunStateCheck.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPRetransmission.o WTPRetransmission.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPSulkingState.o WTPSulkingState.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPBinding.o WTPBinding.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPDriverInteraction.o WTPDriverInteraction.c
gcc -Wall -g -O0 -D_REENTRANT  -I../openssl-0.9.8e/include -DCW_DEBUGGING   -c -o WTPSettingsFile.o WTPSettingsFile.c
gcc -DWRITE_STD_OUTPUT WTP.o WTPFrameReceive.o WTPConfigFile.o WTPProtocol.o WTPProtocol_User.o WTPDiscoveryState.o WTPJoinState.o WTPConfigureState.o WTPDataCheckState.o WTPRunState.o WTPRunStateCheck.o WTPRetransmission.o WTPSulkingState.o CWCommon.o CWConfigFile.o CWErrorHandling.o CWSafeList.o CWList.o CWLog.o CWNetwork.o CWProtocol.o CWRandom.o CWSecurity.o CWOpenSSLBio.o CWStevens.o CWThread.o CWBinding.o WTPBinding.o WTPDriverInteraction.o WTPSettingsFile.o timerlib.o ./static/libssl.a ./static/libcrypto.a -lpthread -ldl -D_REENTRANT -o WTP  
[root@mini /src/capwap]$

CAPWAP——Control And Provisioning of Wireless Access Points Protocol Specification。

其由两个部分组成:CAPWAP协议和无线BINDING协议。

前者是一个通用的隧道协议,完成AP发现AC等基本协议功能,和具体的无线接入技术无关。

后者是提供具体和某个无线接入技术相关的配置管理功能。这么说吧,前者规定了各个阶段需要干什么事,后者就是具体到在各种接入方式下应该怎么完成这些事。

CAPWAP协议的主要功能:

AP自动发现AC,AC对AP进行安全认证,AP从AC获取软件映像,AP从AC获得初始和动态配置等。此外,系统可以支持本地数据转发和集中数据转发。

瘦AP架构让AC具有了对整个WLAN网络的完整视图,为无线漫游、无线资源管理等业务功能的实现提供了基础。

2.2 一些名词

¢  无线控制器(AC):网络实体,在网络架构的数据层,控制层,管理层或者联合起来提供WTP到网络的访问服务。

¢  CAPWAP控制信道:一个双向信道,由AC的IP地址,WTP的IP地址,AC控制端口,WTP控制端口,传输层协议(UDP或者UDP-Lite)定义,在这之上可以收发CAPWAP的控制报文。

¢  CAPWAP数据信道一个双向信道,由AC的IP地址,WTP的IP地址,AC数据端口,WTP数据端口,传输层协议(UDP或者UDP-Lite)定义,在这之上可以收发CAPWAP的数据报文。

¢  STATION:一个包含无线接口的设备

¢  无线终端WTP:物理或者网络实体,包含一个射频天线和无线物理层可以传输和接收 STA在无线存取网络的数据。

Access Controller (AC): The network entity that provides WTPs access
   to the network infrastructure in the data plane, control plane,
   management plane, or a combination therein.

Station (STA): A device that contains an IEEE 802.11 conformant
   medium access control (MAC) and physical layer (PHY) interface to the
   wireless medium (WM).

Wireless Termination Point (WTP):
The physical or network entity that
   contains an RF antenna and wireless PHY to transmit and receive
   station traffic for wireless access networks.

目前,CAPWAP通信数据类型总体上可以分为两类:

l        CAPWAP控制隧道中传输的CAPWAP控制报文

l        CAPWAP数据隧道中传输的CAPWAP数据报文

目前CAPWAP功能的实现都是基于3层网络传输模式下,即所有的CAPWAP报文都被封装成UDP报文格式在IP网路中传输,而CAPWAP隧道就是由AC的接口IP地址和WTP的IP地址来维护的。

AC和AP建立控制链路的过程如下步骤:


1、 Discovery状态

该状态是一个WTP发现可关联AC的过程,在前期WTP可以通过1)读取静态配置文件中AC IP列表2)通过DNS域名解析3)DHCP返回AC IP列表4)广播等方式发送Discovery request,查找当前可关联的AC,当AC收到Discovery request,会发送Discovery response作为响应。

2、 Join状态

该状态是AC与WTP建立控制通道的交互过程,并在此交互过程中,AC检查WTP当前版本,如果WTP的版本无法与AC要求的相匹配,WTP和AC会进入Image Data状态做固件升级,来更新WTP版本;如果WTP版本符合要求,则进入configuration状态

3、 Image Data状态

Image Data状态是AC对WTP升级的过程,以便WTP的版本可正常关联AC

4、 Configuration状态

该状态用于做WTP的现有配置和AC设定配置的匹配检查,WTP发送configuration request到AC,里面包含现有WTP配置,当WTP当前配置与AC要求不符实,AC会通过configuration response通知WTP,WTP根据response内容对自身配置做重新设置。

5、 Run状态

当WTP进入Run状态,说明WTP与AC的控制和数据通道建立已成功,用户可根据需要,对指定的WTP做配置设置,如创建WLAN、Channel设置、Txpower设置等等,并可实时监控WTP的运行状态。

CAPWAP 协议的俩种操作模式:

   CAPWAP assumes a network configuration consisting ofmultiple WTPs communicating via the Internet Protocol (IP) to an AC.  WTPs are viewed as remote RF interfaces controlled by the AC.  The CAPWAP protocol supports two modes of operation: Split and Local MAC. In Split MAC mode all L2 wireless data and management frames are encapsulated via the CAPWAP protocol and exchanged between the AC and the WTP.  As shown in Figure 1, the wireless frames received from a mobile device, which is referred to in this specification as a Station (STA), are directly encapsulated by the WTP and forwarded to the AC.
              +-+         wireless frames        +-+
              | |--------------------------------| |
              | |              +-+               | |
              | |--------------| |---------------| |
              | |wireless PHY/ | |     CAPWAP    | |
              | | MAC sublayer | |               | |
              +-+              +-+               +-+
              STA              WTP                AC

        Figure 1: Representative CAPWAP Architecture for Split MAC


   The Local MAC mode of operation allows for the data frames to be either locally bridged, or tunneled as 802.3 frames.  The latter implies that the WTP performs the 802 bridging function.  In either case the L2 wireless management frames are processed locally by the WTP, and then forwarded to the AC.  Figure 2 shows the Local MAC mode, in which a station transmits a wireless frame which is encapsulated in an 802.3 frame and forwarded to the AC.
              +-+wireless frames +-+ 802.3 frames +-+
              | |----------------| |--------------| |
              | |                | |              | |
              | |----------------| |--------------| |
              | |wireless PHY/   | |     CAPWAP   | |
              | | MAC sublayer   | |              | |
              +-+                +-+              +-+
              STA                WTP               AC


        Figure 2: Representative CAPWAP Architecture for Local MAC

   Provisioning WTPs with security credentials, and managing which WTPs  are authorized to provide service are traditionally handled by proprietary solutions.  Allowing these functions to be performed from a centralized AC in an interoperable fashion increases manageability and allows network operators to more tightly control their wireless
network infrastructure.

CAPWAP 协议control 消息类型

           CAPWAP Control Message           Message Type
                                              Value
           Discovery Request                    1
           Discovery Response                   2
           Join Request                         3
           Join Response                        4
           Configuration Status                 5
           Configuration Status Response        6
           Configuration Update Request         7
           Configuration Update Response        8
           WTP Event Request                    9
           WTP Event Response                  10
           Change State Event Request          11
           Change State Event Response         12
           Echo Request                        13
           Echo Response                       14
           Image Data Request                  15
           Image Data Response                 16
           Reset Request                       17
           Reset Response                      18
           Primary Discovery Request           19
           Primary Discovery Response          20
           Data Transfer Request               21
           Data Transfer Response              22
           Clear Configuration Request         23
           Clear Configuration Response        24
           Station Configuration Request       25
           Station Configuration Response      26


原创粉丝点击