0% found this document useful (0 votes)
107 views12 pages

Socket Programming Interview Insights

The document contains a series of programming tasks, algorithms, and theoretical questions related to data structures, networking, and system programming. It covers topics such as linked lists, binary trees, semaphores, mutexes, OSPF, and various programming challenges. Additionally, it includes questions about memory management, process/thread management, and performance analysis in software development.

Uploaded by

prabhakarraoc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
107 views12 pages

Socket Programming Interview Insights

The document contains a series of programming tasks, algorithms, and theoretical questions related to data structures, networking, and system programming. It covers topics such as linked lists, binary trees, semaphores, mutexes, OSPF, and various programming challenges. Additionally, it includes questions about memory management, process/thread management, and performance analysis in software development.

Uploaded by

prabhakarraoc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd

1.

Write a program to add two numbers which are represented as linked lists

list A: 1->0->2->3
list B: 3->5

Result: 1->0->3->8
Need recursion logic

2. Write a program to print different permutations of a given set


{1, 2, 3, 4}

{1} {2} {3} {4}

{1, 2} {1, 3} {1, 4} {2, 3} {2, 4} {3, 4}


{2, 1} {3, 1} {4, 1} {3, 2} {4, 2} {4, 3}

{1, 2, 3} {1, 3, 2}, {1, 2, 4}

/*Only some permutations listed above. All permutations should be printed */

3. What is process and What is Thread


4. States of a process
5. What is a Semaphore and What is a Mutex. Differences between them
6. What is DMA
7. OSPF split brain issue
8. RIP vs OSPF
9. Write a program to find sum of all elements in a tree (some nodes have more than 1 parent)

1. There is an advertising system which calls a list of mobile numbers


which are in incremental order. If the call receiver marks it as
DO NOT CALL ME, the advertising system should not call the callee
next time. How will you implement it.

2. Try implement the above using BITMAPS

3. Write a program to provide the common parent of a given node in BST

4. When do you use threads and when do you use processes (fork())

4. #define SQRX (X) (X*X).


Is the above macro correct or does it have any problem.

5. Write a program to reverse the words in a given sentence


Input: This is a network
Output: sihT si a krowten

1. How nexthop is selected in BGP


2. How a router in Area 0 reaches a destination in another area.
What actually happens inside an ABR
3. A computer receives multiple UDP packets from different clients.
It has to receive all UDP packets, process them and send them to a
different system (which uses the info for any purpose). How do you
do it.

2. Write an algorithm/program to calculate product of two numbers without using '*' operator
3. Write an algorithm/program to make anagrams of given word.

1. Write a program to find the predecessor and successor of a node in Binary Tree

1. Write a program to combine two strings in below manner


str1 = "abcd"
str2 = "efghijk"

Result: "aebgcgdhijk"
1. What is a Semaphore and What is a Mutex. Differences between them.
2. Write the pseudo code for different operations on semaphore (P & V operations)
3. What is Virtual Memory. Limit of virtual memory on 32 bit and 64 bit
4. What is Thrashing
5. Write the code for function 'myStr' to get the below desired output

... myStr(....)
{
/* Write code */
}

int main()
{
char *str = "this is a string";

myStr(....);
printf("string = ... ", ....);
return 0;
}

Output: this is a string


6. In above program, please explain how the variables are placed in memory layout of C program

1. Sum of odd divisors of a given numbers

39 = 1, 3, 13, 39
Sum = 52

2. Longest Palindromic substring length in a given string

1. What happens if you configure priority '0' on an interface.


2. Will the session come to Full state?
3. Why do we need two stages in SPF Calculation?
4. What is the difference between pointtomultipoint and NBMA?
5. OSPF vs BGP
6. OSPF vs iBGP
7. How do you simulate HUB and SPOKE in OSPF

1. Write a program to reverse words in a sentence


Solution: [Link]
2. How VRRP works and how does it resolves the ARP for virtual ip
3. Convert a BST into Linked List
4. ls | wc
Write a small program to implement above using pipes.
5. Output of below program snippet:

char c = 128;
printf("%d", c);
6. Size of below structure:

struct sample {
char a;
char b;
char c;
short int d;
};
7. Explain structure padding and packing. What needs to be done for less memory allocation and efficent usage of structures.
8. Explain how and where OcNOS/ZebOS is deployed on your hardware/processor. (Something related to platform)
9. How do you detect a loop in a linked list, how do you find the length of the loop and how do you break the loop.
10. What is a RAW socket. How it works
11. What are different IPC mechanisms.
12. Given a set of 20 numbers which lie between 0 and 1000. Fastest way to search whether a particular number is present in given set or not.
13. Write a sample program to find the size of a datatype on a given architecture.
14. Write a function which takes rows and columns as parameters to allocate dynamic memory to a 2D array, return the right data type/pointer and use it in main() function.
15. What is the time taken in worst case to search an element in a BST. What can be done to minimize the search time.

