project report kumar

83
Fast Algorithms for Resource Allocation in Cellular Network A Project Report Submitted To The Faculty of Science Osmania University, Hyderabad (A.P) In partial fulfillment of the Requirements for the Award of the Degree of Master of Computer Applications By G.KUMAR (03709032)

Upload: kumar-golleti

Post on 13-Mar-2015

193 views

Category:

Documents


0 download

TRANSCRIPT

Fast Algorithms for Resource Allocation in Cellular Network A Project Report Submitted To The Faculty of Science Osmania University, Hyderabad (A.P)

In partial fulfillment of the Requirements for the Award of the Degree of

Master of Computer ApplicationsBy G.KUMAR (03709032)

Bankatlal Badruka College for Information Technology

(Affiliated to Osmania University) Kachiguda, Hyderabad-500027 2008-2011

BANKATALAL BADRUKA COLLEGE FOR INFORMATION TECHNOLOGY KACHIGUDA, HYDERABAD

CERTIFICATE

This is to certify that the Project work titled ________________________________________________ was carried out by _________________________________________________________ in partial fulfillment of the requirements for the award of Master of Computer Applications (MCA) by Osmania University during the period ____________________ under our guidance.

The results embodied in this project have not been submitted to any other University or Institution for the award of any degree or diploma.

Internal Guide

: Name & signature

HOD

:

DECLARATION

I, G.KUMAR bearing the Hall Ticket No. (03709032), studying in Bankatlal Badruka College for Information Technology (BBCIT), declare that the report of the Project entitled Fast Algorithms for Resource Allocation in Cellular Network is the result of the original work done by me and has not been submitted earlier to Osmania University or any other Institution for the award of any degree of diploma and does not form part of any other course. This project is submitted in partial fulfillment for the award of degree of Master of Computer Applications (MCA) from Osmania University, Hyderabad.

(G.KUMAR)

CONTENTS Abstract1. Introduction1.1 Objectives of the system 1.1.1 Scheduling for elastic (non real-time) flows 1.1.2 Scheduling for Real-Time Flows 1.2 Existing System 1.3 Proposed System 1.4 Problem formulation 1.4.1 System Model 1.4.2 Existence and Uniqueness of a Positive Solution

122 2 3 4 4 5 5 6

2. System Analysis and Design2.1 Simple SRS 2.1.1 User Utility Functions 2.1.2 Maximum Utility Resource Allocation 2.1.3 Fast online resource allocation algorithm 2.1.4 Hardware Requirements 2.1.5 Software Requirements 2.2 Modules analysis 2.2.1 Module description 2.3 Usecase Diagram 2.4 Sequence Diagram 2.5 Activity Diagram 2.6 Component D 2.7 Deployment Diagram 2.8 Data Flow Diagram

77 7 8 8 10 10 10 10 12 13 14 15 15 16

3. Implementation3.1 Title.java 3.2 Source.java 3.3 Routers.java 3.4 Destination.java

1616 20 29 44

4. Testing and Test Results4.1 Screen shorts 4.2 Test

5050 55

5. Conclusion 6. References

56 57

Fast Algorithms for Resource Allocation in Cellular Networks

Abstract:

We consider a wireless cellular network where the channels from the base station to the n mobile users undergo flat fading. Spectral resources are to be divided among the users using time division multiple access (TDMA) in order to maximize total user utility. We show that this problem can be cast as a nonlinear convex optimization problem, and describe an O(n) algorithm to solve it. Computational experiments show that the algorithm typically converges in around 25 iterations, where each iteration has a cost that is O(n), with a modest constant. When the algorithm starts from an initial resource allocation that is close to optimal, convergence typically takes even fewer iterations. Thus, the algorithm can efficiently track the optimal resource allocation as the channel conditions change due to fading. While, in this paper, we focus on TDMA systems, our approach extends to frequency selective channels, and to frequency division multiple access (FDMA), and code division multiple access (CDMA) systems. We briefly describe such extensions.

1

1. INTRODUCTIONwire line networks due to the time-varying nature of the wireless channel . There has been much prior work on scheduling policies in wireless networks to allocate resources among different flows based on the channels they see and the flow state This work was funded in part by the MARCO Focus Center for Circuit and System Solutions (C2S2, www.c2s2.org) under Contract 2003-CT-888, the AFOSR under Grant AF F49620-01-1-0365, the NSF under Grant ECS-0423905, the NSF under Grant 0529426, the DARPA/MIT under Grant 5710001848, the AFOSR under Grant FA9550-06-1-0514, the DARPA/Lockheed under Contract N66001-06-C2021, the AFOSR/Vanderbilt under Grant FA9550-06-1-0312, the Stanford URI Architecture for Secure and Robust Distributed Infrastructures (AFOSR DoD award 49620-01-1-0365), and the Sequoia Capital Stanford Graduate Fellowship.

1.1 Objectives of the system 1.1.1 Scheduling for elastic (non real-time) flows:The end-user experience for a elastic flow is modeled by a concave increasing utility function of the rate experienced by the flow . The proportional fair algorithm (see, for example, ) where all the resources are allocated to the flow with the maximum ratio of instantaneous spectral efficiency (which depends on the channel gain) to the average rate has been analyzed in roughly speaking this algorithm maximizes the sum of log utilities of average rates over an asymptotically large time horizon.

A more general scheduling rule where potentially multiple users can be scheduled simultaneously has been considered in Most of the above work assumes that the queues have infinite backlogs, i.e., packets are always available in the buffers of all the queues; extensions to finite queues are provided in, for example, Joint design of scheduling and congestion control with modeling of queue dynamics has been considered in, for example, in this case, packets are always assumed to be available at the congestion controller.2

1.1.2 Scheduling for Real-Time Flows:

