How to get list of IP address which are subset are super set of a given IP address from CosmosDB Container or any SQL DB table - network-programming

I a have table which contains column which has array of IP address , I have to retrieve the list of IP address which are subset or superset of the given IP address.
Looking for solution in C#
Table
If the incoming request IP address is 10.94.192.163/29 then i have to get all IP ranges present in table which are subset/ superset of this IP address.
This is requirement to ensure no duplicate IP address should be inserted, before insertion if any related IP is present then update the same row for other columns.
what is the best solution for this.

Related

Log Parser Studio Query - IP address by most recently accessed?

I'm trying to look at the IIS logs with Log Parser Studio to determine how recently some IP addresses have accessed a website. I've used the following query below to at least get myself a count over the life of the logs:
select c-ip, count(c-ip) as requestcount from '[LogFilePath]' group by c-ip order by count(c-ip) desc
I'm having trouble modifying this to pull IP address information with a 'last accessed' date. Is something like this possible? or is there a better way to go about achieving what I want?
Ideally I'd like to utilize this query to audit the logs and after X amount of days of inactivity from an IP address....revoke access based on IP address (remove access at the firewall, IP addresses are on a whitelist).
Due to the nature of the website/application, there may be times where an IP doesn't access for 90-120 days so using a simple 'hit count' doesn't work. It could be easy to mistakenly remove access for a still valid IP address and the hit count is reset when the firewall is rebooted.
Thanks in advance.
Add in MAX(DATE) to the query.
select c-ip, count(c-ip), MAX(DATE) as requestcount from '[LogFilePath]' group by c-ip order by MAX(DATE) desc

how does an inverted page table deal with multiple process accessing the same frame

I've seen the other posts but none has the same problem, So from my understanding an inverted page table's entry depends on both the process id and virtual page number, in the actual page table if the information of both the process id and virtual page number matches then the index is the physical page number/frame number. my question is what happens when more than 1 process needs that frame/physical memory. you can't store both id or vpn in the same index
Interesting question! My guess is that this is one of the reasons that inverted page tables aren't very popular.
One solution could be to append a "shared" bit to each entry and create a hash table for each pid. When a page frame with the "shared" bit set is encountered, the MMU should trigger a fault that will cause the OS to use the pid of the requesting process and the virtual address to index into the hash table. At this point, its the same behavior as the global hash table, where the hashed entry contains the pairs.
An upside to this is that we can still use the pid field in the page table entry, so 1 of the shared pids will hit.
Some downsides are that the hash table per pid could be the same size as the global hash table, so we effectively increase the size of the global hash table by 2^16 (or however many pids are supported)! Of course, the hash table per pid probably won't be that large, so we could dynamically change the size based on how many entries are in use. But, this has its own side-effects, where we may have to evict other pages whenever we want to increase the size.
I'm sure there are better solutions out there, and I would love to hear them.
Another possible solution:
Add a "remap" bit to the page table entry. If a page table entry has this "remap" bit set, the given physical address is not the real physical address, instead its the index into the Remap Table. The Remap Table is a software-controlled data structure that contains mappings from indices to physical addresses. It is shared by all processes, as a page table entry already has the pid. The size of the Remap Table is dynamic; the Remap Table can reside anywhere in contiguous memory, pointed to by a Remap Table Base Register. The Remap Table Tail Register keeps track of the top of the Remap Table, which can increase or decrease.
When a brand new shared page table entry is created, it should be created as a standard page table entry with pid, physical address and virtual address. When other processes request a page for this shared physical address, they should have a page table entry created with the "remap" bit set, and with the physical address pointing to their remap table entry. Software can determine the remap table entry by searching from the base to the tail for any available entries. If none are found, software should increase the tail pointer, evicting the page residing there, if necessary. This remap table entry should contain the physical address of the shared page.
When removing a shared page table, software should remove the remap table entry. If the remap table entry to be removed is at the top of the remap table, software should decrease the Remap Table Pointer to the highest valid entry.
Simplest Solution:
Just create another page frame entry for all of the processes that share that same page table. They should have the pid and virtual address specific to that process, and the same physical page frame number of the shared page. This page table entry should have a "shared" bit that indicates it can be / is being shared with other processes, and that it should be written back to disk when it is evicted. This way, when each process' page table entry is removed, they will each write back the contents of the shared page to disk. This will result in n-1 (n being the number of processes sharing the page) "wasted" write backs, but it avoids the overhead of trying to keep track of all of the processes sharing a page.
A simple solution is to map only one virtual address to shared physical address in page table ,so other virtual address references mapped to same shared physical address will result into page faults.(source-Operating System Principles-Galvin)

Neo4J query to find same data link to different nodes

