【正文】
ge being displayed by his web browser. Bob’s web browser begins the process by creating a TCP socket that will be used to send the HTTP request to . In order to create the socket, Bob’s laptop will need to know the IP address of . We learned that the DNS protocol is used to provide this nametoIPaddress translation service. Bob 的電腦接收到包含 DHCP ACK 的幀,一層層解封裝之后得到 DHCP ACK 報文。 6. The Ether frame containing the DHCP ACK is sent (unicast) by the router to the switch. Because the switch is selflearning and previously received an Ether (containing the DHCP request) from Bob’s laptop, the switch knows to forward a frame addressed to 00:16:D3:23:68:8A only to the output port leading to Bob’s laptop. 包含 DHCP ACK 的 以太網(wǎng)幀從路由器發(fā)送到交換機。 DHCP 報文封裝在 UDP 數(shù)據(jù)報中, UDP 數(shù)據(jù)報又封裝在 IP 報文中, IP 報文封裝在以太網(wǎng)幀中進行傳輸。 我們假設 DHCP 服務器分配給 Bob 的電腦的 IP 是 。 5. Let’s suppose that the DHCP server running within the router can allocate IP addresses in the CIDR block In this example, all IP addresses used within the school are thus within Comcast’s address block. Let’s suppose the DHCP server allocates address to Bob’s laptop. The DHCP server creates a DHCP ACK message containing this IP address, as well as the IP address of the DNS server (), the IP address for the default gateway router (), and the sub block () (equivalently, the “work mask”). The DHCP message is put inside a UDP segment, which is put inside an IP datagram, which is put inside an Ether frame. The Ether frame has a source MAC address of the router’s interface to the home work 22 (00:22:6B:45:1F:1B) and a destination MAC address of Bob’s laptop (00:16:D3:23:68:8A). 我們假設在路由器上運行的 DHCP 服務器能用 。 該報文的廣播的 IP 目的地址表明本 IP 數(shù)據(jù)報應該由上層協(xié)議在這個節(jié)點上進行處理,所以該數(shù)據(jù)報的有效載荷(一個 UDP 報文)向上分用給 UDP,然后 DHCP 請求報文從 UDP 報文中提取。 交換機廣播所有來自輸出端口的傳入幀,包括連接到路由器的端口上的。 the frame’s source MAC address is that of Bob’s laptop, 00:16:D3:23:68:8A. IP 數(shù)據(jù)報包含 DHCP 的發(fā)送請求報文,然后封裝在以太網(wǎng)幀中。 UDP 報文封裝在 IP 數(shù) 據(jù)報內(nèi)以源 IP 地址( ),全網(wǎng)廣播出去,現(xiàn)在 Bob 的電腦依然上不了網(wǎng)。 當 Bob 第一次聯(lián)網(wǎng)時,他不能做任何事假如沒有 IP 地址,因此,第一次網(wǎng)絡關聯(lián)的舉動就是運行 DHCP 來獲得 IP 地 址,也包括其他的一些信息。 Getting Started : DHCP ,UDP, IP, and Ether 讓我們來假設 Bob 啟動他的筆記本然后連上以太網(wǎng)連接到學校的以太網(wǎng)交換機,這些交換機輪流連到學校的路由器,像上圖顯示的一樣 學校的路由器連到 ISP,如電信,電信為學校提供 DNS 服務,因此, DNS服務器存在于電信聯(lián)盟的網(wǎng)絡上而不是學校網(wǎng)絡。 last_seqno=i。 從第二個分組開始 } 計算抖動 printf(%d %.8f\n,i,jitter)。 i++) { if(delay[i]!=0) { if(last_delay==0) { jitter=0。 for(i=0。 用一個數(shù)組保存每個分組的延遲時間 } } last_delay=0。 end = end_time[i]。 i=highest_uid。 更新 highes_uid 的值 } END { id=1。 pkt_type==cbr) end_time[uid] = time。 to_node==0 amp。 } else { if(event==r amp。amp。amp。amp。 uid = $12。 pkt_size = $6。 to_node =$4。 pkt_size = $8。 uid = $6。 trace_type = $4。 len = length(node)。 time = $2。 打印吞吐量信息 } 18 、 文件 BEGIN { highest_uid=0。 } } } END{ th =8*pkt_byte_sum[i1]/(end_time[i1]start_time)/1000。 } end_time[i]=time。 計算已接收的數(shù)據(jù)字節(jié) if(init==0) { start_time=time。amp。amp。 uid = $12。 pkt_size = $6。 to_node = $4。 pkt_size = $8。 uid = $6。 trace_type = $4。 len = length(node)。 time = $2。 i=0。 打印節(jié)點 delay=delay+(end start)。 delay=end start。i++) { start=start_time[i]。 for(i=0。 更新 highest_uid 的值 } END { id=1。amp。amp。amp。 highest_uid==uid) end_time[uid]=time。 pkt_type==cbr amp。 to_node==0 amp。 源節(jié)點是無線節(jié)點 2,保存源節(jié)點發(fā)送分組的時間 } else { 如果分析的是有線 trace 記錄 if(event==r amp。amp。amp。amp。 uid=$12。 有線 trace 第 5 個字段 $5 為分組的類型 pkt_size=$6。 有線 trace 第 3 個字段 $3 為分組的源節(jié)點 to_node=$4。 無線 trace 第 7 個字段 $7 為分組的類型 pkt_size=$8。 uid=$6。 獲取節(jié)點號 trace_type=$4。 第二個字段 $2 標識事件發(fā)生的時間 node=$3。 highest_uid 會保存一處理過的分組中最大的 uid } { event=$1。 。清空跟蹤的緩沖區(qū) close $tracefd 。 $ns_ halt stop 過程 proc stop {} { global ns_ tracefd namtracefd 。 $tcp set class_ 2 創(chuàng)建分組的接收代理對象 sink set sink [new Agent/TCPSink] 將源代理對象 tcp 綁定到節(jié)點 0 $ns_ attachagent $node_(0) $tcp 將接收代理對象 sink 綁定到節(jié)點 1 $ns_ attachagent $node_(1) $sink 在源代理對象 tcp 和接收代理對象 sink 之間建立連接 $ns_ connect $tcp $sink 在 TCP 連接上創(chuàng)建一個 FTP 流 量模擬器,因為 TCP 不會產(chǎn)生自己的流量 set ftp [new Application/FTP] $ftp attachagent $tcp 在 啟動 ftp 流量模擬器 $ns_ at $ftp start 模擬結(jié)束時告知節(jié)點 for {set i 0} {$i $val(nn) } {incr i} { 在模擬結(jié)束前 ()重置節(jié)點中的所有對象 $ns_ at $node_($i) reset。 } 為移動節(jié)點指定初始的 X, Y 坐 標,此處 Z 坐標為 0 $node_(0) set X_ $node_(0) set Y_ $node_(0) set Z_ $node_(1) set X_ $node_(1) set Y_ $node_(1) set Z_ 下面產(chǎn)生一些簡單的運動 Node_(1)在 ,以 (,)運動 $ns_ at $node_(1) setdest Node_(0)在 ,以 (,)運動 $ns_ at $node_(0) setdest Node_(1)在 ,以 (,)運動 $ns_ at $node_(1) setdest 設置節(jié)點間的流量 創(chuàng)建一個 TCP 源代理對象 tcp set tcp [new Agent/TCP] class_是 agent 類中定義的整型變量 ,用于分類,之后可用于著色。 creategod $val(nn) 建立指定數(shù)目 [$val(nn)]的移動節(jié)點并將它們連接至信道。 God 對象主要用來對路由協(xié)議做性能評價,它存儲了節(jié)點總數(shù),節(jié)點間最短路徑等信息。 拓撲的 X 尺寸(單位 m) set val(y) 500 。 移動節(jié)點個數(shù) set val(rp) DSDV 。 天線類型為全向天線 set val(ifqlen) 50 。 MAC 層采用 協(xié)議 set val(ifq) Queue/DropTail/PriQueue 。 無限信號傳輸模型 set val(if) Phy/WirelessPhy 。 set val(chan) Channel/WirelessChannel 。開始運行 、 NAM 動畫演示 10 11 12 、流量分析(曲線模擬) 分析:從 執(zhí)行的是慢啟動過程,之后執(zhí)行的擁塞控制過程。 的時候開始