Real-time flows are typically modeled by a predetermined but unknown arrival process and a delay deadline for each packet. For such flows, we can roughly define the stability region as follows: The stability region for a set of queues is defined as the set of arrival rates at the queues for which there exists a scheduling policy such that the length of any queue does not grow without bound over time (see, for example.

A stabilizing policy is one which ensures that the queue lengths do not grow without bound. Stabilizing policies for a vector of arrival rates within the stability region for different wireless network models have been characterized in, for example, The scheduling policy in minimizes the percentage of packets lost because of deadline expiry, while the delay performance of the exponential rule (introduced in was empirically studied in Work on providing throughput guarantees for such flows includes and and references therein.

We note that policies to schedule a mixture of elastic (non realtime) and real-time flows have been considered in Distributed algorithms for interference management to maximize the sum utilities of user signal-to-noise ratios (SNR) in cellular networks have been studied in Also, related crosslayer optimization problems for resource allocation in wireless networks with different objectives have been analyzed in, for example, Resource allocation algorithms which focus on maximizing um rate (without fairness or with minimum rate guarantees) for OFDM systems include The above summary is only a representative sample of the work in the general area of resource allocation in wireless networks. complete description of prior work, we refer the reader to and the references therein. In this paper, we focus on elastic flows with infinite backlogs; an extension to model constraints of finite backlogs due to congestion control (which can be modeled as an upper bound on the bandwidth allocated to a user) is straightforward.

3

We study the problem of resource allocation in wideband OFDM wireless cellular networks like Ultra Mobile Broadband (UMB) and Long Term Evolution path for 3GPP In particular,we study the assignment of power and spectral resources to maximize the sum-utility of the achieved data rates. The user utility can be a function of instantaneous rate or average rate over time.

For both these cases, the solution in general can result in the distribution of resources to multiple flows at the same time. We show that the problem is a convex optimization problem. Hence, it can be solved in time for users using a general-purpose barrier method (see, for example However, the time-varying nature of wireless channels necessitates recomputation of an optimal resource allocation in an online manner. This requires the design of faster computational algorithms to track the optimal resource allocation. We exploit the underlying structure of the problem to derive a specialized barrier method that has a complexity of . We also illustrate the generality of our computational techniques through extensions to frequency selective fading, where we exploit frequency diversity. We note that our work focusses on computational algorithms and is complementary to that [9The focus of those papers is on the asymptotic analysis when the user utility is a function of the rate averaged over a very long time.

1.2 Existing SystemSpectral resources are to be divided among the users using time division multiple access (TDMA) in order to maximize total user utility. We show that this problem can be cast as a nonlinear convex optimization problem, and describe an O(n) algorithm to solve it. Computational experiments show that the algorithm typically converges in around 25 iterations, where each iteration has a cost that is O(n), with a modest constant. The assignment of power and spectral resources to maximize the sum-utility of the achieved data rates. We show that this is a convex optimization problem. Hence, it can be solved in O(n3) time for n users using a general purpose barrier method.

1.3 Proposed SystemWe use the barrier method to solve the optimization problem the barrier method is used to compute an optimal resource allocation. Such a method, in general, has complexity O(n3). However, we exploit the structure of the problem to reduce the complexity to O(n). We4

modeled the constraint that the average power for a TDMA system should be less than a given maximum average power. Adding instantaneous power constraints, or modeling only instantaneous power constraints is straightforward. The methods in this paper can also be used almost immediately to obtain O(n) algorithms for utility maximization in FDMA systems with flat fading, and in CDMA systems efficiently to give an O(nm)barrier method. Both instantaneous and average power constraints can be modeled.

1.4 PROBLEM FORMULATION 1.4.1 System ModelWe model an OFDM wireless cellular network where spectrum and power need to be divided between communication flows (users) on links in a cell. We formulate an optimization problem which is applicable to the downlink; as we show later, extensions to the uplink can be similarly obtained. We assume an M-Quadrature Amplitude Modulation (MQAM) scheme for transmission and a total system bandwidth, . Then, the maximum rate (in nats/sec) at which a user, , can transmit is given by where is the transmit power, is the channel gain over the link to user , is the bandwidth allocated to user , is the noise power spectral density, and , where BER is the desired (constant) bit error rate [36]. We denote the effective flow rate in nats/s/Hz for user by , and the fraction of bandwidth allocated to it by .

We denote the associated vectors of rates and bandwidth-fractions as and , respectively. The power consumption to support flow rate can be modeled as When , the power required is 0. The power consumption of user as a function of and has the form , where the function is defined as follows: if , otherwise. The set is given by We assume that each cell has a (weighted) total power constraint of the form where is the (weighted) total power, is the given maximum (weighted) total power, and are the weights.

This constraint can be used to model a sum-power constraint, with , for the downlink in a cell. For the uplink, it can also be used to model the requirement that the total interference at a neighboring interfering base-station should be kept below some threshold.1 The weights then represent the power gains to the neighboring base-station.2 We will normalize the5

power constraint by defining the normalized power by where . The power constraint is then . We first observe that is a convex function of and . The function , defined for , is the perspective of the exponential function, and so is convex. The function is obtained from by an affine composition, and the addition of a linear term, and so is convex.

The total power is therefore also a convex function of In the uplink, some mobiles may be power limited and so, it is necessary to model the individual power constraint for each link. Since we mainly focus on the downlink for the rest of the paper, we do not include this in our analysis for notational simplicity our techniques can be generalized in a straightforward manner to allow for such constraints as well. In general we can have a total interference budget constraint at more than one base-station our analysis extends to this case as well.

Also, a total interference budget constraint is a reasonable way to keep interference low at neighboring base-stations when the frequency tones in neighboring cells hop randomly and independently of each other Setting the interference budgets is out of the scope of our paper. For the uplink, now represents the noise plus average interference power spectral density and

and so, the total power constraint is a convex constraint for .

1.4.2 Existence and Uniqueness of a Positive SolutionIn this section, we show that the resource allocation problem (1) has a unique solution with and. We will do this by constructing a sequence of points converging to the maximum, which must therefore lie in the closure of the feasible set. We first show the following.

Lemma 1: The closure of satisfies . The interpretation of this result is that allocating zero bandwidth- fraction and positive rate to a user requires infinite power. Hence for every point in the feasible set, we must have whenever , and in fact this holds for the closure of the feasible set also. The next result shows that a point with for some cannot be optimal. The idea here is that since has infinite slope at 0, slightly increasing and will give an increase in

6

utility which outweighs the decrease in the other constraint.

rates necessary to maintain the power

Lemma 2: Suppose there is a sequence with limit and Suppose also that for all either or . If there is some such that then there exists such that The final lemma needed shows that a point with for some must also have . If this were not the case, we could decrease to zero, spreading this bandwidth-fraction among the other users, who can use the extra bandwidth fraction to increase their rates without increasing their powers, thus giving a feasible point with larger total utility. Then using Lemma 2, we can rule out the possibility that a maximizing sequence converges to .

Lemma 3: Suppose is a sequence in with limit and , with and . If there is some such that , then there exists such that We now have the following theorem showing the existence and uniqueness of the solution.

Theorem 1: There exists a unique with such thatProof: First notice that problem (2) is feasible. That is, the set is nonempty, since for small enough the choice , satisfies . Let Then is finite, since is bounded and is concave. We must show that this optimal value is actually achieved. Suppose is a maximizing sequence in , so that . By extracting a subsequence, we can assume that converges to a point . Lemma 1 implies this point lies in and since it is optimal on Lemma 3 implies that and . Hence the optimal value is achieved in . Uniqueness now follows from strict concavity of .

2 SYSTEM ANALYSIS AND DESIGN2.1 Simple SRS 2.1.1 User Utility Functions The utility for user is a function of its instantaneous rate, given by , so the total utility is We assume that the utility functions are thrice continuously differentiable with for all and7

Thus, (and therefore also ) is strictly increasing and strictly concave, and the marginal utility increases without bound as the rate converges to zero. Examples of common utility functions satisfying these conditions include and , for . Note that the above utility function does not take into account past allocations to users. We consider this extension in Section V. We show that we can use our computational techniques o efficiently compute a scheduling policy that is a generalization of the scheduling policy in

2.1.2 Maximum Utility Resource Allocation

Our goal is to choose and to maximize the total utility, subject to the power constraint and the bandwidth-fraction constraint: maximize subject.

where denotes the vector with all entries one. The optimization variables are and ; the problem data are and the functions . The vector inequalities are component wise; means , . For convenience we will define the feasible set by We now have the equivalent problem maximize subject to In the following section, we will show that there is a unique optimal allocation which is achieved at a point with and . Hence, relaxing these strict inequalities to non strict inequalities, and appropriately interpreting and , does not change the optimal solution. The resource allocation problem is a convex optimization problem, with variables and constraints. Roughly speaking, this means that its global solution can be efficiently computed, for example by a general interior-point method.

These methods typically converge in a few tens of iterations; each iteration in a general-purpose implementation requires arithmetic operations The algorithm we describe in the next section solves the resource allocation problem much faster by exploiting its special structure. The resulting interior point method converges in about 25 to 30 iterations, where each iteration requires operations with a modest constant.

2.1.3 FAST ONLINE RESOURCE ALLOCATION ALGORITHM Barrier method

8

In this section, we describe the barrier method to compute an optimal resource allocation. Such a method, in general, has complexity owever, we exploit the structure of the problem to reduce the complexity to . A. Barrier Method We use the barrier method to solve the optimization problem in (2) The central point for a given value of the barrier parameter is given by the solution of the following problem: minimize subject to (3) As increases, becomes a more accurate approximation to the solution to the problem in (2).

Note that the objective function above is convex, and the above problem is a convex optimization problem. Moreover, the solution to the above problem is unique. This follows, in particular, from the positive-definiteness of the Hessian of the objective function, as argued in Section III-C. We collect the variables into one vector , . Note that we have interleaved the rate and bandwidth-fraction variables here, so that the variables associated with a given user are adjacent. Also, we denote the barrier function as nd The barrier method is then as follows. Given strictly feasible starting point , tolerance .

Repeat 1) Centering Step. Minimize subject to , starting at . 2) Update. . 3) Stopping Criterion. quit 4) Increase . .

