资源简介
使用opnet仿真软件仿真AODV路由,对于初学者能起到帮助作用
代码片段和文件信息
/***************************************************************************
aodv_dev.c - description
-------------------
begin : Thu Aug 7 2003
copyright : (C) 2003 by Luke Klein-Berndt
email : kleinb@nist.gov
***************************************************************************/
#include “aodv_dev.h“
//extern char *g_aodv_dev;
extern char g_aodv_dev[8];
extern aodv_route *g_my_route;
extern u_int32_t g_my_ip;
aodv_dev *aodv_dev_list;
aodv_dev *create_aodv_dev(struct net_device *dev struct in_ifaddr *ifa)
{
aodv_dev *new_dev;
aodv_route *tmp_route;
tmp_route = create_aodv_route(ifa->ifa_address);
tmp_route->ip = ifa->ifa_address;
//tmp_route->netmask = calculate_netmask(0); //ifa->ifa_mask;
tmp_route->self_route = 1;
tmp_route->seq = 1;
tmp_route->old_seq = 0;
tmp_route->rreq_id = 1;
tmp_route->metric = 0;
tmp_route->next_hop = tmp_route->ip;
tmp_route->lifetime = -1;
tmp_route->route_valid = 1;
tmp_route->route_seq_valid = 1;
tmp_route->dev = dev;
if ((new_dev = (aodv_dev *) kmalloc(sizeof(aodv_dev) GFP_ATOMIC)) == NULL)
{
/* Couldn‘t create a new entry in the routing table */
printk(KERN_WARNING “AODV: Not enough memory to create Route Table Entry\n“);
return NULL;
}
new_dev->ip = tmp_route->ip;
new_dev->netmask = ifa->ifa_mask;
new_dev->route_entry = tmp_route;
new_dev->dev = dev;
new_dev->next=NULL;
g_my_route = tmp_route;
g_my_ip = g_my_route->ip;
insert_kernel_route_entry(tmp_route->ip tmp_route->next_hop tmp_route->netmask dev->name);
return new_dev;
}
int insert_aodv_dev(struct net_device *dev)
{
aodv_dev *new_dev;
int success=0 error=0;
struct in_ifaddr *ifa;
struct in_device *in_dev;
char netmask[16];
read_lock(&in_dev->lock);
if ((in_dev=__in_dev_get(dev)) == NULL)
{
return 0;
}
read_lock(&in_dev->lock);
for_primary_ifa(in_dev)
{
if ((strcmp(g_aodv_dev““)!=0) && (strncmp(dev->name g_aodv_dev IFNAMSIZ) == 0))
{
if (ifa==NULL)
{
return success;
}
new_dev = create_aodv_dev(dev ifa);
strcpy(netmask inet_ntoa(new_dev->netmask & new_dev->ip));
printk(KERN_INFO “INTERFACE LIST: Adding interface: %s IP: %s Subnet: %s\n“ dev->name inet_ntoa(ifa->ifa_address) netmask);
strncpy(new_dev->name dev->name IFNAMSIZ);
new_dev->next = aodv_dev_list;
aodv_dev_list = new_dev;
error = sock_create(PF_INET SOCK_DGRAM 0 &(new_dev->sock));
if (error < 0)
{
kfree(new_dev);
read_unlock(&in_dev->lock);
printk(KERN_ERR “Error during creation of socket; terminating %d\n“ error);
return err
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
----------- --------- ---------- ----- ----
158842 51
- 上一篇:数电面试题-全!
- 下一篇:STC8+MPU6050+BMP280飞控原理图
相关资源
- opnet
- opnet包交换网络.
- modifyFiles.zip
- Opnet Modeler 11.5安装包及算号器
- OPNET一个移动无线网络仿真
- opnet实现简单aloha和csma
- LEO卫星通信OPNET网络仿真
- 基于OPNET仿真案例
- 基于OPNET的无线传感器网络仿真
- csma_ca opnet
- opnet加强的mm1模型
- opnet可用的mm1模型
- 可用的包交换网络opnet14.5
- OPNET-TDMA仿真.zip
- OPNET无线网络仿真
- opnet adov 仿真
- opnet无线仿真模型及程序
- OPNET 仿真cdma
- opnet中进行TDMA仿真
- OPNET s_aloha仿真
- OPNET路由DIjkstra实现跳数与队列延时代
- opnet的flood泛洪路由实现
- OPNET安装合集:OPNET14.5+vs2010+安装视频
- OPNET14.5安装教程
- MM1 OPNET实验
- opnet种子
- opnet 14.5 包交换网络仿真教程
- RIP协议的OPNET仿真
- 基于OPNET的TDMA多路访问技术仿真研究
- IEEE802.15.4_opnet_simulation_model_v2.0
评论
共有 条评论