application of data structures & algorithms in...
TRANSCRIPT
D T V R A M A K R I S H N A R A O S E N I O R T E C H N I C A L A R C H I T E C T
P R O D U C T E N G I N E E R I N G D E P T
I N F O S Y S L T D
Application of Data Structures & Algorithms in Networking
Introduction
It is a good idea to question why we are learning what we are learning?
Objective & Agenda
Objective
Is it worth learning Data structures & Algorithms?
Is what we are learning actually used in Industry?
If so, how?
Agenda
Consider various topics in the course and identify where it is used in networking domain
In our data-to-day work, how we deal with algorithms
Varieties of Uses of what we are learning
Overview of Networking Industry
Network industry is vast
Its software development is vast
Types of Business
OEMs
Service Providers
We focus on networking devices software
Ethernet switches
DSL Access Multiplexors
IP routers
Pizza Box Modular Chassis
Ethernet switches
Source: Wikipedia
Linear data structures
Stacks, queues, singly linked lists, doubly linked lists
Very commonly used
Linked lists are more common than arrays to maintain stacks or queues
To have flexibility in the number of entries and for memory efficiency
Stacks
E.g., Conversion of recursive routines to non-recursion
Queues
Managing IDs
Trees
AVL trees/Splay trees
To make searches faster and also need sorted order (e.g., subscriber table, OSPF neighbor table)
Tries
Used in radix trees for maintaining routing table
Longest prefix match
Hashing
Used when order is not important but Lookup needs to be fast
Hashing for MAC table
Sorting and Searching techniques
Lot of lists are maintained List of users, MAC addresses, List of neighbors, etc
Searching E.g., When someone logs out
Linear search is common Binary search is rarely used Sorting
E.g., to display list of users in a show command E.g., to show the forwarding table used for switching
SNMP wants tables in sorted order If the table is not kept sorted, then you need to sort it for SNMP use
Quick sort is sometimes used In general, it is common to use the sorting data structure (e.g., tree)
rather than sorting on the fly Sometimes a structure is kept under multiple data structures
Dynamic Programming
Dynamic programming is a method for solving complex problems by breaking them down into simpler sub-problems
Used in the routing protocols
RIP
Finds the optimum route by exchanging distance information with neighbors
DVMRP
Multicast routing protocol
Graph Algorithms, Shortest Path algorithms
Shortest path algorithms are common in networking
A network is a graph
Shortest path algorithms used in OSPF
Name itself includes the algorithm name – Open shortest path first
IS-IS
Yet another routing protocol based on Dijkstra’s shortest path
Spanning Trees are used in STP
Name itself stands for spanning tree protocol
For avoiding loops
String matching algorithms
Networking devices deal with strings
They support regular expressions
The commands support grep operation
Many debugging tools use string matching
E.g., log file analysis looking for patterns
Cryptographic algorithms
Security is extremely important for networking devices They are full of cryptography algorithms Security Aspects Confidentiality Integrity
SSH instead of Telnet Supports authentication using cryptography Uses DES etc
IPSEC instead of bare-bones IP Supports encryption (e.g., AES)
OSPF uses MD5 hash for integrity Almost every protocol has to deal with security aspects
Parallel algorithms
Multi-cores are getting important for Networking
Two ways
Each processor will run a set of processes
Split a process so that we can make it faster
GP-GPUs use 100s of processors
They need parallel algorithms
Many cryptography algorithms are implemented in parallel fashion on GP-GPUs
There are more algorithms…
The algorithms in the course are not enough
More algorithms are used in industry
Example: Distributed Algorithms
Is the peer dead?
Avoid Synchronization using Randomization
The algorithms course is a pre-requisite to catch-up with the new algorithms that keep coming in industry
Creating new Protocols
Industry creates new protocols
Algorithms are part of many protocols
For Internet, protocols are described in RFCs
At Infosys, we have published about 4 RFCs dealing with protocols for DHCP and Multicast
Industrial Use
Selecting & Implementing the Algorithm
First time when code is written
To Improve Performance
Use of Libraries
Libraries are common for data structures and algorithms
E.g., CDT http://www2.research.att.com/~gsf/download/ref/cdt/cdt-spe.pdf
Debugging the code involving the algorithm
Need to know the data structure & algorithm
Selecting an Algorithm
Should know how to make trade-offs
Need to know when to use which algorithm
Code Tuning
Very common
Porting of Code is extremely common From Pizza Box to Modular chassis
Performance drops noticed Analyze existing code
Complexity analysis
Find Bottlenecks
Use New data structures or Algorithms
Low level code tuning E.g., Constant folding etc
Better left to optimizing compiler
What do you learn in your course
Data Structures
Stacks, queues, trees, etc
Algorithms
Sorting algorithms, Cryptographic algorithms, etc
Techniques
Divide-and-conquer, Dynamic Programming, etc
Varieties of Uses of What you are Learning
Direct Use of Data structures & Algorithms
Learn how to learn
New Needs Arise
Need to learn new data structures or algorithms
Learning to design new algorithms
Learning new algorithms
Perspective
This is just one-person’s view of what he has come across on data structure & Algorithms in networking industry It is based on what I could recollect
It is not complete in that sense
It is not complete with respect to networking itself Others might have come across more or different algorithms
Of course, it totally ignores non-networking domains Data structures & Algorithms is common in many domains
E.g., Banking & Financial services
Lot more algorithms than what I covered are regularly used in industry
Further Study
“Interconnections”, Radia Perlman, Addison-Wesley
“Network Algorithmics”, George Verghese, Elsevier
Conclusion
Data structures & Algorithms is a basic building block for a software engineer’s career in industry
Questions?