Newton Method We now describe the Newton method to compute the central point , i.e., solve the problem in (3) for a given value of . The Newton step at , and the associated dual variable are given by following equations: where . For the Newton method, we use a backtracking line search to ensure an adequate decrease The method is then as follows.

Given starting point such that , tolerance , Repeat9

1) Compute and . 2) Stopping Criterion. quit if 3) Backtracking line search on .while Update.

2.1.4 Hardware Requirements SYSTEM HARD DISK MONITOR MOUSE RAM KEYBOARD : Pentium IV 2.4 GHz : 40 GB : 15 VGA colour : Logitech. : 256 MB : 110 keys enhanced.

2.1.5 Software Requirements Operating system :- Windows XP Professional Front End :- Java Technology

2.2 Modules analysis1. Communication networking module 2. Distributed DataStream module 3. Planning module 4. Adaptation module 5. Query processing module

2.2.1 Module description:1. Communication networking module

Computing or networking is a distributed application architecture that partitions tasks or workloads between service providers (servers) and service requesters, called clients. Often clients and servers operate over a computer network on separate hardware. A server machine is a high-performance host that is running one or more server programs which share its resources with clients. A client also shares any of its resources; Clients therefore initiate communication sessions with servers which await (listen to) incoming requests.10

2. Distributed Data Stream module Distributed data streams systems are distinguished by a number of characteristics. First, a network of computing nodes with heterogeneous bandwidth and computing resources together serves as a distributed data stream delivery system. Second, data streams originate from multiple sources and are disseminated to multiple receivers. Third, multiple continuous stream queries are executing simultaneously on the stream delivery network with different input and output rates. Instead of shipping all data streams to a single node and processing all the stream queries in a centralized server, many have shown that performing distributed processing of stream queries using techniques such as in-network processing and filtering at the source minimizes the communication overhead on the system and helps spread processing load, significantly improving performance. 3. Planning module A predefined join order may involve a transfer or a processing of an intermediate result to a node that is currently unavailable, thus causing the query to halt even though an alternate join order exists and is available. 4. Adaptation module: Given that each query plan is computed at compile time independently and once for all, the predefined join order from one query plan may prevent us from reusing the results of an already deployed join from another query at runtime. This limits the scope of the adaptation which aims at exploiting runtime environment properties to further optimize the efficiency of distributed stream query deliveries. 5. Query processing module

11

The paradigm of in-network query processing has been used earlier in sensor networks, and also in scientific data flows and large-scale visualizations with data manipulations sometimes pushed to the source for efficiency. The use of this technique in stream-based systems to only decide operator placement when the query tree is already known, The network aware algorithms in first perform phased deployments which we have shown to be suboptimal. Second, they do not address the important question of how the query should be divided and assigned to different portions of the network. Clearly, as seen from our experiments on varying cluster sizes, this decision can impact the efficiency of the resulting deployments. Also, no analysis is provided on the impact of the number of zones and the placement heuristics on the computational complexity of the algorithms.

