filtering traffic belonging to particular subnets (title may be misguiding)

say we have a cell array of nx1 strings, i.e ip addresses.something like
'69.35.34.28' '89.23.180.34' '69.35.24.10' '123.35.82.12' '129.24.78.24' '89.23.193.12'
i have to uniquely filter out each subnet like
'69.35.xxx.xxx' - 2 occurences '89.23.xxx.xxx' - 2 occurences '123.35.xxx.xxx' - 1 occurence '129.24.xxx.xxx' - 1 occurence
the input is taken from a text or xls file. solutions ??

 Accepted Answer

You cannot do this without knowing where the subnet boundaries are.
Yes, you could use the obsolete "Class A", "Class B" definitions, but if you do that then 129.24.78.24 is Class C and would imply a subnet of 129.24.78.x rather than 129.24.x.x
Your entire series of questions on subneting and packet filtering would have gone much more smoothly if you had adopted CIDR early on.

3 Comments

sir , i want to sort all on the basis of class b . i.e no matter what the actual subnet is i want to sort all of them in the form of 129.24.xxx.xxx only.
Use string manipulation or regexp() to strip out from the second '.' onward. Use the three-output version of unique() on the resulting cell array of strings. Take the indices returned by unique() and either accumarray() with them or histc() them to get your counts.
yeah well thanx , never heard of accumarray .. will implement it soon

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!