NS2.35內建的衛星網路模擬學習

來源:互聯網
上載者:User

看了那麼多論文之後,現在應該開始實際模擬了!!!

首先,NS2.35內建iridium和teledesic的星座配置,在ns/tcl/ex下,先看一下iridium的

下表是iridium星座的參數:

相鄰軌道面plane的間隔是31.6°,縫隙處是22°,不是均勻的

每個軌道面11顆星,所以360/11=32.73°

不同軌道面的相位因子360/66=5.454545,16.36/5.454545=3,正好是軌道面內相位差的一半

Ns/tcl/ex中的例子將node和link單獨獨立為兩個檔案,node檔案部分內容如下:

set plane 1set n0 [$ns node]; $n0 set-position $alt $inc 0 0 $planeset n1 [$ns node]; $n1 set-position $alt $inc 0 32.73 $plane set n2 [$ns node]; $n2 set-position $alt $inc 0 65.45 $plane set n3 [$ns node]; $n3 set-position $alt $inc 0 98.18 $planeincr plane  set n15 [$ns node]; $n15 set-position $alt $inc 31.6 16.36 $plane set n16 [$ns node]; $n16 set-position $alt $inc 31.6 49.09 $plane set n17 [$ns node]; $n17 set-position $alt $inc 31.6 81.82 $plane

地面終端會不停的切換,為了讓切換髮生更優,nodetcl中設定的next衛星,為同軌道面下一顆衛星,這裡應該是假定了位置0處的衛星是上升軌道

# By setting the next_ variable on polar sats; handoffs can be optimized$n0 set_next $n10; $n1 set_next $n0; $n2 set_next $n1; $n3 set_next $n2$n4 set_next $n3; $n5 set_next $n4; $n6 set_next $n5; $n7 set_next $n6$n8 set_next $n7; $n9 set_next $n8; $n10 set_next $n9$n15 set_next $n25; $n16 set_next $n15; $n17 set_next $n16; $n18 set_next $n17$n19 set_next $n18; $n20 set_next $n19; $n21 set_next $n20; $n22 set_next $n21$n23 set_next $n22; $n24 set_next $n23; $n25 set_next $n24

節點設定好後,在linktcl中設定衛星鏈路,包括軌內和軌間星間鏈路

# Now that the positions are set up, configure the ISLs# Plane 1 intraplane$ns add-isl intraplane $n0 $n1 $opt(bw_isl) $opt(ifq) $opt(qlim)$ns add-isl intraplane $n1 $n2 $opt(bw_isl) $opt(ifq) $opt(qlim)$ns add-isl intraplane $n2 $n3 $opt(bw_isl) $opt(ifq) $opt(qlim)# Interplane ISLs# 2 interplane ISLs per satellite (one along the seam)# Plane 1-2$ns add-isl interplane $n0 $n15 $opt(bw_isl) $opt(ifq) $opt(qlim)$ns add-isl interplane $n1 $n16 $opt(bw_isl) $opt(ifq) $opt(qlim)$ns add-isl interplane $n2 $n17 $opt(bw_isl) $opt(ifq) $opt(qlim)

主tcl檔案中設定參數:

global optset opt(chan)           Channel/Satset opt(bw_down)        1.5Mb; # Downlink bandwidth (satellite to ground)set opt(bw_up)          1.5Mb; # Uplink bandwidthset opt(bw_isl)         25Mbset opt(phy)            Phy/Satset opt(mac)            Mac/Satset opt(ifq)            Queue/DropTailset opt(qlim)           50set opt(ll)             LL/Satset opt(wiredRouting) OFFset opt(alt)            780; # Polar satellite altitude (Iridium)set opt(inc)            86.4; # Orbit inclination w.r.t. equator

設定地面終端節點:

# Set up terrestrial nodes$ns node-config -satNodeType terminalset n100 [$ns node]$n100 set-position 37.9 -122.3; # Berkeleyset n101 [$ns node]$n101 set-position 42.3 -71.1; # Boston

增加星地鏈路,這裡地面終端節點與那個衛星節點串連可以任意,因為切換管理器會重新設定為地面終端可見的衛星節點。

# Add GSL links# It doesn't matter what the sat node is (handoff algorithm will reset it)$n100 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \  $opt(phy) [$n0 set downlink_] [$n0 set uplink_]$n101 add-gsl polar $opt(ll) $opt(ifq) $opt(qlim) $opt(mac) $opt(bw_up) \  $opt(phy) [$n0 set downlink_] [$n0 set uplink_]

配置地面終端為CBR-UDP流量

# Attach agentsset udp0 [new Agent/UDP]$ns attach-agent $n100 $udp0set cbr0 [new Application/Traffic/CBR]$cbr0 attach-agent $udp0$cbr0 set interval_ 60.01

