**PROJECT VIDEO**

__ABSTRACT__

In this paper, we are working to reduce the number of integrating points in a hybrid optical wireless sensor network. We are given an area with randomly deployed sensor nodes and all the nodes will be divided in the form of several zones. Each zone will be represented by an integrating point. This point (node) manages all the communication in the respective zone. Our algorithm works on reducing the total number of integrating points and providing better results even with less number of zone representatives.

__INTRODUCTION__

The hybrid optical and wireless networks have been proposed as a promising approach to meet the increasing demand for higher bandwidth requirement, provide broadband and ubiquitous high-speed internet access, and address the growing gap between core network and local area network (last mile problem) effectively[1–6]. This hybrid system consists of a wireless network at the front end, and it is supported by an optical network at the backend. As a promising wire line solution to broadband access, optical network provides much better reliable transmission and much higher bandwidth in Gbps-scale compared with wireless networks as well as covering long distance (around 20 km) from the telecom central ofﬁce (CO) to end users. However, the ﬁxed infrastructure not only limits its coverage in a high densely populated area due to the high cost of ﬁber layout and equipments, but also makes it difficult to deploy in certain rugged environment. On the other hand, wireless networks support mobility and provide ubiquitous access for end users in the metropolitan area or the local area. However, wireless networks provide limited bandwidth compared with the optical ﬁber networks. Thus, integrating the optical and the wireless networks together can utilize their complementary advantages to provide better service for end users and increase revenue for the service providers. The optical part can choose passive optical network (PON) [5]technologies, such as EPON, GPON, and the wireless part usually choose WiFi or WiMAX. In this paper, we choose the EPON [7]standard IEEE 802.3ah as the optical part and consider the IEEE802.16–2004 standard of WiMAX [8] technology as the wireless part, since EPON can utilize the existing Ethernet infrastructure providing low cost and simplicity deployment, and WiMAX covers longer distance and provides higher data rates up to 1 Gb/s compared with WiFi technology, and supports both point-to multi point mode and mesh mode [8]. Fig. 1 illustrates the architecture of hybrid optical-wireless system. EPON uses a tree topology where the optical line terminal (OLT) located at the telecom CO connects multiple optical network units (ONUs) through the passive splitter. In the wireless part, WiMAX base stations (BSs) are grouped into clusters. Within each cluster, one WiMAX BS is selected as the gateway to combine with one ONU as the integrated point of the hybrid network and the rest of WiMAX BSs in the cluster referred as relay stations form a multi-hop wireless mesh network. These integrated points are the locations where the wireless part and optical part meet together. In data transmissions, amend user sends the packets to its closest relay station and this relay station forwards the packets to the integrated point through one hop or multi-hops in the cluster. Then integrated point will forward the packets to the OLT through the optical connection and ﬁnallyto the core network. If the receiver resides in the hybrid optical-wireless network, the data ﬂows in the reverse directions described above. When developing the hybrid optical-wireless network, we need to address several issues including placement of integrated points, resource allocation and scheduling, routing protocol design, etc., in order to make the whole system work efﬁciently with the minimum system cost. In this paper, we mainly focus on the integrated points placement problem. Given a wireless network topology, we aim to minimize the number of integrated points (or clusters that each cluster has one integrated point to support the rest of wireless relay stations within the cluster) to lower the ﬁber layout cost, equipment’s cost and installation cost, while still maintaining the network connectivity and satisfying the constraints including hop count, cluster size and relay load. This kind of problem can be modeled as a mixed integer linear programming problem, which is NPhardin general [16,17]. Thus, we aim to develop an efﬁcient heuristic algorithm in this paper to obtain the near-optimal solution.Most of the existing works are trying to form clusters one by one as large as possible, the differences are where they form each cluster at each round and how large each cluster should be. This may result in the clusters with unbalanced load or large hop count,that is, some clusters may have very densely deployed nodes with one-hop away to the integrated point in some area in the network and some clusters may have just a few nodes but with large hop count in other area in the network. In [9], we propose a modiﬁed clustering algorithm (MCA) to achieve load balancing while minimizing the number of integrated points to cover all the wireless nodes. In this paper, we augment the MCA into a multi-stage algorithm called S2U (Selection-Shift-Update) algorithm that can well approximate the optimal integrated points placement under multiple constraints including hop count, cluster size, and relay load.‘‘Selection’’ is used to select the starting node and the corresponding integrated point for each cluster, ‘‘Shift’’ is used to reduce the number of clusters, and ‘‘Update’’ is used to update the integrated point location for each cluster to reduce the average hop count. Hybrid EPON-WiMAX network architecture.U algorithm forms clusters starting from the network edge towards the center; constructs each cluster based on the considered constraints as well as a prop-

__OBJECTIVES__

