1. Count the number of 1s in an integer
2. Difference between little-endian and big-endian
Q1 and Q2 are in Programming Interviews Exposed
3. If uint32 *p = 100, what's the value of p after ++p
should increment by the size of the uint32 (I think)
4. What is a system call
from wikipedia, a system call is a mechanism for an application to request service from the OS.
5. Follow 4. Something about write() and strcpy()
write() is a system call
6. what does keyword volatile in C do
it tells the implementation to suppress optimization
7. Something about spinlock
8. Difference between semaphore and mutex
Since I never did any thread programming, I can't answer these two at all :-( But here are some answers.
9. difference between TCP and UDP
TCP is connection-oriented, reliable, in order delivery, and has congestion control
10. When to use TCP and UDP
TCP, when we cannot afford packet loss. UDP, time sensitive applications, voice, video etc
11. System function calls for a simple server
socket()->bind()->listen()->accept()
12. is listen() blocking?
listen() is nonblock and accept() after listen is default blocking. Note: recv() also blocks <- failed at this one
13. difference between SOCK_STREAM and SOCK_DGRAM SOCK_STREAM-> TCP, SOCK_DGRAM->UDP
14. What does the keepalive option in socket() do?
it's a heartbeat that periodically (usually 2 hrs) checks if the TCP connection is still valid.
15. can udp use connect()? what does it do?
Yes, udp can use connect(), it filters the incoming packets to certain hosts or certain port. <- not very sure A better explanation. It simply tells the OS the address of the peer. No handshake and no data is sent. Once is connected, client can use sendto() with null address, and can use send(), recv(), read(), write().
16. describe select(), what is the disadvantage of select() select monitors several sockets (file descriptors) at the same time, and let you know which one is ready so you can do further processing. disadvantage? No idea, but here are some answers
17. What is MTU/Path MTU
MTU = maximum transmission unit. The max size of a packet that the layer can handle. Path MTU, the max size of packets between a path (2 end points) can have without fragmentation. Wiki
18. describe how traceroute works
basically we sent out a series of ordinary IP packets (UDP datagram), each with increasing TTL value (1, 2, etc) and a random port. When TTL expires, the router returns a TTL expired ICMP message. When it reaches the destination, the destination returns a port unreachable ICMP message.
19. what does SOCK_SEQPACKET do?
Never seen this before, but I think I actually gave out the right answer. Here is a better explaination. Basically, it's either a sequence of packets which are delivered reliably and in order, or a reliable, ordered stream with record boundaries in it.
And there's also a question ask me to explain one of my project (id-based routing protocol). Overall I think I am ok with networking concepts, but I really need to do more study on the basic C/thread programming/socket programming stuff.
6 comments:
hi, useful post.
Very good and informative post. Thanks
dude... One help.... was this inerview for 30 minutes.... I have an interview with juniper some time next week.... It will be great if you can tell me what the duration of the interview was in your case. He said that it is an 1/2 hour interview. was it the same in your case?
I have also attended an interview with Juniper.Your post was very useful for that.
Today they asked me to write
1)code for counting no.of.bits of uint32 variable.
2)Code for graph in c
3)Is send() blocking till the data is sent to the server in TCP?
A- No it is copied to socket buffer by the kernel and keeps a copy for re transmitting if necessary.
3)What is a bridge?
4)What does a bridge do?
5)What are various layer 2 protocols, routing,what does data link layer do etc.All theory about computer networks.
6)What is memory fragmentation?
Defragmentation etc.
Hope my input is useful to someone.
All the best.
For me this interview is gone as i did not tell those theory Questions. I have coded for graph and talked confidently abt socket programming.
HI,THANKS A LOT....ITS REALLY USEFULL:-)
i have an interview in few days..can u tell what to study and from where..this is for intern. .will the questions be easier than this??
-rag
Post a Comment