Following is what I created in Neo4j:
Nodes: Customer Names, Customer Address and Customer Contact
Linked these nodes based on common relationships between all three.
I can see all three nodes linked in Neo4j. Contact contain email and phone numbers so some cases customer name node is connected to email address, phone number and address.
In my learning curve I am asked to show how many same contacts are used by different customer names also how many same address used by different customer names. Based on my little experience I tried few queries but couldnt reach to results.
Tried following query -
start n=node(*)
match n-[:CONTACT_AT]-()
return distinct n
CONTACT_AT is the relationship between customer name and Contact (email, phone) node.
Your question does not provide enough information about your data model. To save time, I will assume that it looks something like this (without showing all the properties):
(a:Address)<-[:ADDRESS_AT]-(p:Person {name: '...'})-[:CONTACT_AT]->(c:Contact)
With this model, this is how you'd get all the names of the people who have the same Contact:
MATCH (person:Person)-[:CONTACT_AT]->(contact:Contact)
RETURN contact, COLLECT(person.name) AS names;
And this is how you'd get all the names of the people who have the same Address:
MATCH (person:Person)-[:ADDRESS_AT]->(address:Address)
RETURN address, COLLECT(person.name) AS names;

Address dimension or not?

My team is debating internally whether or not we should be creating a separate dimension of address information. The use case is a warehouse for a mail marketing agency, so address is quite important for a multitude of reasons.
We have a couple of pieces of address information flowing in (like Bank address, Customer Address (Our Client's customers), Mailing List Address (or Manifests), And Client Address. We might also get information in bits and pieces from other information that we might need to tie to a specific customer based on address comparisons.
We also do geocoding on our addresses to augment, standardize and validate our addresses that come in.
In total, we are storing the following fields for any given address:
DeliveryLine1
DeliveryLine2
LastLine
DeliveryPointBarcode
StreetNumber
ApartmentNumber
ApartmentUnitType
StreetName
StreetSuffix
Locality
Region
ZipCode
ZipCodePlusFour
DeliveryPoint
DeliveryPointCheckpointDigit
Latitude
Longitude
RecordType
ZipType
CountyFIPS
CarrierRoute
ResidentialDeliveryIndicator
Precision
DPV
Vacant
Active
EWS
thats 27 fields in total.
My colleague is of the opinion that address should go into each dimension (Customer, Bank, Client, Manifest). While I agree that in simple cases where we store Address1, Address2, City, State, Zip it would make sense, but we store a significant amount of added information about an address, with more bits and pieces being added later on (potentially). I make the contention that something like this would be better suited as a separate dimension. Any thoughts?
Looking from dimensional modelling point of view, your fact tables should answer to this question. If your [mail marketing] facts relates to addresses then go ahead and make Address as a separate dimension. I mean, if you do [a mail marketing] to Banks, to Customers, to Mailing List Addresses and Clients and want to analyze information based on Geo information (that is on Address) then it should be created as a separated dimension. However, if you [usually] mail market only your CLients and use an address for other purpose, i.e to find nearly Customer, Banks,etc, then I don't see much value to make an Address as a dimension. In essence, if your facts are related to Addresses to the same level as targets (Banks, Customers, Mailing List Addresses, Clients) then it should be a dimension. If that means nothing but just an attribute of Bank, Customer, Mailing List Address or Client then no need to go with a dimension.

Reading SNMP Object index of type IPAddress

In a simple SNMP table like mib-2.interfaces.ifTable, ifIndex is the index for the table, so you read ifIndex.1 (i.e. read value from direct child nodes of ifIndex) to get the index for the first row of the table. Simple enough.
But it's not as obvious with something like mib-2.ip.ipRouteTable. In that case ipRouteIfIndex is the index column. It's defined as INTEGER just like ifIndex was. However, you can't read the direct child nodes (i.e. ifIndex.0 is a direct child), but instead need to read ifIndex.0.0.0.0 to get to the value. So how does one know how to find the value when it's not a direct child of the index column?
There is some concept that I'm not understanding. (Probably having to do with the fact that SNMP objects are delimited by . but so are IP addresses, and I can't tell how to recognize the difference).
Note that you have a table with multiple indices in this particular case.
The fact is that you cannot directly read the table entries with snmp-get service, since the index is dynamic (and, as a consequence, the OID address). But you can discover the values with snmp-get-next (v1) and snmp-get-bulk (v2) services.
For example, you can read the indices (and store them for querying table items later) or directly read the items of the table :
you ask snmp-get-next for IP-MIB::ipAdEntNetMask
the reply will be IP-MIB::ipAdEntNetMask.172.16.38.42 IPV4 255.255.0.0
(So: first index is 172.16.38.42 in that case!)
you iterate and ask next value after IP-MIB::ipAdEntNetMask.172.16.38.42
the reply will be IP-MIB::ipAdEntNetMask.172.16.11.43 IPV4 255.255.0.0
etc.. until there is no other value, or the value is not on the same tree
The service snmp-get-bulk will enable you to query N values directly in this way.
Have a look at Net-Snmp's snmptable that does good job with tables : http://net-snmp.sourceforge.net/wiki/index.php/TUT:snmptable

Resources