Exemplo n.º 1
0
    public void activateNodes(Dictionary <long, ipDataStruct> map)
    {
        float tScaleVal;

        NFPointManager ptMan;

        foreach (KeyValuePair <int, GameObject> entry in nfMap)
        {
            ptMan = entry.Value.GetComponent <NFPointManager>();
            ptMan.deactivate();
            //entry.Value.SetActive(false);
        }

        int        lowerByte;
        GameObject g;

        foreach (KeyValuePair <long, ipDataStruct> entry in map)
        {
            lowerByte = (int)(entry.Key & 0xFFFF);
            if (nfMap.TryGetValue(lowerByte, out g))
            {
                ptMan = g.GetComponent <NFPointManager>();

                ipDataStruct ipds = entry.Value;
                tScaleVal = getScaleVal((float)ipds.numTimesSeen);

                if (ptMan.nodeType == ipType.WORKSTATION)
                {
                    g.transform.localScale = new Vector3(tScaleVal, tScaleVal, 1.0f);
                }
                else if (ptMan.nodeType == ipType.SERVER)
                {
                    tScaleVal *= 2.0f;
                    g.transform.localScale = new Vector3(tScaleVal, tScaleVal, tScaleVal);
                }
                //g.SetActive(true);
                ptMan.activate();
            }
        }
    }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if ((Input.GetKeyDown(KeyCode.Space) || inAnimation || currTimeIdx < 0) && !queryActive)
        {
            currTimeIdx++;

            currTimeIdx = Math.Max(0, Math.Min(timeSlices.Length - 2, currTimeIdx));

            timelineScript.updateSliderPosition((float)currTimeIdx / (float)timeSlices.Length);

            getVals();

            UpdateActiveTimeRange();
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            for (int i = 0; i < 3; i++)
            {
                Debug.Log("Subnet " + (i + 1) + ": " + currNfIpsSeen[i].Count);
            }
        }


        if (queryActive)
        {
            long   ipNum;
            string ipAddress = "";
            int    numTimesSeen;
            int    statusVal;

            long   dstIpNum;
            string dstIpAddress;
            int    priorityVal;

            int idx;

            // int numLoaded = 0;
            double currTime = DateTime.Now.TimeOfDay.TotalMilliseconds;
            double maxTime  = currTime + iterTimeOffset;

            ipDataStruct  tmpNfValue  = new ipDataStruct();
            bbDataStruct  tmpBbValue  = new bbDataStruct();
            ipsDataStruct tmpIPSValue = new ipsDataStruct();

            bool foundInSubnet = false;

            while (currTime < maxTime && hasResultSets)
            {
                if (currDbDataType == dbDataType.NETWORK_FLOW)
                {
                    while (dataReader.Read())
                    {
                        try
                        {
                            ipAddress    = dataReader.GetString(0);
                            ipNum        = dataReader.GetInt64(1);
                            numTimesSeen = dataReader.GetInt32(2);

                            foundInSubnet = false;

                            for (idx = 0; idx < 3; idx++)
                            {
                                if (ipNum <= maxSubnetIpNum[idx] && ipNum >= minSubnetIpNum[idx])
                                {
                                    //nextIpsSeen[idx].



                                    if (!nextNfIpsSeen[idx].TryGetValue(ipNum, out tmpNfValue))
                                    {
                                        tmpNfValue              = new ipDataStruct();
                                        tmpNfValue.ipAddress    = ipAddress;
                                        tmpNfValue.numTimesSeen = numTimesSeen;
                                        nextNfIpsSeen[idx].Add(ipNum, tmpNfValue);
                                    }
                                    else
                                    {
                                        tmpNfValue.numTimesSeen += numTimesSeen;
                                    }

                                    foundInSubnet = true;

                                    break;
                                }
                            }



                            if (!foundInSubnet)
                            {
                                tmpNfValue           = new ipDataStruct();
                                tmpNfValue.ipAddress = ipAddress;
                                outOfNetIpsSeen.Add(ipNum, tmpNfValue);
                            }
                        }

                        catch (System.InvalidCastException e)
                        {
                            Debug.Log(e);
                        }

                        currTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

                        if (currTime >= maxTime)
                        {
                            break;
                        }
                    }
                }
                else if (currDbDataType == dbDataType.BIG_BROTHER)
                {
                    while (dataReader.Read())
                    {
                        try
                        {
                            ipAddress = dataReader.GetString(0);

                            if (ipAddress == null || ipAddress.Length < 7)
                            {
                                continue;
                            }

                            ipNum     = dataReader.GetInt64(1);
                            statusVal = dataReader.GetInt32(2);

                            for (idx = 0; idx < 3; idx++)
                            {
                                if (ipNum <= maxSubnetIpNum[idx] && ipNum >= minSubnetIpNum[idx])
                                {
                                    //nextIpsSeen[idx].

                                    if (!nextBbIpsSeen[idx].TryGetValue(ipNum, out tmpBbValue))
                                    {
                                        tmpBbValue           = new bbDataStruct();
                                        tmpBbValue.ipAddress = ipAddress;
                                        tmpBbValue.status    = statusVal;
                                        nextBbIpsSeen[idx].Add(ipNum, tmpBbValue);
                                    }
                                    else
                                    {
                                        if (statusVal > tmpBbValue.status)
                                        {
                                            tmpBbValue.status = statusVal;
                                        }
                                    }
                                    break;
                                }
                            }
                        }

                        catch (System.InvalidCastException e)
                        {
                            Debug.Log(e.Message + " for ip/time: " + ipAddress + "/" + timeSlices[currTimeIdx]);
                        }

                        currTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

                        if (currTime >= maxTime)
                        {
                            break;
                        }
                    }
                }
                else if (currDbDataType == dbDataType.INTRUSION_PROTECTION)
                {
                    while (dataReader.Read())
                    {
                        try
                        {
                            ipAddress    = dataReader.GetString(0);
                            ipNum        = dataReader.GetInt64(1);
                            dstIpAddress = dataReader.GetString(2);
                            dstIpNum     = dataReader.GetInt64(3);

                            priorityVal = dataReader.GetInt32(4);

                            for (idx = 0; idx < 3; idx++)
                            {
                                if (ipNum <= maxSubnetIpNum[idx] && ipNum >= minSubnetIpNum[idx])
                                {
                                    if (!nextIPSIpsSeen[idx].TryGetValue(ipNum, out tmpIPSValue))
                                    {
                                        tmpIPSValue           = new ipsDataStruct();
                                        tmpIPSValue.ipAddress = ipAddress;
                                        tmpIPSValue.priority  = priorityVal;
                                        nextIPSIpsSeen[idx].Add(ipNum, tmpIPSValue);
                                    }
                                    else
                                    {
                                        if (priorityVal > tmpIPSValue.priority)
                                        {
                                            tmpIPSValue.priority = priorityVal;
                                        }
                                    }

                                    break;
                                }
                            }

                            for (idx = 0; idx < 3; idx++)
                            {
                                if (dstIpNum <= maxSubnetIpNum[idx] && dstIpNum >= minSubnetIpNum[idx])
                                {
                                    if (!nextIPSIpsSeen[idx].TryGetValue(dstIpNum, out tmpIPSValue))
                                    {
                                        tmpIPSValue           = new ipsDataStruct();
                                        tmpIPSValue.ipAddress = dstIpAddress;
                                        tmpIPSValue.priority  = priorityVal;
                                        nextIPSIpsSeen[idx].Add(dstIpNum, tmpIPSValue);
                                    }
                                    else
                                    {
                                        if (priorityVal > tmpIPSValue.priority)
                                        {
                                            tmpIPSValue.priority = priorityVal;
                                        }
                                    }

                                    break;
                                }
                            }
                        }

                        catch (System.InvalidCastException e)
                        {
                            Debug.Log(e.Message);
                        }

                        currTime = DateTime.Now.TimeOfDay.TotalMilliseconds;

                        if (currTime >= maxTime)
                        {
                            break;
                        }
                    }
                }

                if (currTime >= maxTime)
                {
                    break;
                }
                else if (dataReader.NextResult())
                {
                    if (currDbDataType == dbDataType.NETWORK_FLOW)
                    {
                        currDbDataType = dbDataType.BIG_BROTHER;
                    }
                    else if (currDbDataType == dbDataType.BIG_BROTHER)
                    {
                        currDbDataType = dbDataType.INTRUSION_PROTECTION;
                    }
                    continue;
                }
                else
                {
                    hasResultSets = false;
                }
            }

            if (!hasResultSets)
            {
                queryActive = false;

                queryEndTime = DateTime.Now.TimeOfDay;

                for (int i = 0; i < subnetObjects.Length; i++)
                {
                    currNfIpsSeen[i].Clear();
                    currBbIpsSeen[i].Clear();
                    currIPSIpsSeen[i].Clear();

                    currNfIpsSeen[i]  = nextNfIpsSeen[i];
                    currBbIpsSeen[i]  = nextBbIpsSeen[i];
                    currIPSIpsSeen[i] = nextIPSIpsSeen[i];

                    subnetMappings[i].activateNodes(nextNfIpsSeen[i]);
                    subnetMappings[i].activateBBNodes(nextBbIpsSeen[i]);
                    subnetMappings[i].activateIPSNodes(nextIPSIpsSeen[i]);
                }
            }
        }
    }