17. What are your strengths. Give an example for each of your strengths mentioned

1. Steps involved in packet processing


2. How many processes are created in below program:

for (i=0;i<2;i++)
fork() ;
3. char *ptr ="ABCDE" ;
Where the value ABCDE is stored in C program's memory layout.
4. What is Structure Padding. What is the size of below structure:

struct sample {
int a; Size of int is 4 bytes
double b; Size of double is 8 bytes
char c; Size of char is 1 byte
};
5. char *ptr =malloc(10)
What does ptr store? When free() is called, how it knows how many bytes has to be freed?
6. Difference between a MACRO and Inline function
7. What is the difference between exit(), abort(), assert()
8. How a system call works. What are the steps involved in it.
9. When fork() is used to create a child process, what are shared between parent and child processes?
10. How bit fields are used in a structure? What are the issues faced while using bit fields?
What precautions has to be taken while using bit fields.
11. Write a program to find max width of a Binary Tree
12. What are different IPC mechanisms.
13. Why only message queues are selected to exchange route messages in your product
14. Differences between Linux and FreeBSD
15. What are blocking and non-blocking system calls.
16. Swap two two bits in an integer.
17. Swap two nibbles in an integer.
18. Find second frequent repetitive character in a string
19. Write a program to reverse words in a sentence
Solution: [Link]
20. Find middle location of a linked list.
21. How do you deallocate memory without using free() function.
22. How do you analyze memory corruptions
23. Using GDB to analyze Assembly code instructions
24. What are AVL trees.
25. Explain how Patricia insertion or how Patricia trie works
26. What is paging.

1. Which sorting technique you use to sort below array and why?
{1, 0, 1, 1, 0, 0, 1, 0, 0, 1}
2. How to calculate max sum in below array
{1, 2 -3, 10, -4, 6, 7, -8}
3. Write a program to find whether given Binary Tree is Binary Search Tree or not.
4. Program to identify whether a given string is Palindrome or not.

1. Longest Prefix Match and it's algorithm for Ipv6 addresses


2. What is Unix socket and what are the calls involved in it.
3. What is circular queue. How do you implement it
4. How OSPFv3 process is upgraded in a customer deployment.
5. Architecture of ZebOS
6. What are AVL Trees. What is meant by O(Log N)
7. How processes communicate each other.
8. Why lib/thread.c is not pal_ calls.
9. Why multiple threads are necessary when your product is a single threaded architecture
10. Does Windows have threads?
11. What is VPLS
12. What is Vxlan-EVPN. How does it works
13. What is VPLS
14. What is the recent performance issue you have handled

1. Tell me about your work experience


2. What is VRRP. How it works
3. How VRRP routers know that Master router is down
4. What is VRF. How data plane seperation is done in VRF
5. How software upgrade is done in customer location
6. What is ZTP. How it is implemented. Do configurations also can be pushed from server in ZTP or only software upgrade can be done
7. What model you use in NetConf. Have you implemented any NetConf stuff
8. Does data plane runs on same processor or different ones like ASIC or seperate network processor
9. What is the most recent complex issue you have worked on.
10. How protocol modules communicate
11. What happens in background when a command is issued. How a command is processed
12. What are Dockers and Containers. What are their advantages
13. How a best route is installed in RIB. What is the criteria
14. Whar are the features/enhancements you have worked on