2.3 Usecase Diagram

Select a File

Split Source

Select Nodes

Send

12

Node A

Source A

Node B Split Clustered Node

Destination

Source B

NodeC

Node D

2.4 Sequence Diagram

Select File : Sender 1: selects the filename

Select Destination Node

Source Nodes

Clustering Nodes

Destination Node

2: select destination node

3: tranferring file 4: dividing file b/w nodes

5: integrating file 6: file sent

13

2.5 Activity Diagram

Select filename

Select Destination node

Send the file

Div iding file between two source nodes

Integrating file at clustering nodes

Sending file to the destination node

14

& 4 02'1 0) ('r

02'1 @'98C@987 0B

7 0 ' A@ 087( 2 1 9 65r

& 3 02'1 0) ('r

%"$

" # "r

>

2.7 Deployment Diagram

! r

2.6 Component Diagram

r

15

2.8 Data Flow Diagram

3. Implementation3.1 Title.java import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel;

public class title implements ActionListener {16

public Font f0 = new Font("Times new roman" , Font.BOLD , 22); public Font f = new Font("Times new roman" , Font.BOLD , 17); public Font f1 = new Font("Verdana", Font.BOLD , 28); public Font f2 = new Font("Calibrie", Font.BOLD + Font.ITALIC, 15); public Font f3 = new Font("Algerian", Font.BOLD , 25); public JLabel T1= new JLabel("ENERGY - EFFICIENT SINR - BASED ROUTING FOR "); public JLabel T2= new JLabel(" MULTIHOP WIRELESS NETWORKS"); public JLabel T3= new JLabel("AND USE RECOMMENDATION"); public JLabel note= new JLabel("IEEE Transactions on Mobile Computing "); public JLabel note1= new JLabel("(VOL. 8, NO. 5, MAY 2009)"); public JLabel by = new JLabel("By"); public JLabel name = new JLabel("Name public JLabel depart = new JLabel("Depart&year :"); :");

public JLabel regno=new JLabel("Registeration no :"); JLabel il = new JLabel(); public JButton Sub=new JButton("Submit"); public JButton Exit=new JButton("Exit"); public JFrame jf; public Container c; title() { ImageIcon v1 = new ImageIcon(this.getClass().getResource("Net.jpg")); il.setIcon(v1); il.setBounds(0, 0, 1024,768); jf = new JFrame(""); c = jf.getContentPane(); c.setLayout(null); jf.setSize(800,670); c.setBackground(new Color(3,75,65)); T1.setBounds(130,10,1200,50);17

T2.setBounds(240,50,1000,50); T3.setBounds(300,90,1000,50); T2.setForeground(Color.CYAN); T1.setForeground(Color.CYAN); T3.setForeground(Color.BLUE); note.setBounds(330,65,900,120); note1.setBounds(420,100,500,120); note.setForeground(Color.PINK); note1.setForeground(Color.PINK);

by.setBounds(650,320,150,20); name.setBounds(630,375,150,20); depart.setBounds(630,400,150,30); regno.setBounds(630,425,175,30); by.setForeground(Color.GREEN); name.setForeground(Color.GREEN); depart.setForeground(Color.GREEN); regno.setForeground(Color.GREEN); note.setFont(f0); note1.setFont(f); by.setFont(f); name.setFont(f); depart.setFont(f); regno.setFont(f); T1.setFont(f1); T2.setFont(f1); T3.setFont(f1); Sub.setFont(f); Exit.setFont(f); Sub.setBounds(370,640,150,30);Exit.setBounds(590,640,150,30); c.add(T1);18

//c.add(T3); c.add(T2); Sub.setBackground(new Color(151,232,158)); Exit.setBackground(new Color(151,232,158)); Sub.setForeground(Color.BLACK); Exit.setForeground(Color.BLACK); jf.show(); c.add(note); c.add(note1); c.add(by); c.add(name); c.add(depart); c.add(regno); c.add(Sub); c.add(Exit); c.add(il); Sub.addActionListener(this); Exit.addActionListener(this); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } }; } public static void main(String args[]) { new title(); } public void actionPerformed(ActionEvent e) { if (e.getSource() == Exit) {19

jf.setVisible(false); System.exit(0); } if(e.getSource()== Sub) { jf.setVisible(false); } } }

3.2 source.javaimport java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader;20

import java.net.Socket; import java.net.UnknownHostException; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea;