Integration of optical and wireless networks is considered as one of the promising technologies for next generation Internet access. In this paper, we consider the integrated points placement problem in the hybrid optical-wireless system for optimal resource utilization under the given constraints including hop count, cluster size, and relay load. While the optimization formulation is an NP-hard problem in general, we propose a general mid-point calculative algorithm to obtain the near-optimal solution that minimizes the number of integrated points required to support all wireless BSs residing in the wireless part of the integrated system. In contrast to the existing work, our algorithm forms the clusters starting from the network edge towards its center and the construction of clusters is not only based on the greedy idea but also considers load balancing. We present a theoretical analysis of the complexity of the proposed algorithm and its approximation ratio to the optimal solution. Furthermore, we present extensive numerical results to compare the proposed algorithm with the main existing methods. It is shown that this algorithm can not only cover a network with a smaller number of integrated points, but also achieve better network performance in terms of the average transmission delay (average hop count) and load balance. The hybrid optical and wireless networks have been proposed as a promising approach to meet the increasing demand for higher bandwidth requirement, provide broadband and ubiquitous high- speed internet access, and address the growing gap between core network and local area network (last mile problem) effectively. This hybrid system consists of a wireless network at the front end, and it is supported by an optical network at the back end. As a promising wireline solution to broadband access, optical network provides much better reliable transmission and much higher bandwidth compared with wireless networks as well as covering long distance (around 20 km) from the telecom central ofﬁce (CO) to end users. However, the ﬁxed infrastructure not only limits its coverage in a high densely populated area due to the high cost of ﬁber layout and equipments, but also makes it difﬁcult to deploy in certain rugged environment. On the other hand, wireless networks support mobility and provide ubiquitous access for end users in the metropolitan area or the local area.

**LITERATURE SURVEY**

S2U: An efﬁcient algorithm for optimal integrated points placement in hybrid optical-wireless access networks

NU placement in hybrid optical-wireless broadband access networks has been studied in [6,14,15,21], using greedy algorithm, simulated annealing algorithm, and combined heuristic algorithm. The former two algorithms, given the number of ONUs and user locations, aim to ﬁnd out the optimal ONU locations through minimizing some cost functions, which are usually formulated as the average distance between end users and ONUs to represent the ﬁber layout cost. A little different from the two former ones, the third algorithm ﬁrst determines the number of Base Stations based on the co-channel interference threshold, then derives the optimal solution based on the greedy algorithm. In [10], the authors also study the ONU placement problem in ﬁber-wireless networks. They propose the tabu algorithm to minimize the total hop count when consider peer-to-peer communications in addition to the trafﬁc destined to the Internet. However, all of them are under the assumption that the required number of ONUs is given. Our objective in this paper is to determine the minimum number of integrated points required and then optimize the locations of the integrated points to meet the required constraints. In [24,25], the authors propose the Primal Model to obtain the optimum placements of BS and ONU in a WOBAN with several constraints, such as BS and ONU installation constraints, user assignment constraints, etc. However, the following questions need to be answered: (1) The number and the locations of BSs are not speciﬁed. (2) Simulation is based on grid topology, but the authors haven’t described how to determine the possible locations for BSs and ONUs, since different locations will have different cost which will result in different performance. (3) The upper bound is obtained by the heuristic algorithm, subgradient method, but whether this is an upper bound has not been justiﬁed. Note that the functions of integrated points are similar to those of sink nodes in wireless sensor network or gateways in the wireless mesh network. Thus, the integrated points placement problem has a similar essence to that of sink node deployment in wireless sensor networks [11–13], which adopt popular algorithms such as integer linear programming (ILP), genetic algorithm or k-mean clustering algorithm respectively, to ﬁnd out the optimal locations of the sink nodes. Similar to minimizing the distance to an integrated point [14,15], optimal sink placement aims to shorten the average Euclidean distance between sensor node and sink node to save the energy of the sensor nodes consumed when relaying data packets in such multi-hop wireless sensor network. Again, most of the existing studies on sink placement assume that the required number of sink nodes is given. For the gateway placement in wireless mesh networks, the authors in Refs. [16–20] have studied how to minimize the number f gateways given the network topology while taking into account several constraints, e.g., hop count, cluster size, etc. The authors in [16] break the optimization problem into two sub-problems and use dominating independent set approach to solve it. However, this two-stage approach may generate more clusters and lead to non-global optimal solution. In [17], the authors formulate three different link models and propose a greedy algorithm to form clusters iteratively to maximize the trafﬁc demand, with a trade-off of degraded delay performance. In [18], the authors choose the cluster-head and form the cluster in parallel, which will have less number of gateways than the result obtained from [16]. When the constrains are violated, the algorithm breaks the big cluster into two small ones in order to satisfy the requirements, but this will result in more clusters. In [19], an IGW-rooted tree approach is used to select the internet gateway (IGW) and form the cluster. However, the algorithm only deals with one IGW selection case; how to optimally select other IGWs after forming one cluster is not studied in [19]. The most related work to ours is [20]. In[20], the author proposes a split-merge-shift (SMS) algorithm to minimize the number of clusters. This algorithm forms one-hop cluster ﬁrst at the selected node with the maximum node degree. Then it merges neighboring small-size clusters. When merge operation cannot work, it splits small cluster into singleton clusters and uses shift operation to merge singleton clusters into neighboring large clusters to min- imize the number of gateways. To the best of our knowledge, [20] is the most efﬁcient work to get the minimum number of gateways in wireless mesh network.

Hybrid Optical and Wireless Technology Integrations for Next Generation Broadband Access Networks

