足球盘口

首页>>足球盘口资讯

应用笔记

W5100S-SOCKET-less ARP功能解析

更新时间:2018-11-13 阅览次数: 640

       ARP——地址解析协议,即ARP(Address Resolution Protocol),是根据IP地址获取物理地址的TCP/IP协议之一。

       ZAITONGGUOYITAIWANGFASONGIPSHUJUBAOSHI,XUYAOXIANFENGZHUANGDISANCENG(32WEIIPDIZHI)、DIERCENG(48WEIMACDIZHI)DEBAOTOU。

       DANYOUYUFASONGSHIZHIZHIDAOMUBIAOIPDIZHI,BUZHIDAOQIMACDIZHI,YOUBUNENGKUADIER、SANCENG,SUOYIXUYAOSHIYONGDIZHIJIEXIXIEYI。

       SHIYONGDIZHIJIEXIXIEYI,KEGENJUWANGLUOCENGIPSHUJUBAOBAOTOUZHONGDEIPDIZHIXINXIJIEXICHUMUBIAOYINGJIANDIZHI(MACDIZHI)XINXI,YIBAOZHENGTONGXINDESHUNLIJINXING


YI、SHIYONGScoket-lessMINGLINGLIUCHENG

新建位图图像.bmp

CONGSHANGTUWOMENKEYIKANCHU,Socket - less MINGLINGDESHIYONG,ZHENGTILIUCHENGHAISHISHIFENMINGLEDE。

KAISHI,PEIZHIXIANGGUANJICUNQIDESHUZHI,WANCHENGHOUQIDONGSocket - less MINGLING,QIDONGHOUZEPANDUANDUIDUANDEHUIYINGYUCHAOSHIDEPANDUAN。

ERZAIZHEIGEZHENGTILIUCHENGZHONG,ZUIZHUYAODENANDIANZAIYUJICUNQIPEIZHIBUFEN。


ER、GUANYUSocket - less ARP GONGNENGDEJICUNQI

WOMENZAISHIYONGSocket - less MINGLINGSHI,ZHIXUYAOPEIZHIYIXIAJICUNQIJIKEWANCHENGPINGGONGNENGDEDIAOYONG。

1.SLRTR(SOCKET - less ZHONGCHUANCHAOSHISHIJIANJICUNQI)

PEIZHIARPDECHAOSHIZHONGCHUANSHIJIANJIBENDANWEISHI100us,DANGGUOLESHIJIANZEHUIQIDONGZHONGCHUANJIZHI。

2.SLRCR(SOCKET - less ZHONGCHUANCISHUJICUNQI)

SHEDINGZHONGCHUANCISHU,RUODANGQIANZHONGCHUANCISHU >= ZHONGCHUANCISHU + 1SHI,ZEPANDINGWEITIMEOUT。

3.SLPIPR(SOCKET - less MUBIAOIPDIZHIJICUNQI)

YINGJIANARPDEMUBIAOIP。

4.SLIMR(SOCKET - less ZHONGDUANPINGBIJICUNQI)

XUANZEKAIQI/GUANBIPINGYUTIMEOUTZHONGDUAN。

5.SLCR(SOCKET-lessKONGZHIJICUNQI)

FASONGXIANGGUANQINGQIUDESHINENGJICUNQI。

DUIYUSHIYONGSOCKET - less MINGLING,XIANGGUANDEJICUNQIHAIYOUHENDUO,ZHEILIJINJIESHAOJIGEGUANYUYINGJIANPINGGONGNENGXIANGGUANDEJICUNQI。

GENGDUOXIANGXIDEW5100SXINXI,HUANYINGQIANWANGLIULANXIAZAI,ZILIAOLICHENGWOMENHUIBUDUANWANSHANGENGXIN。


SAN、XIANGGUANJICUNQIDEPEIZHIJISocket - less MINGLINGDIAOYONG

SHIYONGYINGJIANPINGSHIJINXUYAOSHEZHIZHEIJIGEXIANGGUANJICUNQIJIKE。JUTIPEIZHILIUCHENGRUXIADAIMA:

void hw_arp_init(void)
{
    setSLRTR(0x03E8);       // 重传超时时间设置:1000 * 100us
    setSLRCR(3);            // 重传次数设置:3次
    /* 使用中断时可开启该配置 */	
    setSLIMR(0x06);         // 中断开启 ARP & TIMEOUT
}

SHANGSHUDAIMASHIYONGYINGJIANARPGONGNENGSHI,WUTESHUYAOQIUNEIMESHEZHIYICIJIKE。SHEZHIXIANHOUSHUNXUBUZUOYAOQIU。

void hw_arp(void)
{
    setSLPIPR(hw_arp_ip);     // 目标IP设置:ARP对象IP
    setSLCR(0x02);            // 发送ARP请求
}

ZHEIBUFENDAIMAZAIXUYAOSHIYONGYICIYINGJIANARPGONGNENGSHI,JINXINGYICIDIAOYONG。

ERPANDUANARPDEJIEGUO,ZEKESHIYONGZHONGDUANJINXINGPANDUAN,CHAOSHIHAISHIXIANGYINGDOUHUIFASHENGCIZHONGDUAN,JUTIRUXIA:

switch(getSLIR())
{
    case 0x02:
        setSLIR(0x02);
        getSLPHAR(remote_mac);
        printf("
已收到来自 %d.%d.%d.%d 的ARP回应,其MAC地址%x:%x:%x:%x:%x:%x。",
        hw_arp_ip[0],hw_arp_ip[1],hw_arp_ip[2],hw_arp_ip[3],remote_mac[0],
        remote_mac[1],remote_mac[2],remote_mac[3],remote_mac[4],remote_mac[5]);
    break;
    case 0x04:
        setSLIR(0x04);
        printf("
%d.%d.%d.%d 无回复。",hw_arp_ip[0],hw_arp_ip[1],hw_arp_ip[2]
        ,hw_arp_ip[3]);
    break;
    default:break;
}

ZHONGDUANFASHENGHOU,GENJUARPDESLIRJICUNQIDESHUZHI,PANDUANDUIFANGSHIJIYUFANKUI,HAISHIYIJINGCHAOSHI。

SHANGSHUDAIMA,JUNSHIwww.w5100s.comNEI18.HW_ARPLICHENGNEIDE,GAILICHENGYIJINGGUOSHICE,YINGJIANARPGONGNENGZHENGCHANGSHIYONG。

ZHU:TIGONGDELICHENGSHIZHONGDUANFANGSHIPANDUANJIEGUO,YEKEXIECHENGLUNXUNXINGSHI,JUNKE。


SI、DAIMAYUNXINGJIEGUO

DIANNAOIP:192.168.1.100;MAC:54:E1:AD:E7:DF:C9

W5100S IP:192.168.1.233;MAC:00:08:DC:22:33:33

W5100S YUDIANNAOLIANJIEZAITONGYILUYOUQIXIA。

W5100S YINGJIANARP MUBIAO IP:192.168.1.100

新建位图图像.bmp

KEYIKANDAO,W5100SZIDAIDEYINGJIANARPGONGNENGHENJISHIHUOQUMUBIAOHUIFUQINGKUANG,HUOQUQIDUIYINGDEMACDIZHI。

LIYONGZHEIGEGONGNENG,YONGHUKEYIHENJISHIDEHUOQUDAOMUBIAOSHEBEIDEWULIDIZHI,GENGJISHIDEJINXINGSHUJUCHUANSHU。

ZHU:WUHUIFUSHI,SHIWOYIJIANGWANGXIANBALE。


WU、WiresharkWANGLUOFENGBAONEIRONG

新建位图图像.bmp