public class Source implements ActionListener { public Font f = new Font("Times new roman" , Font.BOLD , 35); public Font f1 = new Font(" Times new roman", Font.BOLD , 18); public Font f2 = new Font("Times new roman", Font.BOLD , 18); public Font f3 = new Font("Times new roman", Font.BOLD , 16); public JLabel T0= new JLabel("Fast_Server"); public JLabel T1= new JLabel("Select the Method"); public JLabel T2= new JLabel("Select the File Name public JLabel T3= new JLabel("File Path public JLabel T4= new JLabel(); public JLabel T5= new JLabel("Select The Route"); public JLabel T6= new JLabel("FA -Foriegn Agent"); :"); :");

public JLabel T7= new JLabel("GFA -Gateway Foriegn Agent"); public JCheckBox chk1=new JCheckBox(""); public JComboBox TAreu = new JComboBox(); public JButton btn = new JButton("Submit");21

public JTextArea tf = new JTextArea(); public JScrollPane pane = new JScrollPane(); public JButton btn1 = new JButton("Browse"); JLabel imageLabel = new JLabel(); JLabel image= new JLabel(); JLabel imageLabel1 = new JLabel(); JLabel image1= new JLabel(); JLabel imageLabel2 = new JLabel(); JLabel image12= new JLabel();

JPanel jp=new JPanel(); JPanel jp1=new JPanel(); public JFrame jf; public Container c; Source() { jf = new JFrame("Fast_Server"); c = jf.getContentPane(); c.setLayout(null); jf.setSize(800,670); //c.setBackground(Color.GRAY); c.setBackground(new Color(120,50,5)); T0.setBounds(450,30,350,45); T0.setFont(f); T0.setForeground(Color.RED); T2.setBounds(205, 150, 250,45); T2.setFont(f2); T2.setForeground(Color.BLUE); T3.setBounds(205, 210, 250,45); T3.setFont(f2); T3.setForeground(Color.BLUE);22

T4.setBounds(400, 210, 950,45); T4.setFont(f2); T4.setForeground(new Color(120,0,0)); T5.setBounds(660, 145, 300,45); T5.setFont(f2); T5.setForeground(Color.GREEN); T6.setBounds(760, 70, 400,35); T6.setFont(f2); T6.setForeground(Color.GREEN): T7.setBounds(760, 110, 400,35); T7.setFont(f2); T7.setForeground(Color.MAGENTA); btn1.setBounds(590,153,150,33); btn1.setFont(f2); // btn1.setBackground(Color.WHITE); btn1.setForeground(new Color(120,0,0)); jp.setBounds(157,126,719,450); jp.setBackground(new Color(227,146,87)); //jp1.setBackground(new Color(120,0,0)); jp1.setBounds(155,124,723,453); T1.setBounds(300,550,250,45); TAreu.setBounds(650,550,200,35); btn.setBounds(440,520,150,33); T1.setFont(f3); T1.setForeground(new Color(0,120,0)); btn.setFont(f2); //btn.setBackground(Color.WHITE); btn.setForeground(new Color(120,0,0)); TAreu.addItem("Mesh Route"); TAreu.addItem(" Node "); TAreu.setFont(f3);23

TAreu.setBackground(Color.WHITE); TAreu.setForeground(Color.BLUE); TAreu.setFont(f); pane.setBounds(385, 280, 400, 200); tf.setColumns(20); tf.setForeground(Color.MAGENTA); tf.setFont(f2); tf.setRows(10); tf.setName("tf"); pane.setName("pane"); pane.setViewportView(tf); btn1.addActionListener(this); btn.addActionListener(this); btn1.setMnemonic(KeyEvent.VK_B); btn.setMnemonic(KeyEvent.VK_S); jf.show(); c.add(btn); c.add(T2); c.add(T3); c.add(T4); c.add(pane, BorderLayout.CENTER); c.add(btn1); c.add(T0); c.add(imageLabel1); c.add(jp); c.add(jp1); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } });24

}

