需要有关如何在网络中使用Java实施安全性的指南 [英] Need guidance on how to implement security using Java in networks

查看:84
本文介绍了需要有关如何在网络中使用Java实施安全性的指南的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关什么是Gnave算法以及如何实现它以为易受节点捕获攻击攻击的网络提供安全性的详细信息

I need details about What is Gnave Algorithm and how I can implement it to provide security to networks that are vulnerable to Node capture Attack

推荐答案

令我不安的是,有人的安全性将依赖于知道一些流行术语并依赖在线论坛提供实际代码的人.
There is nothing more disturbing to me than the idea that someone''s security will be reliant on someone who knows a couple of buzzwords and relies on online forums for the actual code.


Christian已经指出了这一点.所以我不会太在意它.

如果您知道需要使用Gnave算法,请尝试进行一些有关如何实现它的研究. Google应该是您的第一站.然后,当您对实现有技术问题时,请在此处提出问题,然后人们会尝试提供帮助.
Christian has already made the point so I will not belabour it.

If you know that Gnave Algorithm is what you need, then try doing some research on how to implement it; Google should be your first port of call. Then, when you have a technical question with your implementation, come back and ask it here and people will try to help.


import java.awt.Point;
import java.util.*;

import edu.uci.ics.jung.graph.UndirectedGraph;
import edu.uci.ics.jung.graph.UndirectedOrderedSparseMultigraph;
/**
 * Application to perform GNAVE algorithm
 * @author jshou, babsher, cbolson
 *
 */
public class RouteCapture {

        //public static HashMap<Integer,ArrayList<Node>> network;
        public static HashMap<Integer, Node> nodes;

        public static UndirectedGraph<Node,Edge> network;

        //public static final int SHARED_KEYS = 1;
        //public static final int RANGE = 1;

        public static void main(String[] args){
                nodes = new HashMap<Integer, Node>();
                // create a network with a probability of connectedness of .9999
                network = createNetwork(.9999, 5, 1, 10, 1);
        }

        /**
         * This function will return the key ring size.
         * @param pc - Probability of creating a connected graph
         * @param numNodes - number of nodes in graph
         * @param pool - size of key pool
         * @param n_prime - size of neighborhood
         * @return key ring size for each node
         */
        public static int calculateKeySizes(double pc, int numNodes, int pool, int n_prime){
                // TODO Auto-generated method stub
                // Use Corey's matlab stuff
                return 1;
        }

        public static UndirectedGraph<Node,Edge> createNetwork(double Pc, int poolSize, int n_prime, int numNodes, int keyRingSize){
                // initalize graph
                UndirectedGraph<Node,Edge> graph = new UndirectedOrderedSparseMultigraph<Node, Edge>();

                // Create Key Pool
                ArrayList<Integer> keyPool = new ArrayList<Integer>();
                for(int i = 0; i < poolSize; i++){

                        keyPool.add(i);

                }



                HashMap<Integer, Node> nodelist = createNodes(0, 0, keyPool);

                // get keys for nodes
                ArrayList<Integer> keylist = new ArrayList<Integer>(nodes.keySet());

                for(int i = 0; i < keylist.size(); i++){

                        int key = keylist.get(i);

                        Node curr = nodelist.get(key);



                        // find hood

                        ArrayList<Integer> hood = curr.getNeighborhood(n_prime, numNodes, nodelist);

                        // for each node in hood of the current node
                        // create edge if 2 nodes share a key and are near each other
                        for(int j = 0; j < hood.size(); j++){

                                int neighborId = hood.get(j);

                                Node neighbor = nodelist.get(neighborId);



                                // find the intersection of the two key rings

                                ArrayList<Integer> sharedKeys = (ArrayList<Integer>) neighbor.getKeys().clone();
                                sharedKeys.retainAll(curr.getKeys());

                                // if there is some shared create an edge
                                if(!sharedKeys.isEmpty()){
                                        Edge edge = new Edge(sharedKeys, curr.getId(), neighbor.getId());
                                        graph.addEdge(edge, curr, neighbor);
                                }
                        }
                }

                return graph;
        }

        /**
         * This class creates the node list for the network.
         * @param numNodes - number of nodes to create
         * @param keyRingSize - size of key ring for each node
         * @param n_prime - size of neighborhood
         * @return a hash map of node id to node class
         */
        public static HashMap<Integer, Node> createNodes(int numNodes, int keyRingSize, ArrayList<Integer> keyPool){
                HashMap<Integer, Node> nodelist = new HashMap<Integer, Node>();

                Point gridSize = getGridSize(numNodes);

                // iterate over the grid and
                // create nodes for each location
                for(int x = 0; x < gridSize.x; x++){

                        for(int y = 0; y < gridSize.y; y++){

                                int id = Node.computeId(x, y, numNodes);

                                Point loc = new Point(x,y);

                                ArrayList<Integer> keyring = getRandomSubset(keyPool, keyRingSize);
                                nodelist.put(id, new Node(id, loc, keyring));

                                // make sure we do not over fill
                                if(nodelist.size() == numNodes){
                                        break;
                                }
                        }

                        if(nodelist.size() == numNodes){
                                break;
                        }
                }

                return nodelist;
        }

        /**
         * Returns a random subset of array of size n.
         * @param array
         * @param n
         * @return
         */
        public static ArrayList<Integer> getRandomSubset(ArrayList<Integer> array, int n){
                ArrayList<Integer> workinglist = (ArrayList<Integer>) array.clone();
                ArrayList<Integer> subset = new ArrayList<Integer>();

                for(int i = 0; i < n; i++){

                        int index = (int) Math.floor(Math.random() * workinglist.size());

                        subset.add(workinglist.remove(index));

                }

                return subset;

        }



        /**

         * This method will return the max x and y for the

         * physical location of all the nodes.

         * @param numNodes - number of nodes dropped in area

         * @return - a point representing the max a and y

         */

        public static Point getGridSize(int numNodes) {

                // TODO Auto-generated method stub

                return null;

        }



        // the following methods are all GNAVE, helper functions or route vulnerability metric

        public static ArrayList<Node> gnave(){
                ArrayList<Node> C = new ArrayList<Node>();

                return C;
        }

        /**
         * Incremental node value of adding node i to C
         * @param C - captured nodes
         * @return
         */
        public static int v(int i, ArrayList<Node> C){
                return 0;
        }

        /**
         * Route Vulnerability Metric for independent path routing
         * @param C - captured nodes
         * @return
         */
        public static double VsdIndependent(ArrayList<Node> C){

                return 0.0;
        }

        public static double phi_ij(){
                return 0.0;
        }

        public static double phi_sd(){
                return 0.0;
        }


这篇关于需要有关如何在网络中使用Java实施安全性的指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