Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > PHP/MySQL/Scripting

  • Print
  • + Share This
Like this article? We recommend

Creating the LSP

Let’s now see the code that runs in the NMS to create LSP123. Listing 2 illustrates the base Connection class.

Listing 2 Connection Class

class Connection {
  Connection() {};
  char* Path;
  int resourceId;

As you can see, the Connection class is pretty generic. An object of this class has only a Path and a resourceId. We need a little more to model an LSP.

The LspConnection class is a subclass of Connection, as illustrated in Listing 3.

Listing 3 A Subclass of Connection: spConnection

class LspConnection : Connection {
  explicit LspConnection(int Id, int lspPreference, int pathId);
  ~LspConnection() { }

  const int getLspId() { return lspId; }
  const int getLspPreference() { return preference; }
  const int getLspPathId() { return pathId; }

  int lspId;
  int preference;
  int pathId;

Listing 3 augments the subclass with the addition of some LSP-specific member functions and a new integer data member called preference. (You’ll see what the purpose of these are shortly.)

Listing 4 illustrates the type of code that is typically used to create an LSP object.

Listing 4 Instantiating an Object of LspConnection

LspConnection* lsp = new LspConnection(1, 0, 1);

In Listing 4, the three integer parameters passed to the LspConnection() constructor are Id, lspPreference, and pathId respectively.

The Id is internal to the NMS and is used to keep track of all the LSPs under its control. You create an LSP, and the NMS automatically assigns an Id value. The lspPreference is a parameter that reflects the importance of this LSP with respect to other LSPs in the network. Remember the signaling process mentioned above? If a future LSP is signaled with a higher preference than that of LSP123, it’s possible that LSP123 might be torn down to make way for the new, more important LSP.

Finally, the pathId reflects the required path taken by LSP123 (R2-R3-R4-R5). In many cases, the path is stored in a separate database table, and the pathId is a reference to the appropriate path.

We’ve now covered all the background needed!

  • + Share This
  • 🔖 Save To Your Account