Solved

Tree Assistance

Posted on 2006-11-20
13
206 Views
Last Modified: 2016-08-29
Fernado,
Here is the new posting for the previous thread. I uploaded the data, which includes the tool and source data as a attachment to this question.
http://www.experts-exchange.com/Programming/Programming_Languages/Dot_Net/VB_DOT_NET/Q_22043310.html


Thank you for all your help,
Gr8life
0
Comment
Question by:gr8life
  • 7
  • 6
13 Comments
 

Author Comment

by:gr8life
Comment Utility
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi Gr8life;

I ran your program and all the lines in the file c:\results\SkeletonKey\SkeletonKey20061121.txt stated that the IP was not in the database. I also noticed that you had combined the original files in the resource directory into 1 file with the  fields 1-4 having valid data and fields 0, 5-6 having a value of s which seemed to be OK because fields 0, 5-6 are not used in the code. I commented out the combined.latest file and uncommented the original files and re-ran the program and found that out of the 804 entires in the  Altered Data.txt file approximately 154 now were entries with Not In Database and 650 with valid entries in it. I then wrote a small program to convert the 4 files in the resource directory into a single file and re-ran the program and got 154 lines Not In Database and 650 with valid entries. I suspect that your combined.latest file has errors in it although the format looks correct. I did see a entry that the IP address was the same in both combined.latest file but had a different country code and a different field 4 which is used to find the length of the range of IP's. I have upload the following 3 files NewCombined.latest, my version of the original 4 files, NotInDatabase.txt, the list of all the Not In Database entries and SkeletonKey20061121.txt.

Please check this out and let me know what you find out with the 150 Not In Database entries.

    https://filedb.experts-exchange.com/incoming/ee-stuff/1459-TestResults.zip

Fernando
0
 

Author Comment

by:gr8life
Comment Utility
The reason I made the combined.latest file was to make it easy to find problems, like IP addresses that are not in the database.  I used newer data than what was in the original file, because IP ranges are constantly changing and the database needs to be reflective so the results are as accurate as possible.  I looked at the data in the not in database file and it appears some of the IP ranges are not in the NewCombined.latest file.  I did find some with ranges that were in the database, but reported not in database.  I think I found the problembut,  I'm not sure if the problem is the building of the tree or the traversal of the tree. I need to research a little further to be certain.

Thanks,
Gr8life
0
 

Author Comment

by:gr8life
Comment Utility
Is there a way to output the tree structure once it is populated with data to examine it for building errors?

Thanks,
Gr8life
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi gr8life;

I have found this tool to be excelent UltraCompare, it is a stand alone tool or can be added to there other products as a add in. You can download a trial version to see if you like it.

        http://www.ultraedit.com/index.php?name=Content&pid=34

UltraCompare Professional is a powerful compare/merge application loaded with features to enable users to track differences between files, directories, and .zip archives! File Compare features include text and binary compare of two or three files at a time and users can merge differences between compared files.

Folder Compare supports comparison of local/network directories (and subdirectories with recursive compare) and .zip archives as well and users may merge differences between them. With automatic integration with UltraEdit-32 or UEStudio '05, UltraCompare Professional is a tool no user should be without!

Fernando
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Sorry posted this one to the wrogn thread.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
To this question, "Is there a way to output the tree structure once it is populated with data to examine it for building errors? ", Let me take a look at how this may be done.

Fernando
0
 

Author Comment

by:gr8life
Comment Utility
I was able to locate a C++ recursive code snippet.

http://www.fredosaurus.com/notes-cpp/ds-trees/binarytreetraversal.html

void print_inorder(tree_node *p) {
    if (p != NULL) {
        print_inorder(p->left);  // print left subtree
        cout << p->data << endl; // print this node
        print_inorder(p->right); // print right subtree
    }
}

Not sure if this approach could be applied.
Also I will be on vacation until November 28.

Thank you for your time and hope you have a great holiday,
Gr8life
0
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
Hi Gr8life;

I had to make a change in the IPCountryLookup.vb and BinaryTrie.vb classes in the project. When I was converting the code I ran into the situation where in C# if you add to an integer variable which would exceed the max value it would overflow and make the value negative but in VB it throws an error. So what I did was to simulate the C# in VB and the results were the same. The problem comes in when doing the reverse. So to properly correct the issue I just used a data type of long so that the calculations would not cause an overflow. So I made the code in VB to the same in C3 except I used a long for one variable.

I put together a package to print the Trie to a log file. The below link is that project with the corrected IPCountryLookup.vb and BinaryTrie.vb. Use those two file in your SK Tool project.

        https://filedb.experts-exchange.com/incoming/ee-stuff/1510-IPLookupTri.zip

Sorry about the blunder. ;=)

Fernando
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Hi Gr8life;

I have looked at the problem with the program after I made the last correction which I have posted above and this is what I have found. I have single stepped through the program looking at how the Trie was being built with an address that should have been found in the table but was not, the address was 12.106.65.236. The way the Trie is built is that it uses the first two parts of the IP to find the index into the main root node of the Trie that should hold this address; the Trie has 65536 such root nodes. In this case 12.106, bit shifting the first part of the address, 12, 8 bits to the left will result in a value of 3072. Now adding the second part of the address to the first part results in an index of 3178 in the Trie array of nodes. Now the range of valid IP’s is determined by the IP address plus the field 4 of the line from the file, for example:

s|US|ipv4|12.106.65.88|182040|s|s

The above line is from your combined.latest file. Note that field 4 has a value of 182040 and needs 18 bits to represent it but only 16 are available for use and so the way the Trie is written it will use the base address itself to store the node. Therefore when you go to see if the node 12.106.65.236 is valid it will not find it because the Trie only knows about 12.106.65.88.

I did not verify that all of the approximately 500 values that were Not In Database were for the same reason but what I did do was to download the most current versions of the files from “The Address Supporting Organizations” web site  at http://aso.icann.org/stats/index.html and used them in place of your combined.latest file. The result was that the file your program creates did not have 1 “Not In Database” message in it.

I hope that this was of some help to you.

Fernando
0
 

Author Comment

by:gr8life
Comment Utility
Thank you for all your help.  

I am going to look at the changes tomorrow and again THANK YOU!!

Gr8life
0
 

Author Comment

by:gr8life
Comment Utility
Works excellent

THANK YOU VERY MUCH!!
Gr8life
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
No problem, always glad to help. ;=)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now