1. Toggle a bit
2. Program to sort a given linked list (possibly with O(N) time complexity
1. What are the things you observe in output of 'top' command
2. What is Swap memory
3. Write a program or explain how do you implement priority queues using message passing between two asynchronous process
4. In IP header, checksum field is calculated for what all fields?
5. Write a python program on how to make a dictionary using two different lists without using for loop (you can use lists, map, lambda etc)
6. What is a map in Python
7. How do you implement Exception Handling in C. Write a macro and a function to handle division by '0' case.
8. Explain BGP state machine. What are different BGP packets
9. What is Binary Semaphore. Differences between Binary Semaphore and Mutex

1. Pairwise summation related program in C


2. 10 MCQ questions on snippet of program and its output

1. How ping packet travels. What are the steps involved.


2. How do you determine whether a packet is routable or not.
3. What is VLAN. How it works.
4. Write a small program to find the Nth node from tail of a linked list (without finding length of the full list)
5. How do you determine the duplicate elements in a given linked list
6. Explain what happens at each host and router.

HostA-------RTR1-------------RTR2-----------HostB
7. How does a MAC table look like. What are the fields and contents present in it.
8. Why and how do you use GDB to debug processes. How do you analyze a crash if debug logs are not available.

1. Output of below program 2. Output of below program


int a = -9; void *ptr;
unsigned int b = 6; ptr = malloc(0);
if (a+b)
printf("+ve"); 3. Why and how Volatile and Const keywords are used.
else 4. How do you delete the third element of the linked list. Pointer to NODE 3 is available. HEAD pointer is not available
printf("-ve"); 4->3->2->1->NULL Output: 4->3->1->NULL

4. How do you analyse/debug a crash using GDB.


5. What are the steps involved in developing a Feature/Enhancement in your product
6. How do you detect duplicate code or logic in entire code
7. How do you measure performance/stability of your product while adding a new feature or enhancement

1. Swap two bits of an integer Puzzles


2. Reverse all words in a sentence 1. 3 bulbs and 3 switches.
3. Toggle a bit 2. 100 coins and 7 bags
4. Size of a given structure without using sizeof()
5. Implement a stack using two queues
6. How do you implement circular queues 25. Determine Path MTU using socket programming
7. Priority inversion
8. Mulithreading
9. What are different IPC mechanisms
10 How shared memory works b/w different processes
11. How a system call works
12. How hashmap is used
13. Where do you see stack implementation in your daily work
14. What is RIP
15. What are the differences b/w OSPF and BGP.
16 Reverse bits in an integer
17. Questions on padding
18. Sockets
19. Given string = "abcdae"
Total string length = 27. So the final string is abcdaeabcdaeabcdaeabcdaeabc
Program to find how many times character 'a' apprears in total string
20. Remove a node from a linked list without having a HEAD pointer
21. Ping works at which layer. How do you perform a L2 Ping
22. What is Half Closed TCP connection
23. What is TCP Four-way handshake mechanism
24. Merge point of two linked lists

1. Explain OSPF router LSA and its fields


2. What are the enhancements you have worked on
3. Convert an integer to an IP address

1. Program to display an integer in binary format


2. Program for different operations on a stack
3. Delete a node in a linked list when head pointer is NOT given
4. Delete repeated characters in a string like below
Input - aabbccddeeaaafff
Output-abcdeaf
5. Multithread program where one thread prints ODD number and one thread prints EVEN number
6. Toggle all bits of a given number
7. Find the distinct element in the given set where all are repeating and only one element is NOT repeating.
8. What is Volatile keyword
ADDTRON
1. Dynamic binding
[Link]
3. Singleton class
4. Design pattern
5. Vector, Iterator
6. Friend class
7. Abstract class
8. static member variable
9. difference between process & thread
10. what happens during processor context switch
11. Fastest IPC, why it is fastest (shared memory)
12. IPCs used in your projects, communication between processes in ur project
13. Virtual functions
14. Remove duplicates in sorted linked list
15. Result linked list from 2 intersect linked list
16. toggling kth bit in interger
17. toggling bits 2 - 5 from a given integet
18. timer implementation in SSR
19. volatile in c++
20. how ping works
21 how traceroute works
dhcp relay agent
control messages exchanged during dhcp
UDP sockets
Different type of sockets and difference between them
raw sockets how will be used
how does tcp provides reliab
how tcp provides reliable service
udp socket calls
tcp sockets used by an example application
how pppoe packet in payload got determined from ethernet frame
3 way handshake in TCP
ethernet/ppp packet formats
device a to device b arp resolution, contents of the packets exchanged
1. Brief about overall experience
2.C program memory layout
[Link] classes in c
[Link] is structure padding
[Link] fields in c
[Link] and dynamic libraries differences
[Link] is memory leak and how do you detect
[Link] do you analyse core dump
[Link] is the difference between process and thread
[Link] are thread system calls
[Link] is fork and vfork
[Link] of IPC in Linux
[Link] between pipes and other ipcs
[Link] is the fastest IPC
[Link] is race condition
[Link] is deadlock
[Link] is mutex
[Link] between Mutex and Semaphore
[Link] types of Semaphores
[Link] connection establishment sequenCe
[Link] connection termination sequence
[Link] System calls for TCP server
[Link] is accept system call
[Link] is blocking or non blocking by default
[Link] do you make accept as non blocking call
[Link] do you handle sockets if accept is made non blocking

[Link] me about your self


[Link] me about your work experience Role/type of products
[Link] how routing table is updated using OSPF protocol
4 Explain about ARP Protocol
[Link] will happen if we have only switches in the internet instead of Routers.
[Link] routing table is implemented.
[Link] a c program to detect loop in a linked list
[Link] a c program to reverse a string
[Link] a c program to reverse a sentence "he is very good" convert to "good very is he"

[Link] OSPF state Machine


2. H1 is connected to AS1 H2 is connected to AS2.ASBR1 in AS1 is connected to ASBR2 in [Link] How H1 can co
[Link] control plane and data plane
[Link] about Ericsson modules worked and Ericsson Router architecture
[Link] about Zebos architecture
[Link] about the bugs worked on Ospf and ISIS
[Link] packets with different hello interval come to [Link] the queuing system in the router to process these
[Link] can we know that data has come to a socket
[Link] can multiple clients can be handled in a server
[Link] Split brain for DR election
[Link] a program with two threads where one thread forms the packet and another thread sends the packet and r

[Link] ospf state machine


[Link] between OSPF and BGP
[Link] Routing table is implemented
[Link] is port mirroring
[Link] is native vlan
[Link] is the processor used in router
[Link] how packet which arrived at interface will be delivered to ospf process
[Link] about Ethernet header fields
[Link] some crucial bugs solved in ospf
[Link] vs threads

[Link] of the structure


struct nde {
int a;
char b;
shrt c;
duble d;
char e;
}

[Link] two variables with out using 3rd variable


[Link] sort program
[Link] of elements in an array using sizeof()
[Link] Memory initialization for 3x4 Array
[Link] the no of set bits in a number
[Link] to check the 7th bit in a number is set or not
[Link] pointer declaration syntax
[Link] a function using function pointer.

[Link] about How Lacp works


2. Five Differences between OSPF,BGP,RIP
[Link] can we say OSPF has faster convergence when compared to RIP
[Link] packet types
[Link] OSPF fixes
[Link] between OSPF and ISIS
[Link] is administrative distance
[Link] about TCAM
[Link] FIB is updated
[Link] system calls both at server side and client side
[Link] about usage of select
[Link] a recursive program to find the sum of digits in an integer
[Link] a recursive program to find the sum of digits in two linked lists
[Link] a program to find whether nth bit in a number is set or [Link] the nth bit is set then reset it
[Link] a program for little endian to big endian conversion
[Link] for max(a,b)
[Link] for max(a,b,c)

[Link] about your experience


[Link] ospf operation
[Link] me explain ospf bugs fixed
[Link] are the IPC mechanisms
[Link] is the difference between pipes and message queues
[Link] is shared memory
[Link] is a thread
[Link] between threads and process
[Link] do you synchronize shared memory
[Link] is a dead lock
[Link] is a socket.

[Link] is the protocol used in AAA


[Link] is the authentication mechanism used in AAA
[Link] states
[Link] packet types
[Link] bugs solved in ospf
[Link] System calls at server side
[Link] do you handle multiple clients using sockets
[Link] the logic how to count the repeated words in a paragraph

[Link] the design considerations for UDP application


[Link] in detail the socket system calls at server and client side
[Link] are the scenarios when RST will be sent
[Link] three way handshake
[Link] the server is not running what happens to the connect at client side
[Link] is the port number used for ospf
[Link] about the recent bugs in ospf
[Link] a program to encode a protocol packet at sending side and decide the protocol packet at receiving side.
[Link] a program to toggle the bits after nth position in a manner
[Link] a program for longest prefix match

1. Differences between Thread and Process


2. What fork() system call returns to Parent Process
3. Socket system call at server side to handle multiple clients. Explain with detailed code flow
[Link] to find maximum of a and b .
5. Reverse a string in C
6. Reverse a string in C using recursion
7. "Hello World"
Remove one space and two 'o' s in naive string
8. Explain Vrrp protocol in detail

1. Ospf packet types


2. Crucial OSPF bugs which are recently resolved
3. Questions related to AAA and PPP and Ericsson SSR infra
4. How do you debug a program
5. How do you debug a process crash
6. How do you analyze and resolve a bug.

[Link] arp works


[Link] header
[Link] of vlans
[Link] are the fields in the mac table
[Link] happens when a switch receives unknown destination
[Link] between semaphore and mutex
[Link] a program to find whether a machine is little endian or bigendian
[Link] to find the intersection point of two linked lists
[Link] do you debug threads using gdb
d very is he"

[Link] How H1 can communicate to H2.

e router to process these packets


ad sends the packet and receives the response
ket at receiving side.

You might also like