Coding Assignment – TCP sender receiver communication with handling of duplicate and out of order packets.
Scenario: An application receives packets from a server on the network. Each packet belongs to a particular channel, and is also identified by a unique sequence number. Note that each channel has its own sequence number series. So if the server is sending data for 10 channels, you should expect to see packets starting with sequence number 1 for each of these 10 channels.
The network is such that after leaving the server but before reaching your application, these packets could be
- re-ordered; OR
- duplicated; BUT
- never dropped completely.
The goal of your application is to always apply the packet data in-order of (channel-specific) sequence numbers and without any gaps. Of course in the real world, there will be more work to be done, but we will ignore it for now.
You have to implement the function re_sequence_and_apply().
You can use any data structure for this purpose, including anything from C++ STL. If you write your own data structure, please supply the entire definition of that data structure with your solution.
Additionally, you will have also to implement the event_source interface to test your code the any way you wish to. Your solution will be evaluated on the basis of correctness, as well as, space and time complexity.
Round 2 (Around 35-40 minutes)
1. What is user mode and kernel mode?
—-> Kernel Mode
In Kernel mode, the executing code has complete and unrestricted access to the underlying hardware. It can execute any CPU instruction and reference any memory address. Kernel mode is generally reserved for the lowest-level, most trusted functions of the operating system. Crashes in kernel mode are catastrophic; they will halt the entire PC.
In User mode, the executing code has no ability to directly access hardware or reference memory. Code running in user mode must delegate to system APIs to access hardware or memory. Due to the protection afforded by this sort of isolation, crashes in user mode are always recoverable. Most of the code running on your computer will execute in user mode.
2. Why do you need kernel mode in case of single user system?
—> Think in terms of hardware resources and I/O resources allocation, Traps, system calls, Interrupts all takes place in kernel mode. For the execution of primitive and sensitive instructions, kernel mode is necessary.
3. Why operations of kernel mode can’t be executed in user mode?
4. Can two processes generate same virtual address? If yes, then will there physical address be different or same? Why same or why different?
5. What is trap? What is interrupt? Types of interrupt? How are they different? Do all traps requires switching between modes?
6. How threads of a process having different stacks will share resources? How will threads communicate?
7. In case on multi core, if T1 running on core 1 , T2 running on core 2, how will they synchronize and communicate?
8. Some code snippet in C++ was given in which P1 and P2 processes were generating some address. Address generated by P1 was initialized using dereferencing. Can P2 dereference it?
9. Questions on Stack pointer.
10. Code Snippets were given on printed sheet. Asked what will be output of the code. Mostly seg fault was there in the answers.
11. Some syscalls code was written but she explained me that code so patiently and then asked where is the error? I did not remember the code.
Asked if I want to ask anything. I asked 2-3 questions about the company and what will I be supposed to do? Asked about the work and profile and what company actually do?
She answered very interestingly. I liked it.
Round 3 (Around 1 hour)
Interviewer is just amazing. I did n’t feel uncomfortable even for a single second in this round. Discussion just went on and on. It was just amazing as per my personal experience.
1. Complete discussion on coding assignment. Strategy and data structure used.
2. Design Data structure to save a large number of incoming packets if you have memory constraints.
3. Where will you place Scheduler, Compiler, Dispatcher, MMU in the thread execution? Explain everything in detail.
4. Do you know assembly code? Assembly code you used in thread library? How will that invoke scheduler?
5. Segmentation fault can occur if you try to access address 1 incremented by stack pointer as in SP= Sp +1?If yes, why? If not, why?
6. Discussion on Advanced COmputer Networks Course : New TCP protocols : Vegas, Reno, Wireless westwood etc
7. Design a data structure (can use STL) to capture packets if incoming data is coming at a very fast pace keeping in mind the out of order delivery and duplicate packets. Efficient in terms of handling all cases.
—> Latency should be minimum in processing
—> Capability to manage more than 10000 out of order packets.
8. Explain 3-way handshake. What will happen if SYN is dropped, if SYN+ACK is dropped, if ACK is dropped? On dropping of last ACK, can sender still send the data over the channel? WIll it be reliable?
9. Asked questions on implementation of pthread library – CSP Assignment. About Scheduler, Compiler and how scheduler will work in dispatching of threads. Complete explanation of round robin scheduler.
10. A code was given :
Will this code compile? If yes, what is the output? If No, why?
How memory allocation and deallocation on stack will work?
A long discussion on segmentation fault. if yes , why? if No, yes? Will the memory swapped off the stack space when function returns or values of local variables still resides unless next function overwrites. What actually happens?
Asked me to run the code when I was leaving. I asked can I take this piece of code with me? he said No, I can’t disclose question and smiled. Then, I said It’s okay. Question is in my mind. I will execute it for sure.
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
- APT Portfolio Interview Experience
- APT Portfolio Interview Experience - Junior/middle C++ developer
- MathWorks Interview Experience (EDG, Oncampus)
- ServiceNow Interview Experience Oncampus
- UHG Interview Experience | OnCampus- 2019
- InfoEdge Interview Experience | OnCampus-2019
- Amazon Interview Experience | Set 167 (SDE I for 1 year 6 months experience)
- Walmart Lab Interview Experience | Set 7 (Off-Campus 3 Years Experience)
- Walmart Lab Interview Experience | Set 8 (Off-Campus 3 Years Experience)
- Brocade Interview Experience | Set 2 (For Software Engineer 0-2.5 Years Experience)
- Amazon Interview Experience | Set 241 (1.5 years experience)
- Amazon Interview Experience | Set 242 (1 Year Experience)
- Amazon Interview Experience | Set 243 (2.5 Years Experience)
- Oyo Rooms Interview Experience | Set 3 (For Backend Engineer, Experience <=1yrs)
- Amazon Interview Experience | Set 248 (4.8 Yrs Experience for SDE II)
- Goldman Sachs Interview Experience | Set 23 (2+ years Experience for Java Developer Role)
- Amazon Interview Experience | Set 391 (SDE-2, 5.5 years Experience)
- Arcesium Interview Experience | Set 5 (3+ years experience - Developer profile)
- Oyo Rooms Interview Experience | Set 12 (4+ experience Backend Developer)
- Microsoft Interview Experience | Set 151 (SDE-2 3.5 years experience)