使得ns2支持BGP协议(测试成功)

Download ns-BGP version 2.0 for ns-2.33 here.

Unpack it in the "ns-allinone-2.33" directory:

 

> gzip -dc ns-2.33-bgp_2.0.tgz | ( cd ~/ns-allinone-2.33 ; tar xvf - )

 

This will:

  • create a patch file "ns-2.33-bgp_2.0_patch" in the "ns-allinone-2.33" directory
  • create a "bgp" subdirectory with all C++ files for BGP under the "ns-2.33" subdirectory
  • add new C++ files for TcpSocket under the "ns-2.33/tcp" subdirectory
  • create a "bgp" subdirectory with all TCL files for BGP under the "ns-2.33/tcl" subdirectory.

 

Apply the ns-BGP patch:

 

> cd ~/ns-allinone-2.33 ; patch -p0 < ns-2.33-bgp_2.0_patch

 

Recompiling ns-2

ns-2 then needs to be recompiled before the changes take effect:

 

> cd ~/ns-allinone-2.33/ns-2.33

> ./configure

> make clean ;

>  make

 

在这个过程中遇到很多的问题,主要问题描述为bgp的支持位C++语言的支持,而自己默认的Makefile对.cc文件都是调用gcc编译器进行解释,这个造成很多的库函数都早不到。

解决思路:

将bgp安装过程中产生的文件的后缀.cc改为.cpp

对一些缺少头文件的库函数根据需要去查找相应的头文件。

实例说明:

需要将#include <iostream.h>改为#include <iostream>

缺少atoi,sprintf等函数需要添加#include <stdio.h>

具体的问题去具体分析

 

煞费周折,大家有什么巧妙的思路可以回复说明。

 

Using ns-BGP in simulations

In order to use ns-BGP, turn on the BGP option with the node-config command in your OTcl scripts before creating BGP nodes:

 

$ns node-config -BGP ON

set n0 [$ns node 0:10.0.0.1] ;# creates a BGP node with AS number 0 and IP address 10.0.0.1

set n1 [$ns node 1:10.0.1.1]

set n2 [$ns node 1:10.0.2.1]

$ns node-config -BGP OFF

 

Configuring ns-BGP

Each BGP routing agent instance (one per BGP node) can be configured individually from OTcl:

 

set bgp_agent0 [$n0 get-bgp-agent] ;# gets the BGP routing agent

$bgp_agent0 bgp-id 10.0.0.1 ;# sets the BGP ID

$bgp_agent0 neighbor 10.0.1.1 remote-as 1 ;# establishes a BGP session with the router 10.0.1.1

$bgp_agent0 neighbor 10.0.2.1 remote-as 2

 

The available configuration commands for a BGP routing agent are:

 

$bgp_agent0 bgp-id 10.0.0.1 ;# BGP ID

$bgp_agent0 cluster-id 1000 ;# cluster number for route reflection

$bgp_agent0 connretry_time 120 ;# connection retrial time interval

$bgp_agent0 min_as_orig_time 15 ;# Minimum AS Origination Interval

$bgp_agent0 set-auto-config

$bgp_agent0 neighbor $ipaddress $command $cmd-value

 

The "set-auto-config" command enables a BGP routing agent to automatically find its potential BGP peers and configure these peers with default parameter values.

The "neighbor" command is used to configure each peer of a BGP routing agent:

 

$bgp_agent0 neighbor 10.0.1.1 remote-as 1

$bgp_agent0 neighbor 10.0.1.1 route-reflector-client ;# sets this peer as a route reflection client

$bgp_agent0 neighbor 10.0.1.1 hold-time 90 ;# Hold Timer value

$bgp_agent0 neighbor 10.0.1.1 keep-alive-time 30 ;# KeepAlive Timer value

$bgp_agent0 neighbor 10.0.1.1 mrai 30 ;# Minimum Route Advertisement Interval Timer value

 

Please note that no error checking is performed on the values of these variables. Changing them to strange or disallowed values will probably yield unexpected results. The default values can be found in the "ns-2.33/tcl/lib/ns-default.tcl" file.

In addition to individual configurations, we can also enable some BGP optional features, such as SSLD (sender-side loop detection) and rate_limit_by_dest (per-destination rate-limiting), in the "ns-2.33/bgp/global.h" file. These settings in the global.h file will affect all BGP routing agents in an ns-BGP simulation.

After configuring the BGP routing agents, three run-time commands can be executed during ns-BGP simulations:

 

$bgp_agent0 network 10.0.0.0/24 ;# originates a network prefix

$bgp_agent0 no-network 10.0.0.0/24 ;# withdraws a network prefix

$bgp_agent0 show-routes ;# displays the content of routing tables

 

A set of validation test scripts can be found in the "ns-2.33/tcl/bgp/test" directory.  

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值