目录
💥1 概述
📚2 运行结果
🎉3 参考文献
👨💻4 Matlab代码
💥1 概述
与陆地多跳传感器网络类似,水下网络的路由协议可以分为:①主动路由,②按需路由。
①主动路由(又被称为表驱动(table-driven)):在该路由协议中,网络中每个节点都要建立并维护一个路由表,用于记录该节点到网络中其他所有节点的路由信息,并根据网络当前状态进行更新。
主动路由的缺点:
①路由第一次建立、节点移动或节点失效导致路由重新建立连接会造成较大的网络开销。
②路由表的建立和维护会造成巨大的网络开销,节点频繁移动,网络拓扑的动态变化更是会加剧这种状况。
主动路由的路由信息主要是从基站周期性广播的控制包中获得的,主要包含DSDV(destination sequenced distance vector),WRP(wireless routing protocol)和OLSR(optimized link state routing)等。
② 按需路由(被动式(反应)路由):网络节点无需建立并维护去往其它节点的路由信息,而是根据通信需要临时建立路由。只有当源节点要向目的节点发送消息时,源节点才进行路由的查找和建立。路由建立后,将由一个专门的路由维护程序进行维护,直到该路由失去作用。 主要包含DSR,AODV和TORA。
按需路由协议的路由表根据通信需要而临时建立,基站不需要周期性广播路由信息。建立好的路由会保存在缓存中供后续通信使用,而无需节点维护,这降低了网络开销,减小网络资源的浪费,更适用于拓扑动态变化的网络。
📚2 运行结果
主函数部分代码:
% close and clear everything running in the command window clc; clear all; close all; % Initialize transmission range transRange = 250; % Initialize number of nodes numNodes = 100; % Initialize minimum range of x,y,z co-ordinates of the network plot00000 min.x = 0; min.y = 0; min.z = 0; % Initialize maximum range of x,y,z co-ordinates of the network plot max.x = 1000; max.y = 1000; max.z = -1000; % Initialize x,y,z co-ordinates for six sinks including two embedded sinks % embedded sink 1 sink(1,1)=250; sink(1,2)=250; sink(1,3)=0; % embedded sink 2 sink(2,1)=250; sink(2,2)=0; sink(2,3)=250; % sink 3 sink(3,1)=100; sink(3,2)=1000; sink(3,3)=100; % sink 4 sink(4,1)=250; sink(4,2)=1000; sink(4,3)=250; % sink 5 sink(5,1)=750; sink(5,2)=100; sink(5,3)=500; % sink 6 sink(6,1)=500; sink(6,2)=500; sink(6,3)=500; % Plot nodes randomly using createNodes function nodePositions = createNodes(min, max, numNodes); plot3(nodePositions(:, 1), nodePositions(:, 2),nodePositions(:, 3), '+'); hold on % Plot sink nodes plot3(sink(1, 1), sink(1, 2), sink(1, 3), 'S', 'MarkerFaceColor', 'y'); plot3(sink(2, 1), sink(2, 2), sink(2, 3), 'S', 'MarkerFaceColor', 'y'); plot3(sink(3, 1), sink(3, 2), sink(3, 3), 'S', 'MarkerFaceColor', 'r'); plot3(sink(4, 1), sink(4, 2), sink(4, 3), 'S', 'MarkerFaceColor', 'r'); plot3(sink(5, 1), sink(5, 2), sink(5, 3), 'S', 'MarkerFaceColor', 'r'); plot3(sink(6, 1), sink(6, 2), sink(6, 3), 'S', 'MarkerFaceColor', 'r'); % Initialize lost packets and average time taken for one packet delivery as zero lostPackets = 0; avgTime = 0; % Initialize t1 to current starting time t1 = clock; % loop for transmitting one packet from each node to a sink node % for i = 1 to numNodes for i=1:numNodes % Initialize an empty list for visited nodes visitedNodes = []; % Initialize source as ith node and forwarder node as the source source = i; forwarder = source; fprintf('Node %d \n', i); % find the route of the packet from the ith node to any of the sink node using the function % find_route function returns neighbours of the given node, delivery status (success/failure) and nearest node of the neighbors, this function takes forwarder node, sink nodes, transmission range, number of nodes, nodes positions and visited nodes list as parameters [neighbours, success, nearestNode] = find_route (forwarder, sink, transRange, numNodes, nodePositions, visitedNodes); % Add source to visited nodes list visitedNodes(end+1) = source; % if the ith node could not find a sink node in its transmission range % while packet status is undelivered or neighbors list is empty while (success == 0 || isempty(neighbours) == 0) % change forwarder to the nearest node obtained previously forwarder = nearestNode; % if forwarder is unreachable, packet is said to be lost and break the loop if (forwarder == Inf) success = 0; disp('Packet Lost') lostPackets = lostPackets + 1; break; end % Add forwarder node to visited nodes list visitedNodes(end+1) = forwarder; % Find the route for the ith packet from the new forwarder to any of the sinks [neighbours, success, nearestNode] = find_route (forwarder, sink, transRange, numNodes, nodePositions, visitedNodes); end
🎉3 参考文献
[1]张剑,黄本雄,张帆,涂来.一种适合水下无线传感器网络的能量有效路由协议[J].计算机科学,2008(01):38-41+195.
部分理论引用网络文献,若有侵权联系博主删除。