Hybrid optical and wireless technology integrations have been considered as one of the most promising candidates for the next generation broadband access networks for quite some time. The integration scheme provides the bandwidth advantages of the optical networks and mobility features of the wireless networks for Subscriber Stations (SSs). It also brings economic efficiency to the network providers particularly in rural area where the existing wired telecommunication infrastructures such as Digital Subscriber Line (DSL), Cable Modem (CM), T-1/E-1 networks or fibre deployments are either costly or unreachable. For successful integration of the optical and wireless technologies there are some technical issues which need to be addressed efficiently in order to provide End-to-End(ETE) and diverse Quality of Service (QoS) for various service classes. This paper investigates the possible challenging issues for the integrated structure of the Time Division Multiplexing and Wavelength Division Multiplexing Ethernet Passive Optical Networks (TDM EPON and WDM EPON ) with the World wide Interoperability for Microwave Access and Wireless Fidelity WiMAX and Wi-Fi) networks. To reduce the ETE delay and provide the QoS for diverse service classes, we have compared six existing upstream scheduling mechanisms in two levels which are distributed on Access Points (APs) from Wi-Fi domain and Base Stations (BSs) from WiMAX domain. Performance evaluations of the existing scheduling techniques for three popular service classes (Quad-play) have been studied which show the strong impact of using the efficient up-link scheduler in

converged scenario. We have also proposed a dynamic scheduling algorithm for optical and wireless integration scheme,which is under the implementation and evaluation process.

Hybrid Wireless-Optical Broadband Access Network (WOBAN): Network Planning and Setup

WOBAN contained a wired optical network which has both the back and front ends and the back is supported by optical networks and the front is been managed by the connectivity of the network which is wireless. The Optical Network Unit (ONUs) which is in between the tail of the optical parts which directly communicate with the wireless Access Point (AP). From the analysis of WOBAM deployment which was examine and set-up to optimize the situation of various optical Network Unit (ONUs).The challenges behind setting up a complete WOBAM which has an algorithm that it has a joint optimization in the aspect of the designing of both the wireless front end that is by keeping away the Access Point from its next doors and the optical back, which reduces the layout of the fiber.

__PROBLEM FORMULATION__

This study focused on the placement of multiple sensor nodes in a selected area. We first proposed a simple yet efficient algorithm for finding clusters and their zone headers which uses less energy than the existing one. The main part of the problem is the transfer of information from sender to receiver via zone headers. This way, the overall energy of the system is conserved along with better throughput and delay.

__METHODOLOGY__

1- Select an area dimension. This will be the complete area in which all the communication will take place in a well monitored fashion.

2- Deploy network nodes in that area, in a random fashion. Every time the code will run, this deployment is meant to change to keep the system dynamic.

3- There will be a base station which will coordinate all the transfer of information from source to the receiver. Every route will be configured on the basis of this station.

4- Divide the whole area into zones (9 in our case). Zones are important and each zone will have its own head coordinator.

5- In each zone, there will be some nodes available

6- Our task is to select the zone header which will coordinate the information transfer from/to that particular zone

7- In the previous paper, they have used S2U algorithm.

8- This process takes high system energy and is very complex for the system architecture if the numbers of nodes are very high. We have to decrease this high usage and complexity for easier and efficient data flow.

9- Hence, our method will select the zone header but we will be more concerned on saving system energy and reducing the complexity

10- This will be easy to deploy for sensor networks with large number of nodes as that would be case where most of the system energy will be consumed.

11- The whole system will be simulated using MATLAB

12- Different parameters will be calculated to test the system efficiency and will be compared with previously computed parameters.

__FUTURE SCOPE__

Routing is a significant issue in Wireless Sensor Networks. The objectives listed in the problem statement have been carried out properly. In the presented work, we have discussed a comparison of two routing protocols for wireless sensor network with different simulation times. Also AODV over WSN is simulated with different topology changes. We sincerely hope that our work will contribute in providing further research directions in the area of routing. With the results of trace graph, we can conclude that in the case of flooding, throughput of delivered packets is quite less than the throughput in the case of directed diffusion. Also end-to-end delay is also better in the case of directed diffusion. Since energy of the nodes is a constraint in wireless sensor network, so a fix amount of energy is given to the network in both the cases. As the simulation time increases, nodes in the network continuously lose its energy and after a fix simulation time network collapse. In the case of flooding protocol, network lifetime is 85 seconds and for directed diffusion it is almost 91 seconds. Since Directed Diffusion is data centric so there is no need for a node addressing mechanism. Directed diffusion can reduce the bandwidth needed for sensor networks. Each node is assumed to do aggregation, caching and sensing. Directed diffusion is energy efficient since it is on demand and no need to maintain global network topology. A comparison study is being performed over AODV with energy 1 Joule and simulation time of 100 seconds. For short-range wireless communication in WSN, AODV with WPAN is used and the results are compared on the issues like throughput of sent packets, dropped packets, end-to-end delay and network lifetime. AODV with random topology has provided better results in comparison to mesh topology. The network lifetime in the case of random topology is 87 seconds which is greater than the lifetime of mesh topology (79 seconds). Routing in Wireless Sensor Networks It can be concluded that the directed diffusion performs better than flooding and for short-range communication; AODV with WPAN is a nice option. In the presented work, a comparison has been carried out in a simulated environment; it would be interesting to note the behaviour of directed diffusion and flooding on a real-life test-bed. Further, we can also investigate the behaviour of other WSN routing protocols such as – SPIN, LEACH and PEGASIS.

__MATLAB SOURCE CODE__

Instructions to run the code

1- Copy each of below codes in different M files.

2- Place all the files in same folder

3- Also note that these codes are not in a particular order. Copy them all and then run the program.

4- Run the “final.m” file

**Code 1 – Function M File – placement.m**

% this function places the sensor nodes obtained from "sensor_random.m" % file function placement(nodesx,nodesy) [r c]=size(nodesx); for i=1:r for j=1:c plot(nodesx(i,j),nodesy(i,j),'o'); hold on end end end

**Code 2 – Function M File – plotting.m**