public void actionPerformed(ActionEvent e) { // // DataInputStream input; BufferedInputStream bis; BufferedOutputStream bos = null; // // BufferedWriter writer = null; int in; String str="MobileTerminal,Foriegn Agent A,Gateway FA A"; byte[] byteArray=str.getBytes(); String strLine = null; // String newline = "\n"; if (e.getSource()== btn1) { JFileChooser chooser = new JFileChooser(); try { File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setSelectedFile(f); } catch (IOException e1) {} chooser.showOpenDialog(btn1); int retval = chooser.showOpenDialog(btn1); if (retval == JFileChooser.APPROVE_OPTION){ File field = chooser.getSelectedFile(); T4.setText(field.getAbsolutePath()); } File curFile = chooser.getSelectedFile(); try{ FileInputStream fstream = new FileInputStream(curFile);25

DataInputStream ins = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(ins)); StringBuffer buffer = new StringBuffer(); while ((strLine = br.readLine()) != null) { System.out.println (strLine); buffer.append(strLine+ "\n"); } tf.setText(buffer.toString()); } catch (Exception e1){ System.err.println("Error: " + e1.getMessage()); } Socket client = null; int Port = 1111 ; try { client = new Socket("127.0.0.1", 1111 ); bos = new BufferedOutputStream(client.getOutputStream()); //byteArray = tf.getText().getBytes(); bos.write(byteArray, 0, byteArray.length); bos.flush(); bos.close(); client.close(); } catch (UnknownHostException e1) { e1.printStackTrace(); } catch (Exception e1) {} finally { if (bos != null) { try { bos.close();26

} catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } try { client.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } if(e.getSource()== btn) { Socket client = null;

int Port = 1001;

try { client = new Socket("127.0.0.1", Port);

bos = new BufferedOutputStream(client.getOutputStream()); byteArray = tf.getText().getBytes(); bos.write(byteArray, 0, byteArray.length); bos.flush(); bos.close(); client.close(); } catch (UnknownHostException e1) {27

e1.printStackTrace(); } catch (Exception e1) {}

finally { if (bos != null) {

try {

bos.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } try { client.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } } public static void main(String args[])28

{ new Source(); } }

3.3 Routers.javaimport java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.ServerSocket; import java.net.Socket; import java.net.UnknownHostException; import java.util.Random;

import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame;29

import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField;

public class Routers mouseEvent implements ActionListener { public Font f0 = new Font("Verdana" , Font.BOLD , 35); public Font f = new Font("Times New roman" , Font.BOLD , 18);

public Font f1 = new Font("Calibrie", Font.BOLD + Font.ITALIC, 25); public JLabel l=new JLabel("Received File"); public JLabel c1=new JLabel("Routers"); public JLabel l1=new JLabel("Energy public JLabel l2=new JLabel("Packet Size :"); :");

public JLabel l3=new JLabel("Number Of Packet :"); public JLabel Tl1 = new JLabel(""); public JLabel Tl2 = new JLabel(""); public JLabel Tl3 = new JLabel(""); public JLabel Tl4 = new JLabel(""); public JLabel Tl5 = new JLabel(""); public JLabel Tl6 = new JLabel(""); public JLabel Tl7 = new JLabel(""); public JLabel Tl8 = new JLabel(""); public JLabel Tl9 = new JLabel(""); public JTextField T1 = new JTextField(""); public JScrollPane pane = new JScrollPane(); public JTextArea tf = new JTextArea(); public JButton graph=new JButton("Graphical"); public JButton Sub=new JButton("Submit"); public JButton Exit=new JButton("Exit");30

public JFrame jf; public Container c; JLabel imageLabel = new JLabel(); JLabel imageLl = new JLabel(); JLabel ill = new JLabel(); JLabel image = new JLabel(); JLabel image0 = new JLabel(); JLabel image1 = new JLabel(); JLabel image2 = new JLabel(); JLabel image3 = new JLabel(); JLabel image4 = new JLabel(); JLabel image5 = new JLabel(); JLabel image6 = new JLabel(); JLabel image7 = new JLabel(); JLabel image8 = new JLabel(); JLabel image9 = new JLabel(); String bytes;

Routers() { ImageIcon b1 = new ImageIcon(this.getClass().getResource("cement.png")); image.setIcon(b1); image0.setIcon(b1); image1.setIcon(b1); image2.setIcon(b1); image3.setIcon(b1); image4.setIcon(b1); image5.setIcon(b1); image6.setIcon(b1); image7.setIcon(b1); image8.setIcon(b1);31

image9.setIcon(b1); image.setBounds(10,370,120,100); image0.setBounds(10,220,120,100); image1.setBounds(150,120,120,100); image2.setBounds(380,120,120,100); image3.setBounds(600,120,120,100); image4.setBounds(150,300,120,100); image5.setBounds(380,300,120,100); image6.setBounds(600,300,120,100); image7.setBounds(150,480,120,100); image8.setBounds(380,480,120,100); image9.setBounds(600,480,120,100);

jf = new JFrame("Router"); c = jf.getContentPane(); c.setLayout(null); jf.setSize(800,670); //c.setBackground(Color.WHITE); c.setBackground(new Color(250,215,150)); l.setBounds(650,100,200,50); l1.setBounds(30,170,250,50); l2.setBounds(30,270,250,50); l3.setBounds(30,370,250,50); c1.setFont(f0); c1.setBounds(370,30,450,50); l1.setFont(f); l2.setFont(f); l3.setFont(f); l.setForeground(Color.GREEN); l1.setForeground(Color.CYAN); l2.setForeground(Color.CYAN);32

l3.setForeground(Color.CYAN); Tl1.setBounds(110,210,50,25); Tl2.setBounds(110,390,50,25); Tl3.setBounds(110,570,50,25); Tl4.setBounds(380,210,50,25); Tl5.setBounds(380,390,50,25); Tl6.setBounds(380,570,50,25); Tl7.setBounds(640,210,50,25);

Tl8.setBounds(640,390,50,25); Tl9.setBounds(640,570,50,25);

Tl1.setBackground(new Color(250,215,150)); Tl2.setBackground(new Color(250,215,150)); Tl3.setBackground(new Color(250,215,150)); Tl4.setBackground(new Color(250,215,150)); Tl5.setBackground(new Color(250,215,150)); Tl6.setBackground(new Color(250,215,150)); Tl7.setBackground(new Color(250,215,150)); Tl8.setBackground(new Color(250,215,150)); Tl9.setBackground(new Color(250,215,150)); pane.setBounds(700,170,300,360); tf.setColumns(20); tf.setRows(10); tf.setForeground(new Color(120,0,0)); tf.setFont(f); tf.setBackground(new Color(246,233,191)); tf.setName("tf"); pane.setName("pane"); pane.setViewportView(tf); l.setFont(f);33

T1.setFont(f); Sub.setFont(f); Exit.setFont(f); graph.setFont(f); T1.setBounds(200,100,350,50); Sub.setBounds(700,80,120,35); Exit.setBounds(410,640,200,40); Exit.setBackground(new Color(151,232,158)); graph.setBounds(140,520,200,40); graph.setBackground(new Color(151,232,158)); T1.setBackground(Color.white); T1.setForeground(Color.white); Exit.setForeground(Color.BLACK); //c.add(l); // c.add(l1); // c.add(l2); // c.add(l3); c.add(pane, BorderLayout.CENTER); c.add(Tl1); c.add(Tl2); c.add(Tl3); c.add(Tl4); c.add(Tl5); c.add(Tl6); c.add(Tl7); c.add(Tl8); c.add(Tl9); // c.add(l1); // c.add(l2); //c.add(Sub); Sub.addActionListener(this);34

c1.setForeground(Color.RED); Sub.setBackground(new Color(151,232,158)); jf.show(); c.add(c1); //c.add(Exit); Sub.addActionListener(this); Exit.addActionListener(this); jf.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent win) { System.exit(0); } } }

int[] ports = new int[] { 1001 }; for (int i = 0; i 1; i++) {

Thread t = new Thread(new PortListener(ports[i])); t.setName("Listener-" + ports[i]); t.start();

} c.add(image); c.add(image0); c.add(image1); c.add(image2); c.add(image3); c.add(image4); c.add(image5); c.add(image6); c.add(image7);35

c.add(image8); c.add(image9);

} public static void main(String args[]) { new Routers();

}

class PortListener implements Runnable { Routers ip1; BufferedOutputStream bos = null; ServerSocket server; Socket connection; BufferedReader br = null; int port; public PortListener(int port) { this.port = port; } public void run() { if(this.port==1001) { try { server = new ServerSocket(port); while (true) { connection = server.accept(); br = new BufferedReader( new InputStreamReader(new BufferedInputStream(36

connection.getInputStream())));

String strLine; // Read File Line By Line StringBuffer buffer = new StringBuffer(); System.out.println("hi"); while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println(strLine); buffer.append(strLine + "\n"); } br.close(); connection.close(); tf.setText(buffer.toString());

int len=buffer.length(); String bytes=Integer.toString(len); Random r = new Random(); Random rm = new Random(); Random ran = new Random(); int p1 =(Math.abs(r.nextInt()) % 20)+500; int p2 =(Math.abs(r.nextInt()) % 20)+500; int p3 =(Math.abs(r.nextInt()) % 20)+500; int q1 =(Math.abs(rm.nextInt()) % 20)+300; int q2 =(Math.abs(rm.nextInt()) % 20)+300; int q3 =(Math.abs(rm.nextInt()) % 20)+300; int r1 =(Math.abs(ran.nextInt()) % 20)+650; int r2 =(Math.abs(ran.nextInt()) % 20)+650; int r3 =(Math.abs(ran.nextInt()) % 20)+650; String aString = Integer.toString(p1);37

String bString = Integer.toString(p2); String cString = Integer.toString(p3); String dString = Integer.toString(q1); String eString = Integer.toString(q2); String fString = Integer.toString(q3); String gString = Integer.toString(r1); String hString = Integer.toString(r2); String iString = Integer.toString(r3);

//String a=p1 .toString(); Tl1.setText(aString.toString()); Tl2.setText(bString.toString()); Tl3.setText(cString.toString()); Tl4.setText(dString.toString()); Tl5.setText(eString.toString()); Tl6.setText(fString.toString()); Tl7.setText(gString.toString()); Tl8.setText(hString.toString()); Tl9.setText(iString.toString()); // String b=a.substring(0,23); // String c=a.substring(25,42); System.out.println(" 1 :"+p1); System.out.println(" 2 :"+p2); System.out.println(" 3 :"+p3); ImageIcon b2 = new ImageIcon(this.getClass().getResource("brown.png")); image.setIcon(b2); image0.setIcon(b2); image.setBounds(10,370,120,100); image0.setBounds(10,220,120,100); if(p1 {38

p2 && p1

p3)

System.out.println("First Integer"+p1); // ip1.setInvisible(false); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); // { // // // // public Point getToolTipLocation(MouseEvent e) { return new Point(20, -30); } };

imageLl.setIcon(v1); imageLl.setBounds(150,120,120,100); imageLl.setToolTipText(bytes); //c.add(imageLabel); c.add(imageLl,1); } else if(p2 { System.out.println("Second Integer"+p2); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); imageLl.setIcon(v1); imageLl.setBounds(150,300,120,100); c.add(imageLl,1); imageLl.setToolTipText(bytes); } else if(p3 { System.out.println("Third Integer"+p3); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); imageLl.setIcon(v1); imageLl.setBounds(150,480,120,100); c.add(imageLl,1);39

p1 && p2

p3)

p1 && p3

p2)

imageLl.setToolTipText(bytes); }

/*********************************************************/

if(q1 {

q2 && q1

q3)

System.out.println("First Integer"+p1); // ip1.setInvisible(false); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); ill.setIcon(v1); ill.setBounds(380,120,120,100); c.add(ill,1); ill.setToolTipText(bytes); } else if(q2 { System.out.println("Second Integer"+p2); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); ill.setIcon(v1); ill.setBounds(380,300,120,100); c.add(ill,1); ill.setToolTipText(bytes); } else if(q3 { System.out.println("Third Integer"+p3); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); ill.setIcon(v1); ill.setBounds(380,480,120,100);40

q3 && q2

q1)

q2 && q3

q1)

c.add(ill,1); ill.setToolTipText(bytes); } /****************************************************/ if(r1 { System.out.println("First Integer"+p1); // ip1.setInvisible(false); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); imageLabel.setIcon(v1); imageLabel.setBounds(600,120,120,100); c.add(imageLabel,1); imageLabel.setToolTipText(bytes); } else if(r2 { System.out.println("Second Integer"+p2); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); imageLabel.setIcon(v1); imageLabel.setBounds(600,300,120,100); c.add(imageLabel,1); imageLabel.setToolTipText(bytes); } else if(r3 { System.out.println("Third Integer"+p3); ImageIcon v1 = new ImageIcon(this.getClass().getResource("green.png")); imageLabel.setIcon(v1); imageLabel.setBounds(600,480,120,100); c.add(imageLabel,1);41

r2 && r1

r3)

r3 && r2

r1)

r1 && r3

r2)

