物联网实验报告Word文档下载推荐.docx

上传人:b****1 文档编号:1437758 上传时间:2023-04-30 格式:DOCX 页数:9 大小:1.20MB
下载 相关 举报
物联网实验报告Word文档下载推荐.docx_第1页
第1页 / 共9页
物联网实验报告Word文档下载推荐.docx_第2页
第2页 / 共9页
物联网实验报告Word文档下载推荐.docx_第3页
第3页 / 共9页
物联网实验报告Word文档下载推荐.docx_第4页
第4页 / 共9页
物联网实验报告Word文档下载推荐.docx_第5页
第5页 / 共9页
物联网实验报告Word文档下载推荐.docx_第6页
第6页 / 共9页
物联网实验报告Word文档下载推荐.docx_第7页
第7页 / 共9页
物联网实验报告Word文档下载推荐.docx_第8页
第8页 / 共9页
物联网实验报告Word文档下载推荐.docx_第9页
第9页 / 共9页
亲,该文档总共9页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

物联网实验报告Word文档下载推荐.docx

《物联网实验报告Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《物联网实验报告Word文档下载推荐.docx(9页珍藏版)》请在冰点文库上搜索。

物联网实验报告Word文档下载推荐.docx

进程的主体函数从这里开始

PROCESS_END()

进程的主体函数从这里结束

2.实验过程及结果

编译hello_world

仿真节点的运行

实验三

1.程序分析:

UDPsever

初始化RPLDAG

//检查ADDR_MANUAL是否已经成功设置

uip_ds6_addr_add(&

ipaddr,0,ADDR_MANUAL);

root_if=uip_ds6_addr_lookup(&

ipaddr);

if(root_if!

=NULL){

rpl_dag_t*dag;

//将服务器的IP地址作为初始DAG的根

dag=rpl_set_root(RPL_DEFAULT_INSTANCE,(uip_ip6addr_t*)&

uip_ip6addr(&

ipaddr,0xaaaa,0,0,0,0,0,0,0);

rpl_set_prefix(dag,&

ipaddr,64);

PRINTF("

createdanewRPLdag\n"

);

}else{

failedtocreateanewRPLDAG\n"

}

创建UDP连接

//向客户端的端口创建新的UDP连接

server_conn=udp_new(NULL,UIP_HTONS(UDP_CLIENT_PORT),NULL);

if(server_conn==NULL){

NoUDPconnectionavailable,exitingtheprocess!

\n"

PROCESS_EXIT();

udp_bind(server_conn,UIP_HTONS(UDP_SERVER_PORT));

PRINTF("

Createdaserverconnectionwithremoteaddress"

PRINT6ADDR(&

server_conn->

ripaddr);

local/remoteport%u/%u\n"

UIP_HTONS(server_conn->

lport),

UIP_HTONS(server_conn->

rport));

包的接受和处理

while

(1){

PROCESS_YIELD();

//如果有包

if(ev==tcpip_event){

tcpip_handler();

}elseif(ev==sensors_event&

&

data==&

button_sensor){

Initiaingglobalrepair\n"

rpl_repair_root(RPL_DEFAULT_INSTANCE);

}

//如果有包,调用这个函数

staticvoid

tcpip_handler(void)

{

char*appdata;

if(uip_newdata()){

appdata=(char*)uip_appdata;

appdata[uip_datalen()]=0;

//printthedataofpacket

DATArecv'

%s'

from"

appdata);

%d"

UIP_IP_BUF->

srcipaddr.u8[sizeof(UIP_IP_BUF->

srcipaddr.u8)-1]);

UDPClient:

建立UDP连接

/*远程主机的新连接*/

client_conn=udp_new(NULL,UIP_HTONS(UDP_SERVER_PORT),NULL);

if(client_conn==NULL){

udp_bind(client_conn,UIP_HTONS(UDP_CLIENT_PORT));

Createdaconnectionwiththeserver"

client_conn->

UIP_HTONS(client_conn->

lport),UIP_HTONS(client_conn->

发包

//根据SEND_INTERVAL设置时间间隔

etimer_set(&

periodic,SEND_INTERVAL);

//每个时间间隔就发一个包

if(etimer_expired(&

periodic)){

etimer_reset(&

periodic);

ctimer_set(&

backoff_timer,SEND_TIME,send_packet,NULL);

send_packet(void*ptr)

staticintseq_id;

charbuf[MAX_PAYLOAD_LEN];

seq_id++;

DATAsendto%d'

Hello%d'

server_ipaddr.u8[sizeof(server_ipaddr.u8)-1],seq_id);

sprintf(buf,"

Hello%dfromtheclient"

seq_id);

//通过client_conn向UDP服务器发包

uip_udp_packet_sendto(client_conn,buf,strlen(buf),

&

server_ipaddr,UIP_HTONS(UDP_SERVER_PORT));

2.实验过程及结果:

编译/examples/ipv6/rpl-udp目录下的udp-server.c和udp-client.c

运行Cooja仿真环境

3.问题:

1.问:

节点获取ip地址了吗?

是什么?

获取了IP地址,为fe80:

0000:

:

0212:

7408:

0008:

0808;

2.节点之间有通讯吗?

有通讯,因为有DATAsend

3.udp-server收到其他节点发给它的packet了吗?

收到了,因为有DATArecv

4.节点执行dutycycle了吗?

节点执行了dutycircle

实验收获及问题

通过本次实验,加深了对物联网系统的理解,激发了我对物联网的兴趣,给我打开了一扇崭新的大门,让我看到了未来世界的无线可能。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2