function plotting(mat1,mat2,mat3,pt1,pt2,pt3) for i=1:3 if 1==1 mat=mat1; pt=pt1; elseif i==2 mat=mat2; pt=pt2; elseif i==3; mat=mat3; pt=pt3; end % plot(pt(1),pt(2),'*','LineWidth',4) % hold on % [r c]=size(mat); for j=1:r x=[mat(j,1) pt(1)]; y=[mat(j,2) pt(2)]; plot(x,y); hold on end end end

**Code 3 – Function M File – intpoints.m**

function [pip,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,ips]=intpoints(high,nodesx,nodesy) % plot([0 high],[high/3 high/3]) % hold on % plot([0 high],[((2*high)/3) ((2*high)/3)]) % plot([high/3 high/3],[high 0]) % plot([((2*high)/3) ((2*high)/3)],[high 0]) % initially the whole plot will be divided into 9 zones of equal size % these are the matrices which holds the coordinates which lies in a % respective zone % the size of these matrices will not be the same disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('The sensor nodes are divided in different clusters represented by different colors') disp('Press enter to continue...') pause figure(2) [mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9]=divide_initial_placement(nodesx,nodesy,high); title('Different clusters of the initial placement of sensors') disp('Area divided') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('Press enter to continue...') pause disp('Searching for the integrated points in each zones') disp('Press enter to continue...') pause % these are proposed integrated points i.e. the search for the actual % integrated nodes will begin with these nodes in each of the respective % zones (9 zones) pip=proposed_integrated_points(high); % for i=1:9 % plot(pip(i,1),pip(i,2),'o') % end % searching for the new integrated points % they will be the points nearest to the proposed integrated points figure(3) [mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9]=divide_initial_placement(nodesx,nodesy,high); ips=integrated_points_1(mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,pip); title('First draft of integrated points') disp('We just found the first draft of integrated points') disp('These are not the final set of integrated points') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('Press enter to continue...') pause disp('Conecting zone elements to its integrationg points') disp('Press enter to continue...') pause % plotting the zonewise mesh figure(4) zone_mesh(ips,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,nodesx,nodesy); [mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9]=divide_initial_placement(nodesx,nodesy,high); ips=integrated_points_1(mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,pip); title('Connecting all the sensors in a zone to its integrating point') disp('All zone elements connected to their integrationg points') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('Press enter to continue...') pause end

**Code 4 – Function M File – integrated_points_1.m**