這是產生的trace檔案的內容:

+ 1.000066 26 cbr 210 ------- 0 66.0 67.0 00 37.90 -122.30 48.90 -120.94

- 1.000066 26 cbr 210 ------- 0 66.0 67.0 0 0 37.90 -122.30 48.90 -120.94

r 1.006366 26 cbr 210 ------- 0 66.0 67.0 0 0 37.90 -122.30 48.90 -120.94

+ 1.0063 26 37 cbr 210 ------- 0 66.0 67.0 0 0 48.90-120.94 32.60 -87.51

- 1.0063 26 37 cbr 210 ------- 0 66.0 67.0 0 0 48.90-120.94 32.60 -87.51

r 1.0186 26 37 cbr 210 ------- 0 66.0 67.0 0 0 48.90-120.94 32.60 -87.51

+ 1.0186 37 48 cbr 210 ------- 0 66.0 67.0 0 0 32.60-87.51 48.90 -57.74

- 1.0186 37 48 cbr 210 ------- 0 66.0 67.0 0 0 32.60-87.51 48.90 -57.74

r 1.0300 37 48 cbr 210 ------- 0 66.0 67.0 0 0 32.60-87.51 48.90 -57.74

+ 1.0300 48 67 cbr 210 ------- 0 66.0 67.0 0 0 48.90 -57.74 42.30 -71.10

- 1.0300 48 67 cbr 210 ------- 066.0 67.0 0 0 48.90 -57.74 42.30 -71.10

r 1.0364 48 67 cbr 210 ------- 0 66.0 67.0 0 0 48.90 -57.74 42.30-71.10

+ 31.0100 66 26 cbr 210 ------- 0 66.067.0 1 1 37.90 -122.30 47.12 -120.81

- 31.0100 66 26cbr 210 ------- 0 66.0 67.0 1 1 37.90 -122.30 47.12 -120.81

r 31.0157 66 26cbr 210 ------- 0 66.0 67.0 1 1 37.90 -122.30 47.12 -120.81

+ 31.0157 26 37cbr 210 ------- 0 66.0 67.0 1 1 47.12 -120.81 30.81 -87.48

- 31.0157 26 37cbr 210 ------- 0 66.0 67.0 1 1 47.12 -120.81 30.81 -87.48

r 31.0282 26 37cbr 210 ------- 0 66.0 67.0 1 1 47.11 -120.81 30.81 -87.48

每次路徑都是66-26-37-48-67,難道用的是虛擬節點策略?手冊裡也沒有提及啊?

 

 這是時延的繪圖,呈現周期性,為什麼不同時刻時延不一樣呢?

下面看看NS2中衛星的座標系統,在satgeometry.h, .cc中,首先定義了一些常數和計算宏

// Various constants#define PI 3.1415926535897#define MU 398601.2 // Greek Mu (km^3/s^2)#define LIGHT 299793 // km/s#define EARTH_PERIOD 86164 // seconds#define EARTH_RADIUS 6378  // km#define GEO_ALTITUDE 35786 // km#define ATMOS_MARGIN 150 // km#define DEG_TO_RAD(x) ((x) * PI/180)#define RAD_TO_DEG(x) ((x) * 180/PI)#define DISTANCE(s_x, s_y, s_z, e_x, e_y, e_z) (sqrt((s_x - e_x) * (s_x - e_x) \                + (s_y - e_y) * (s_y - e_y) + (s_z - e_z) * (s_z - e_z)))座標系統採用了極座標系struct coordinate {        double r;        // km        double theta;    // radians        double phi;      // radians        // Convert to cartesian as follows:        // x = rsin(theta)cos(phi)        // y = rsin(theta)sin(phi)        // z = rcos(theta)};

有兩套球面座標系統,一套是軌道為中心的,這裡的theta是90-的theta,才是真正的球面座標系統。

SatGeometry中定義了一些方法,比如計算距離,極座標和直角座標轉換,計算傳播延時,擷取經緯度高度,驗證仰角是否在最低仰角之上,驗證兩顆同高度衛星是否可見(考慮地球大氣層的遮擋150km)

Command方法是從OTCL訪問C++類的方法。

// Library of routines involving satellite geometryclass SatGeometry : public TclObject {public:SatGeometry() { printf("Started\n");}static double distance(coordinate, coordinate);              static void spherical_to_cartesian(double, double, double,    double &, double &, double &);static double propdelay(coordinate, coordinate);static double get_latitude(coordinate);static double get_longitude(coordinate);static double get_radius(coordinate a) { return a.r; }static double get_altitude(coordinate);static double check_elevation(coordinate, coordinate, double);static int are_satellites_mutually_visible(coordinate, coordinate);protected: // Define "command" appropriately if you want OTcl access to this class        int command(/*int argc, const char*const* argv */) { return 0; }};

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.