25
DTV RAMAKRISHNA RAO SENIOR TECHNICAL ARCHITECT PRODUCT ENGINEERING DEPT INFOSYS LTD Application of Data Structures & Algorithms in Networking

Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 2: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Introduction

It is a good idea to question why we are learning what we are learning?

Page 3: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 4: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 5: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Pizza Box Modular Chassis

Ethernet switches

Source: Wikipedia

Page 6: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 7: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 8: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Hashing

Used when order is not important but Lookup needs to be fast

Hashing for MAC table

Page 9: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 10: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 11: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 12: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 13: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 14: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 15: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 16: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 17: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 18: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Selecting an Algorithm

Should know how to make trade-offs

Need to know when to use which algorithm

Page 19: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 20: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 21: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

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

Page 22: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different 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

Page 23: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Further Study

“Interconnections”, Radia Perlman, Addison-Wesley

“Network Algorithmics”, George Verghese, Elsevier

Page 24: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Conclusion

Data structures & Algorithms is a basic building block for a software engineer’s career in industry

Page 25: Application of Data Structures & Algorithms in Networkinggdeepak.com/IADSA/applicationsofdatastrucuturesalgorithmsinfosys.pdf · Others might have come across more or different algorithms

Questions?