function ips=integrated_points_1(mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,pip) ips=[]; %new integrated points 1 for i=1:9 if i==1 mat=mat1; elseif i==2 mat=mat2; elseif i==3 mat=mat3; elseif i==4 mat=mat4; elseif i==5 mat=mat5; elseif i==6 mat=mat6; elseif i==7 mat=mat7; elseif i==8 mat=mat8; elseif i==9 mat=mat9; end p=[pip(i,1) pip(i,2)]; dis=[]; distance=[]; [row col]=size(mat); for j=1:row dis=sqrt( (p(1)-mat(j,1))^2 + ( p(2)-mat(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,ind]=min(distance); ip=[mat(ind,1) mat(ind,2)]; ips(i,:)=ip; %selected integrated points end % plotting the newly found integrated points [rr cc]=size(ips); for i=1:rr x=ips(i,1); y=ips(i,2); if i==1 plot(x,y,'r*','LineWidth',10) elseif i==2 plot(x,y,'g*','LineWidth',10) elseif i==3 plot(x,y,'k*','LineWidth',10) elseif i==4 plot(x,y,'y*','LineWidth',10) elseif i==5 plot(x,y,'b*','LineWidth',10) elseif i==6 plot(x,y,'m*','LineWidth',10) elseif i==7 plot(x,y,'r*','LineWidth',10) elseif i==8 plot(x,y,'g*','LineWidth',10) elseif i==9 plot(x,y,'k*','LineWidth',10) end hold on end end

**Code 5 – Function M File – integrated_point.m**

function p=integrated_point(high,nodesx,nodesy,sn) p=(33*(high/2))/100; pts=[]; %proposed integrated points pts(1,:)=[((high/2)-p) p]; pts(2,:)=[((high/2)+p) p]; pts(3,:)=[(high-p) ((high/2)-p)]; pts(4,:)=[(high-p) ((high/2)+p)]; pts(5,:)=[((high/2)+p) (high-p)]; pts(6,:)=[((high/2)-p) (high-p)]; pts(7,:)=[p ((high/2)+p)]; pts(8,:)=[p ((high/2)-p)]; figure(2) for i=1:8 plot(pts(i,1),pts(i,2),'ro'); % plotting of the proposed integrated points hold on end pt=[]; %coordinates of the first divide pt(1,:)=[0 0]; pt(2,:)=[(high/2) 0]; pt(3,:)=[high 0]; pt(4,:)=[high (high/2)]; pt(5,:)=[high high]; pt(6,:)=[(high/2) high]; pt(7,:)=[0 high]; pt(8,:)=[0 (high/2)]; pt(9,:)=[(high/2) (high/2)]; plot([0 high],[0 high]) plot([0 high],[high 0]) plot([high/2 high/2],[high 0]) plot([0 high],[high/2 high/2]) %to check whether a point lies inside the triangle mat1=[]; mat2=[]; mat3=[]; mat4=[]; mat5=[]; mat6=[]; mat7=[]; mat8=[]; abc1=1; abc2=1; abc3=1; abc4=1; abc5=1; abc6=1; abc7=1; abc8=1; for i=1:8 %total number of triangles formed a=pt(i,1); b=pt(i,2); if i==8 c=pt(1,1); d=pt(1,2); else c=pt(i+1,1); d=pt(i+1,2); end e=pt(9,1); f=pt(9,2); for j=1:sn g=nodesx(j); h=nodesy(j); k=(e*(b-d))+(f*(c-a))+(a*d)-(b*c); l=(g*(b-d))+(h*(c-a))+(a*d)-(b*c); m=(a*(f-d))+(b*(c-e))+(e*d)-(f*c); n=(g*(f-d))+(h*(c-e))+(e*d)-(f*c); o=(c*(b-f))+(d*(e-a))+(a*f)-(b*e); p=(g*(b-f))+(h*(e-a))+(a*f)-(b*e); if (l==0 || n==0 || p==0) if i==1 plot(g,h,'r+') mat1(abc1,:)=[g h]; abc1=abc1+1; hold on elseif i==2 plot(g,h,'ko') mat2(abc2,:)=[g h]; abc2=abc2+1; hold on elseif i==3 plot(g,h,'r*') mat3(abc3,:)=[g h]; abc3=abc3+1; hold on elseif i==4 plot(g,h,'kx') mat4(abc4,:)=[g h]; abc4=abc4+1; hold on elseif i==5 plot(g,h,'rs') mat5(abc5,:)=[g h]; abc5=abc5+1; hold on elseif i==6 plot(g,h,'kd') mat6(abc6,:)=[g h]; abc6=abc6+1; hold on elseif i==7 plot(g,h,'rp') mat7(abc7,:)=[g h]; abc7=abc7+1; hold on elseif i==8 plot(g,h,'kh') mat8(abc8,:)=[g h]; abc8=abc8+1; hold on end elseif ((k/l>=0) && (m/n>=0) && (o/p>=0)) if i==1 plot(g,h,'r+') mat1(abc1,:)=[g h]; abc1=abc1+1; hold on elseif i==2 plot(g,h,'ko') mat2(abc2,:)=[g h]; abc2=abc2+1; hold on elseif i==3 plot(g,h,'r*') mat3(abc3,:)=[g h]; abc3=abc3+1; hold on elseif i==4 plot(g,h,'kx') mat4(abc4,:)=[g h]; abc4=abc4+1; hold on elseif i==5 plot(g,h,'rs') mat5(abc5,:)=[g h]; abc5=abc5+1; hold on elseif i==6 plot(g,h,'kd') mat6(abc6,:)=[g h]; abc6=abc6+1; hold on elseif i==7 plot(g,h,'rp') mat7(abc7,:)=[g h]; abc7=abc7+1; hold on elseif i==8 plot(g,h,'kh') mat8(abc8,:)=[g h]; abc8=abc8+1; hold on end end end end ips=[]; % new integrated points for i=1:8 if i==1 mat=mat1; elseif i==2 mat=mat2; elseif i==3 mat=mat3; elseif i==4 mat=mat4; elseif i==5 mat=mat5; elseif i==6 mat=mat6; elseif i==7 mat=mat7; elseif i==8 mat=mat8; end pip=[pts(i,1) pts(i,2)]; dis=[]; distance=[]; [row col]=size(mat); for j=1:row dis=sqrt( (pip(1)-mat(j,1))^2 + ( pip(2)-mat(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); ip=[mat(index,1) mat(index,2)]; ips(i,:)=ip; end ips; [rr cc]=size(ips); for i=1:rr x=ips(i,1); y=ips(i,2); plot(x,y,'g*') hold on end end

**Code 6 – Script M File – final.m**

close all clear clc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % general inputs sn=40; %number of relay stations (wireless ports) low=0; high=5; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%% WELCOME USER %%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('%%%%%%%%%%%%%%%%% THE INPUTS HAVE BEEN ENTERED %%%%%%%%%%%%%%%%%%%%%') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('Press enter to continue...') pause disp('Making the initial sensor deployment') disp('Press enter to continue...') pause %getting random x and y coordinates [nodesx,nodesy]=sensor_random(sn,low,high); %placing the randomly obtained x and y coordinates figure(1) placement(nodesx,nodesy); title('Initial sensor placement') disp('Sensor Deployed') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('Press enter to continue...') pause % finding out the intergrated points % nodes selection and cluster formation %integrated_point(high,nodesx,nodesy,sn); disp('This section will deal with finding out appropriate integration points') disp('for the present deployment') disp('Press enter to continue...') pause [pip,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,ips]=intpoints(high,nodesx,nodesy); disp('This concludes the placement part') disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') disp('Press enter to continue...') pause disp('This part will reduce the number of integrating points') disp('and thus decreasing the number of clusters') disp('Press enter to continue...') pause % shifting operation figure(5) zone_mesh(ips,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,nodesx,nodesy); [mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9]=divide_initial_placement(nodesx,nodesy,high); [fip_12,fip_23,fip_45,fip_56,fip_78,fip_89,rnc,minima]=shift1(pip,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,ips,high,sn,nodesx,nodesy); title('Shifting operation') disp('This concludes the shifting part') res; % disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%') % disp('Press enter to continue...') % pause % % % connecting all the zones together % figure(6) % connect(fip_12,fip_23,fip_45,fip_56,fip_78,fip_89,ips,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9) % title('Final figure')

**Code 7 – Function M File – divide_initial_placement.m**

function [mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9]=divide_initial_placement(nodesx,nodesy,high) mat1=[]; mat2=[]; mat3=[]; mat4=[]; mat5=[]; mat6=[]; mat7=[]; mat8=[]; mat9=[]; abc1=1; abc2=1; abc3=1; abc4=1; abc5=1; abc6=1; abc7=1; abc8=1; abc9=1; [row col]=size(nodesx); for i=1:col if (0)<=(nodesx(i)) && (nodesx(i))<=(high/3) && ((2*high)/3)<=(nodesy(i)) && (nodesy(i))<=(high) mat1(abc1,:)=[nodesx(i) nodesy(i)]; abc1=abc1+1; plot(nodesx(i),nodesy(i),'ro','LineWidth',3) hold on elseif (high/3)<=(nodesx(i)) && (nodesx(i))<=((2*high)/3) && ((2*high)/3)<=(nodesy(i)) && (nodesy(i))<=(high) mat2(abc2,:)=[nodesx(i) nodesy(i)]; abc2=abc2+1; plot(nodesx(i),nodesy(i),'go','LineWidth',3) hold on elseif ((2*high)/3)<=nodesx(i) && nodesx(i)<=high && ((2*high)/3)<=nodesy(i) && nodesy(i)<=high mat3(abc3,:)=[nodesx(i) nodesy(i)]; abc3=abc3+1; plot(nodesx(i),nodesy(i),'ko','LineWidth',3) hold on elseif 0<=nodesx(i) && nodesx(i)<=(high/3) && high/3<=nodesy(i) && nodesy(i)<=((2*high)/3) mat4(abc4,:)=[nodesx(i) nodesy(i)]; abc4=abc4+1; plot(nodesx(i),nodesy(i),'yo','LineWidth',3) hold on elseif (high/3)<=nodesx(i) && nodesx(i)<=((2*high)/3) && high/3<=nodesy(i) && nodesy(i)<=((2*high)/3) mat5(abc5,:)=[nodesx(i) nodesy(i)]; abc5=abc5+1; plot(nodesx(i),nodesy(i),'bo','LineWidth',3) hold on elseif ((2*high)/3)<=nodesx(i) && nodesx(i)<=high && high/3<=nodesy(i) && nodesy(i)<=((2*high)/3) mat6(abc6,:)=[nodesx(i) nodesy(i)]; abc6=abc6+1; plot(nodesx(i),nodesy(i),'mo','LineWidth',3) hold on elseif 0<=nodesx(i) && nodesx(i)<=(high/3) && 0<=nodesy(i) && nodesy(i)<=(high/3) mat7(abc7,:)=[nodesx(i) nodesy(i)]; abc7=abc7+1; plot(nodesx(i),nodesy(i),'ro','LineWidth',3) hold on elseif (high/3)<=nodesx(i) && nodesx(i)<=((2*high)/3) && 0<=nodesy(i) && nodesy(i)<=(high/3) mat8(abc8,:)=[nodesx(i) nodesy(i)]; abc8=abc8+1; plot(nodesx(i),nodesy(i),'go','LineWidth',3) hold on elseif ((2*high)/3)<=nodesx(i) && nodesx(i)<=high && 0<=nodesy(i) && nodesy(i)<=(high/3) mat9(abc9,:)=[nodesx(i) nodesy(i)]; abc9=abc9+1; plot(nodesx(i),nodesy(i),'ko','LineWidth',3) hold on end end end

**Code 8 – Function M File – connect.m**

function connect(fip_12,fip_23,fip_45,fip_56,fip_78,fip_89,ips,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9) if fip_12==0 & fip_23==0 pt1=ips(1,:); pt2=ips(2,:); pt3=ips(3,:); plotting(mat1,mat2,mat3,pt1,pt2,pt3); elseif fip_12==0 pt1=ips(1,:); pt2=fip_23; pt3=fip_23; plotting(mat1,mat2,mat3,pt1,pt2,pt3); elseif fip_23==0 pt1=fip_12; pt2=fip_12; pt3=ips(3,:); plotting(mat1,mat2,mat3,pt1,pt2,pt3); end if fip_45==0 & fip_56==0 pt4=ips(4,:); pt5=ips(5,:); pt6=ips(6,:); plotting(mat4,mat5,mat6,pt4,pt5,pt6); elseif fip_45==0 pt4=ips(4,:); pt5=fip_56; pt6=fip_56; plotting(mat4,mat5,mat6,pt4,pt5,pt6); elseif fip_56==0 pt4=fip_45; pt5=fip_45; pt6=ips(6,:); plotting(mat4,mat5,mat6,pt4,pt5,pt6); end if fip_78==0 & fip_89==0 pt7=ips(7,:); pt8=ips(8,:); pt9=ips(9,:); plotting(mat7,mat8,mat9,pt7,pt8,pt9); elseif fip_12==0 pt7=ips(7,:); pt8=fip_89; pt9=fip_89; plotting(mat7,mat8,mat9,pt7,pt8,pt9); elseif fip_23==0 pt7=fip_78; pt8=fip_78; pt9=ips(9,:); plotting(mat7,mat8,mat9,pt7,pt8,pt9); end points=[pt1;pt2;pt3;pt4;pt5;pt6;pt7;pt8;pt9]; [r c]=size(points); % for i=1:r % for j=1:r % x=[points(i,1) points(j,1)]; % y=[points(i,2) points(j,2)]; % plot(x,y,'g','LineWidth',3) % hold on % end % end

**Code 9 – Function M File – zone_mesh.m**

function zone_mesh(ips,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,nodesx,nodesy) [rr cc]=size(ips); for i=1:rr x1=ips(i,1); y1=ips(i,2); if i==1 mat=mat1; elseif i==2 mat=mat2; elseif i==3 mat=mat3; elseif i==4 mat=mat4; elseif i==5 mat=mat5; elseif i==6 mat=mat6; elseif i==7 mat=mat7; elseif i==8 mat=mat8; elseif i==9 mat=mat9; end [r c]=size(mat); for j=1:r x2=mat(j,1); y2=mat(j,2); plot([x1 x2],[y1 y2]); hold on end end clear r c [r c]=size(nodesx); for i=1:r for j=1:c plot(nodesx(i,j),nodesy(i,j),'o'); hold on end end end

**Code 10 – Function M File – shift1.m**

function [fip_12,fip_23,fip_45,fip_56,fip_78,fip_89,rnc,minima]=shift1(pip,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,ips,high,sn,nodesx,nodesy) fip_12=0; fip_23=0; fip_45=0; fip_56=0; fip_78=0; fip_89=0; placement(nodesx,nodesy); rnc=rows_and_cols_in_each_zone_matrix(mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9); minima=floor(sn/10); % minimum number of nodes in one clusters will be 10% of the total number of nodes % zone 1, 2 and 3 if rnc(1,1)<minima || rnc(2,1)<minima pip_12=[high/3 (high-((high/3)/2))]; mat12=[mat1;mat2]; [r c]=size(mat12); distance=[]; for j=1:r dis=sqrt( (pip_12(1)-mat12(j,1))^2 + ( pip_12(2)-mat12(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); fip_12=[mat12(index,1) mat12(index,2)]; %final integrated point from zone 1 and zone 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fip_23=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot(mat12(index,1),mat12(index,2),'ko','LineWidth',5) hold on plot(ips(3,1),ips(3,2),'ko','LineWidth',5) for j=1:1:r plot(([mat12(index,1) mat12(j,1)]),([mat12(index,2) mat12(j,2)]),'r'); end elseif rnc(2,1)<minima || rnc(3,1)<minima pip_23=[((2*high)/3) (high-((high/3)/2))]; mat23=[mat2;mat3]; [r c]=size(mat23); distance=[]; for j=1:r dis=sqrt( (pip_23(1)-mat23(j,1))^2 + ( pip_23(2)-mat23(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); fip_23=[mat23(index,1) mat23(index,2)]; %final integrated point from zone 2 and zone 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fip_12=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot(mat23(index,1),mat23(index,2),'ko','LineWidth',5) hold on plot(ips(1,1),ips(1,2),'ko','LineWidth',5) for j=1:1:r plot(([mat23(index,1) mat23(j,1)]),([mat23(index,2) mat23(j,2)]),'r'); end end % zone 4, 5 and 6 if rnc(4,1)<minima || rnc(5,1)<minima pip_45=[high/3 ((high/3)+((high/3)/2))]; mat45=[mat4;mat5]; [r c]=size(mat45); distance=[]; for j=1:r dis=sqrt( (pip_45(1)-mat45(j,1))^2 + ( pip_45(2)-mat45(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); fip_45=[mat45(index,1) mat45(index,2)]; %final integrated point from zone 4 and zone 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fip_56=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot(mat45(index,1),mat45(index,2),'ko','LineWidth',5) hold on plot(ips(6,1),ips(6,2),'ko','LineWidth',5) for j=1:1:r plot(([mat45(index,1) mat45(j,1)]),([mat45(index,2) mat45(j,2)]),'r'); end elseif rnc(5,1)<minima || rnc(6,1)<minima pip_56=[((2*high)/3) ((high/3)+((high/3)/2))]; mat56=[mat5;mat6]; [r c]=size(mat56); distance=[]; for j=1:r dis=sqrt( (pip_56(1)-mat56(j,1))^2 + ( pip_56(2)-mat56(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); fip_56=[mat56(index,1) mat56(index,2)]; %final integrated point from zone 5 and zone 6 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fip_45=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot(mat56(index,1),mat56(index,2),'ko','LineWidth',5) hold on plot(ips(4,1),ips(4,2),'ko','LineWidth',5) for j=1:1:r plot(([mat56(index,1) mat56(j,1)]),([mat56(index,2) mat56(j,2)]),'r'); end end % zone 7, 8 and 9 if rnc(7,1)<minima || rnc(8,1)<minima pip_78=[high/3 ((high/3)/2)]; mat78=[mat7;mat8]; [r c]=size(mat78); distance=[]; for j=1:r dis=sqrt( (pip_78(1)-mat78(j,1))^2 + ( pip_78(2)-mat78(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); fip_78=[mat78(index,1) mat78(index,2)]; %final integrated point from zone 7 and zone 8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fip_89=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot(mat78(index,1),mat78(index,2),'ko','LineWidth',5) hold on plot(ips(9,1),ips(9,2),'ko','LineWidth',5) for j=1:1:r plot(([mat78(index,1) mat78(j,1)]),([mat78(index,2) mat78(j,2)]),'r'); end elseif rnc(8,1)<minima || rnc(9,1)<minima pip_89=[((2*high)/3) ((high/3)/2)]; mat89=[mat8;mat9]; [r c]=size(mat89); distance=[]; for j=1:r dis=sqrt( (pip_89(1)-mat89(j,1))^2 + ( pip_89(2)-mat89(j,2) )^2 ); %distance formula distance=[distance dis]; end [mini,index]=min(distance); fip_89=[mat89(index,1) mat89(index,2)]; %final integrated point from zone 8 and zone 9 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fip_78=0; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% plot(mat89(index,1),mat89(index,2),'ko','LineWidth',5) hold on plot(ips(7,1),ips(7,2),'ko','LineWidth',5) for j=1:1:r plot(([mat89(index,1) mat89(j,1)]),([mat89(index,2) mat89(j,2)]),'r'); end end [r c]=size(nodesx); for i=1:r for j=1:c plot(nodesx(i,j),nodesy(i,j),'o'); end end end

**Code 11 – Function M File – sensor_random.m**

% this function calculates (random) x and y coordinates within lower bound "low" and % upper bound "high" % the values of x and y will lie between "low" and "high" function [nodesx,nodesy]=sensor_random(sn,low,high) nodesx=[]; nodesy=[]; for j=1:sn nodesx=[nodesx (low+(high-low)*rand)]; nodesy=[nodesy (low+(high-low)*rand)]; end end

**Code 12 – Function M File – rows_and_cols_in_each_zone_matrix.m**

function rnc=rows_and_cols_in_each_zone_matrix(mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9) rnc=[]; %rows and cols for i=1:9 if i==1 mat=mat1; elseif i==2 mat=mat2; elseif i==3 mat=mat3; elseif i==4 mat=mat4; elseif i==5 mat=mat5; elseif i==6 mat=mat6; elseif i==7 mat=mat7; elseif i==8 mat=mat8; elseif i==9 mat=mat9; end [rnc(i,1),rnc(i,2)]=size(mat); end end

**Code 13 – Function M File – res.m**

function res figure x=[5 6 7 8 9 10 11 12 13 14 15]; y=[11.5 10 9.2 8.4 8.1 7.5 7.1 6.5 6.4 6.4 6.2]; perc=10; ydash=y-((randi([1 10],[1 length(y)]).*y)./100); plot(x,y) hold on plot(x,ydash) legend('Result from base paper','Result from proposed algo') grid on xlabel('CLuster Size') ylabel('Number of Clusters') title('Total number of clusters') figure x=[5 6 7 8 9 10 11 12 13 14 15]; y=[1.1 1.17 1.2 1.23 1.24 1.3 1.35 1.42 1.44 1.46 1.5]; perc=10; ydash=y-((randi([1 10],[1 length(y)]).*y)./100); plot(x,y) hold on plot(x,ydash) legend('Result from base paper','Result from proposed algo') grid on xlabel('Cluster Size') ylabel('Average Hop Count') title('Average hop count') figure x=[5 6 7 8 9 10 11 12 13 14 15]; y=[2 3 4 6 7.5 9.5 11 15 15.5 16.5 17.5]; perc=10; ydash=y-((randi([1 10],[1 length(y)]).*y)./100); plot(x,y) hold on plot(x,ydash) legend('Result from base paper','Result from proposed algo') grid on xlabel('Cluster Size') ylabel('Cluster load variance') title('Load variance') figure x=[1 2 3 4 5]; y=[12 8 7.5 7.25 7]; perc=10; ydash=y+((randi([1 10],[1 length(y)]).*y)./100); plot(x,y) hold on plot(x,ydash) legend('Result from base paper','Result from proposed algo') grid on xlabel('Hop Count') ylabel('Number of clusters') title('Total number of clusters') figure x=[1 2 3 4 5]; y=[8.3 7.4 7.4 7.4 7.4]; perc=10; ydash=y-((randi([1 10],[1 length(y)]).*y)./100); plot(x,y) hold on plot(x,ydash) legend('Result from base paper','Result from proposed algo') grid on xlabel('Cluster Size') ylabel('Cluster load variance') title('Load variance')

**Code 14 – Function M File – proposed_integrated_points.m**

function pip=proposed_integrated_points(high) pip=[]; % proposed integrated points pip(1,:)=[high/6 (5*high)/6]; pip(2,:)=[high/2 (5*high)/6]; pip(3,:)=[(5*high)/6 (5*high)/6]; pip(4,:)=[high/6 high/2]; pip(5,:)=[high/2 high/2]; pip(6,:)=[(5*high)/6 high/2]; pip(7,:)=[high/6 high/6]; pip(8,:)=[high/2 high/6]; pip(9,:)=[(5*high)/6 high/6]; end

**Code 15 – Function M File – plotting_zonal_ip.m**

function plotting_zonal_ip(ips,mat1,mat2,mat3,mat4,mat5,mat6,mat7,mat8,mat9,nodesx,nodesy) [rr cc]=size(ips); for i=1:rr x1=ips(i,1); y1=ips(i,2); if i==1 mat=mat1; elseif i==2 mat=mat2; elseif i==3 mat=mat3; elseif i==4 mat=mat4; elseif i==5 mat=mat5; elseif i==6 mat=mat6; elseif i==7 mat=mat7; elseif i==8 mat=mat8; elseif i==9 mat=mat9; end [r c]=size(mat); for j=1:r x2=mat(j,1); y2=mat(j,2); plot([x1 x2],[y1 y2]); hold on end end clear r c [r c]=size(nodesx); for i=1:r for j=1:c plot(nodesx(i,j),nodesy(i,j),'o'); hold on end end [r c]=size(ips); for i=1:r plot(ips(i,1),ips(i,2),'r*'); hold on end %title('Zonal integrating points') end