imageLabel.setToolTipText(bytes); } tf.setText(buffer.toString()); byte[] byteArray; Socket client = null; try{ client = new Socket("127.0.0.1", 8889); bos = new BufferedOutputStream(client.getOutputStream()); byteArray =tf.getText().getBytes(); bos.write(byteArray, 0, byteArray.length); bos.flush(); bos.close(); client.close() } catch (UnknownHostException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } finally { if (bos != null) { try{ bos.close(); }42

catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } try { client.close(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } } catch (IOException e){ } finally{ } ******************************************************************/ /*******************************************************************/ } } } public void actionPerformed(ActionEvent e) { if (e.getSource() == Exit) { jf.setVisible(false); System.exit(0);43

} } public void actionPerformed(mouseEvent e) { if(((Image) e).getSource()==imageLl) { imageLl.setToolTipText(bytes); } } public void setInvisible(boolean b) { // TODO Auto-generated method stub } } 3.4 Destination.java import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Font; //import java.awt.Image; //import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.BufferedInputStream; //import java.io.BufferedOutputStream; import java.io.BufferedReader; //import java.io.BufferedWriter; //import java.io.DataInputStream;44

//import java.io.File; //import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.net.ServerSocket; import java.net.Socket; //import java.net.UnknownHostException;

import javax.swing.JButton; import javax.swing.JComboBox; //import javax.swing.JFileChooser; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea;

public class Destination implements ActionListener { public Font f = new Font("Arial Rounded MT Bold" , Font.BOLD , 30); public Font f1 = new Font("Calibrie", Font.BOLD + Font.ITALIC, 25); public Font f2 = new Font("Calibrie", Font.BOLD + Font.ITALIC, 15); public Font f3 = new Font("Times new Roman", Font.BOLD , 17); public Font f4 = new Font("Times new Roman", Font.BOLD , 23); public JLabel T1= new JLabel("Destination Node"); public JLabel T2= new JLabel("Received File"); public JComboBox TAreu = new JComboBox(); public JButton btn = new JButton(" Quit "); public JTextArea tf = new JTextArea(); public JScrollPane pane = new JScrollPane();45

public JButton btn1 = new JButton("Browse"); public JPanel jp = new JPanel(); public JPanel jp1 = new JPanel(); public JFrame jf; public Container c; Destination() { jf = new JFrame("Destination"); c = jf.getContentPane(); c.setLayout(null); jf.setSize(800,670); c.setBackground(new Color(204, 204, 204)); T2.setBounds(400, 160, 250,45); T2.setFont(f4); T2.setForeground(new Color(120,120,0)); T2.setForeground(Color.CYAN); btn1.setBounds(610,190,230,45); btn1.setFont(f3); btn1.setForeground(Color.BLACK); T1.setBounds(370,40,550,45); T1.setForeground(Color.RED); TAreu.setBounds(550,550,200,35); btn.setBounds(420,620,150,35); T1.setFont(f); btn.setFont(f3); btn.setForeground(Color.BLACK); TAreu.addItem("Mesh Route"); TAreu.addItem(" Node "); TAreu.setFont(f3); TAreu.setBackground(Color.WHITE); TAreu.setForeground(Color.BLUE);46

pane.setBounds(350,230,350,250); jp.setBounds(320,125,410,400); jp.setBackground(Color.GRAY); jp1.setBounds(315,120,422,410); tf.setForeground(Color.BLUE); tf.setFont(f3); tf.setColumns(20); tf.setRows(10); tf.setName("tf"); pane.setName("pane"); pane.setViewportView(tf); btn1.setBackground(new Color(176,174,144)); btn.setBackground(new Color(176,174,144)); btn1.addActionListener(this); btn.addActionListener(this); btn1.setMnemonic(KeyEvent.VK_B); btn.setMnemonic(KeyEvent.VK_S); JLabel imageLl = new JLabel(); ImageIcon v1 = new ImageIcon(this.getClass().getResource("phone1.gif")); imageLl.setIcon(v1); imageLl.setBackground(new Color(204, 204, 204)); imageLl.setBounds(10,150,300,327); c.add(imageLl); JLabel i1 = new JLabel(); ImageIcon v2 = new ImageIcon(this.getClass().getResource( "computer.jpg")); i1.setIcon(v2); i1.setBackground(new Color(204, 204, 204)); i1.setBounds(740,150,300,300); c.add(i1); jf.show();47

c.add(T1); c.add(btn); c.add(T2); c.add(pane, BorderLayout.CENTER); c.add(jp); c.add(jp1); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent win) { System.exit(0); } } }; int[] ports = new int[] { 8889 }; for (int i = 0; i 1; i++) {

Thread t = new Thread(new PortListener(ports[i])); t.setName("Listener-" + ports[i]); t.start(); } } public void actionPerformed(ActionEvent e) { if(e.getSource()==btn) { System.exit(0);

} } public static void main(String args[]) { new Destination(); }48

