Introduction to the network data structure

The data structure that we are implementing resembles a network of nodes, one of which is the primary node. Additionally, each node contains a key and a value for the node. You can think of this data structure as a Python dictionary (in other words, a set of keys and values respectively paired together), but one of these key and value pairs is called the primary node of the network.

A good way to visualize this data structure is to analyze a situation in which the data structure is utilized. Suppose that you have been asked to implement the request handling logic of a popular website, which is also, unfortunately, a common target for denial of service (DoS) attacks. Since it is highly possible that the website will be taken down fairly frequently, despite the efforts of the cybersecurity team, an approach that you could take to guarantee that clients of the website will still be able to access it is to keep more than one working copy of the website, in addition to the main website, on the server.

These copies are equivalent to the main website in every way, and the main website can therefore be completely replaced by any of the copies at any time. Now, if and when the main website is taken down by a DoS attack, you, as the server administrator, can simply allow the main website to go down and switch the address of the new main website to one of the copies that you have ready. The clients of the website will therefore experience no difficulty or inconsistency when accessing the data from the website, since the copies are identical to the main website that was taken down. Servers that do not implement this mechanism, on the other hand, will most likely have to spend some time recovering from a DoS attack (isolating the attack, building back the interrupted or corrupted data, and so on).

At this point, a connection between this method of web administration and the aforementioned network data structure can be made. In fact, the network data structure is, in essence, a high-level abstraction of the method; the data structure is a set of nodes or pairs of values (the website address and the data, in the preceding case), while keeping track of a primary node that can also be replaced by any other node (clients accessing the website are directed to a new website when the main website is attacked). We will call this processing refreshing the primary in our data structure, which is illustrated in the following diagram:

Diagram of network primary refreshing

In the preceding diagram, we have three separate notes of data in our network data structure (visualized as a dictionary, denoted by a pair of curly braces): key A, pointing to some data; key B, pointing to its own data; and, finally, key C, also pointing to its own data. Additionally, we have a pointer indicating the primary key of our dictionary network, pointing to key A. As the primary refresh process takes place, we will stop keeping track of key A (which is the primary key) and its own, and then have the primary pointer pointing to another node in the network (in this case, key B).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.176.145