class PortListener implements Runnable { ServerSocket server; Socket connection; BufferedReader br = null; int port; public PortListener(int port) { this.port = port; } public void run() { try { server = new ServerSocket(port); while (true) { connection = server.accept(); br = new BufferedReader( new InputStreamReader(new BufferedInputStream( connection.getInputStream()))); String strLine; // Read File Line By Line StringBuffer buffer = new StringBuffer(); System.out.println("hi"); while ((strLine = br.readLine()) != null) { // Print the content on the console System.out.println(strLine); buffer.append(strLine + "\n"); JLabel il = new JLabel(); ImageIcon v3 = new ImageIcon(this.getClass().getResource("2.gif")); il.setIcon(v3); il.setBounds(650, 160, 100,45); c.add(il); } br.close();49

connection.close(); tf.setText(buffer.toString()); } } catch (IOException e) {} finally {} } } }

4. Testing and Test results 4.1 Screen shots

50

51

52

53

54

4.2 Testimport java.util.Random;

public class Test { public static void main(String args[]) { Random r = new Random(); int p1 =(Math.abs(r.nextInt()) % 20)+1; int p2 =(Math.abs(r.nextInt()) % 20)+1; int p3 =(Math.abs(r.nextInt()) % 20)+1; int q1 =(Math.abs(r.nextInt()) % 20)+1;55

int q2 =(Math.abs(r.nextInt()) % 20)+1; int q3 =(Math.abs(r.nextInt()) % 20)+1; int r1 =(Math.abs(r.nextInt()) % 20)+1; int r2 =(Math.abs(r.nextInt()) % 20)+1; int r3 =(Math.abs(r.nextInt()) % 20)+1; System.out.println(" 1 :"+p1); System.out.println(" 2 :"+p2); System.out.println(" 3 :"+p3); if(p1 p2 && p1 p3)

System.out.println("First Integer"+p1); else if(p2 p1 && p2 p3)

System.out.println("Second Integer"+p2); else if(p3 p2 && p3 p1)

System.out.println("Third Integer"+p3);

} }

5. ConclusionIn this paper, we derived an efficient optimization algorithm to compute the optimal resource allocation in the downlink of an OFDM wireless cellular network. We showed that our algorithm converges to the optimal solution and has a complexity of for users. Numerical results show that our algorithm converges very fast in practice. Thus, our algorithm can be implemented in an online manner even for OFDM networks with high-resource granularity. Extension to frequency selective fading and an application to scheduling algorithms with memory are also discussed.

56

6. References 1. S. Shakkottai, T. Rappaport, and P. Karlsson, Cross-layer design forwireless networks, IEEE Commun. Mag., vol. 41, no. 10, pp. 7480, Oct. 2003.

2. L. Georgiadis, M. J. Neely, and L. Tassiulas, Resource allocation andcross-layer control in wireless networks, Found. Trends Netw., vol. no. 1, pp. 1144, 2006.

3 .H. J. Kushner and P. A. Whiting, Convergence of proportional-fairsharing algorithms under general conditions, IEEE Trans. Wireless Commun., vol. 3, no. 4, pp. 12501259, Jul. 2004.

4. A. Stolyar, Greedy primal-dual algorithm for dynamic resource allocationin complex networks, Queue. Syst., vol. 54, pp. 203220, 2006.

5. S. Shakkottai and R. Srikant, Scheduling real-time traffic with deadlinesover a wireless channel, ACM/Baltzer Wireless Netw. J., vol. 8, no. 1, pp. 1326, 2002.

6. S. Shakkottai and A. Stolyar, Scheduling for multiple flows sharinga time-varying channel: The exponential rule, Amer. Math. Soc., ser. 2A,, vol. 207, Memory of F. Karpelevich, pp. 185202, 2002.

7. F. P. Kelly, A. Maulloo, and D. Tan, Rate control for communicationnetworks: Shadow prices, proportional fairness and stability, J. Oper. Res. Soc., vol. 49, pp. 237252, 1998.

8. D. Tse and P. Viswanath, Fundamentals ofWireless Communcation.Cambridge, U.K.: Cambridge Univ. Press, 2005.

9. J. M. Holtzman, Asymptotic analysis of proportional fair algorithm,in Proc. 2001 12th IEEE Int. Symp. Pers., Indoor, Mobile Radio Commun., , Sep./Oct. 2001, vol. 2, pp. F33F37.

10. S. Borst, User-level performance of channel-aware scheduling algorithmsin wireless data networks, in Proc. IEEE INFOCOM, Mar. 30Apr. 3, 2003, vol. 1, pp. 321331.57

58