Wednesday, October 15, 2014

SCTP

Here are few possible discussion questions related to SCTP protocol

1. What are the advantages of SCTP over TCP ?
2. What is multi-srtreaming in SCTP ?
3. What is multi-homing in SCTP ?
4. How is SCTP more secure than TCP ?
5. What is the use of V-Tag in SCTP ?
6. Is there any difference between the SACK of TCP and SACK of SCTP ?
7. Can SCTP allow transfer of un-ordered packets ?
8. How do you send large packets over SCTP ?
9. Who takes care of fragmentation at the sender side of SCTP and Who takes care of re-assembly at the receiver side of SCTP ?
10. What is an association ? How is it created ? To what functionality of TCP is it equivalent to ?
11. Where is SCTP used widely as of now ?
12. Can a packet packet carry only the control chunk ? Name few singleton chunks ?
13. How many data chunks can be part of a packet ?
14. What is the relation between TSN, SN and SI ?
15. What are the two random values that are generated during the setup of association ?
16. When are the ip addresses of endpoints exchanged ?
17. What is an endpoint ?
18. Is a stream in SCTP uni-directional or bi-directional ?
19. Can an association have more streams in one direction than in other direction ? That is, can inbound streams be greater than outbound streams ?
20. Can the stream number start randomly ?
21. When are the valid stream number range set ?
22. What will the receiver do if the messages are out of order in a stream ?
23. What will the receiver do if fragmented message is received ?
24. Which field plays a key role in detection of lost data chunks ?
25. When a SCTP packet arrives at the receiver, is it possible to process the data chunks before control chunks ?
26. What is the use of U B E bits (Chunk flags) ?
27. Is it possible for a single chunk to have both B and E bit set  ? What does it refer to ?
28. How is the receiver window size conveyed to the sender ?
29. What is the use of cookie and cookie-echo ? What are the contents of cookie ? How is stale cookie identified ?
30. What is SYN flood ? How is it avoided in SCTP ?
31. What is the equivalent of TCP FIN in SCTP ? Is shutdown procedure of 2-way or 3-way or 4-way handshake in SCTP ?
32. What is Head-of-line blocking and how unnecessary Head-of-line blocking are avoided in SCTP ?
33. Can a INIT-ACK chunk have the other NIC interface address rather than that of the main address ?
34. How to determine the number of duplicate TSN report ?
35. What does the field 'Number of Fragments' refer to in SACK ?
36. How is SCTP a mix of UDP and TCP features ?
37. What is the boundary alignment for chunks ?
38. Will the length field include the padding bytes also ? Will the CRC cover the entire SCTP packet (that is, will it cover the SCTP common header + chunks) ?
39. Can a control chunk or data chunk go along with INIT or INIT-ACK chunk ? Can a control chunk or data chunk go along with COOKIE or COOKIE-ECHO chunks ?
40. What are the types of sockets w.r.t SCTP ?
41. What is the relation between initiation tag and verification tag ?
42. Can an SCTP endpoint have more than 1 IP addresses and more than 1 port numbers ?
43. How many associations can be had between any two endpoints ?
44. Do un-ordered messages within a stream have SSN ?
45. What is the encoding format of chunks ?
46. Which chunk conveys the inbound and outbound streams ?
47. How to identify unrecognized chunks ?
48. What is the equivalent of TCP RST in SCTP ?
49. What are the fields/contents of SCTP common header ?
50. What is the use of Heartbeat chunk ?

Monday, October 13, 2014

Multithreading

Hi,

Here are few possible queries that can be discussed about multithreaded programming in linux !

1. Can a child process be called as a thread ?
2. Are there multiple ways to create a thread ?
3. Is it possible for the thread to be alive if we terminate the process ? Is it possible for a child process to be alive if we terminate the parent process ? 
4. What is the memory layout of a process ?
5. What is the difference between multithreading and multiprocessing ?
6. What is the memory layout of a process with 2 threads ? What is the memory layout a process with 2 child process ?
7. If we declare a variable in the thread handler of 1st thread, will it be accessible accessible to 2nd thread ?
8. If we declare one variable locally in process and another globally in process, which one will be accessible to its threads ? Will those variable be available in child process also ?
9. Is it better to design a multi-threaded application or multi-process application ?
10. When should we need to go for multi-thread design and when should we go for a multi-process design ?
11. What is TLS ?
12. Who schedules the processes and who schedules the threads ?
13. Why process considered to be heavy weight ?
14. What are the contents of PCB ? What are the contents of TCB ?
15. How to ensure that thread1 gets terminated before thread2 ?
16. What will happen if we do not reap the zombie process ?
17. What is the use of zombie process ?
18. What are the various ways to terminate a zombie process ?
19. What is the difference between wait() and waitpid() system calls ?
20. Can two zombie process communicate with each other ?
21. How do you decide on the granularity of the lock ?
22. Is it good to have big lock or small lock ?
23. What will happen if a resource is improperly locked ?
24. What is atomicity ?
25. Where are atomic operations useful ?
26. What is spinlock ?
27. What is the use of PID ?
28. What is a process, thread ? What are the differences between process and thread?
29. If there are 2 sequential fork() calls, how many child process will be there ?
30. What is the use of reentrant function in multi-threaded environment ?
31. What is the advantage of using pthreads or POSIX threads ?
32. What are the various thread models and tell the scenario in which the particular thread model is useful / beneficial ?
33. What are the advantages & dis-advantages of 1:N user level threading (thread model)?
34. What is the difference between userspace threads and kernel space threads ?
35. Will a crash of a thread impact the other thread of the process ?
36. What is the difference between pthread_create() and fork() ?
37. What information is shared between a child process and the parent process ?
38. If a parent has 2 threads , will the child process also inherit or have a copy of those 2 threads ?
39. Why a faulty pointer does not crash a process but that of a thread can corrupt the process / other threads of the process ?
40. What is co-operative multitasking and what is pre-emptive multitasking ?
41. How do avoid race conditions in multi-threading
42. What will happen if you call a sleep() in a process or thread ?
43. Will a parent process be given higher priority compared to child process by the linux scheduler ?
44. What is vfork ?
45. What is the common mode of communication between a parent process and child process ? What are the modes of communication between threads ?
46.  Is child process light weight compared to parent process ?
47. What does a fork() call return ?
48. How to terminate a process by programming method ?
49. What are the software models for mulithreaded programming ?
50. What steps are performed during a context switch of a thread and what steps are performed during a context switch of a process ?

Networking - I

Let me share few networking related queries that can be used for our discussion ...

1. What is the use of Ethernet ?
Ethernet is a link layer protocol in TCP/IP stack and the most widely used LAN technology that provides a framework for data transmission to other devices on the same network segment.

2. How is the destination MAC address obtained ?
Destination MAC address is fetched via  ARP

3. Why is TCP called as connection oriented protocol ?
As the communication session is established by means of 3 way handshake ahead of transferring data, it is termed as connection oriented protocol. Here the client initiates the creation of logical pipes through which the messages shall be sent or received. These pipes shall be deleted at the end of connection.

4. Why is UDP called as connection less protocol ?
As the communication session is not established ahead of transferring data, it is termed as connection less protocol.

5. Why is TCP termed as Heavy weight protocol ?
TCP is heavy weight because it performs handshake for connection establishment, ordering of packets, handling reliability & congestion control. That is, TCP does lots of processing to provide reliable service and hence termed as heavy weight protocol.

6. What applications use TCP ?
SSH, HTTP, FTP, Telnet, SMTP, IMAP/POP, NFS

7. What applications use UDP ?
Tunneling/VPN, TFTP, SNMP, Media streaming, Games, local broadcast , RTP

8. Why are realtime applications using UDP even though it is unreliable ?
It is used in realtime applications where it is ok even if data is lost

9. Explain any error detection mechanism in TCP ?
Error detection is viable through sequence numbers. Duplicate packets are discarded based on SN at receiver. The lost packets are re-transmitted based on ACKs.

10. What is flow control in TCP ?
In order for the receiver and transmitter to be sync on the rate of data transmission, TCP uses sliding window protocol, where the receiver intimates the sender about the amount of data that it is willing to buffer for the connection via the receive window field. The sender can accordingly send data only up to the extent.

11. What is the use of MSS in TCP ?
It is used to represent the largest amount of data that the receiver shall receive in a single segment.   

12. What is sliding window algorithm ?
TCP uses sliding window protocol, where the receiver intimates the sender about the amount of data that it is willing to buffer for the connection via the receive window field. The sender can accordingly send data only up to the extent.
       
13. Bandwidth utilization is good in TCP or UDP ?
TCP

14. Why is connect system call invoked by client ?
Connect system call helps in connecting the socket to the address of the server thereby enabling the establishment of connection.

15. Why is bind system call optional for either UDP or TCP client ?
connect system call is optional for UDP client as UDP is a connectionless protocol.

16. What is socket ?
 Socket represents an endpoint of a connection.

17. What is a raw socket and when will we use it ?
Raw socket receives or sends raw datagram without including any link layer headers. That is, it allows direct sending and receiving of internet protocol packets without any protocol specific transport layer formatting.

18. Once the segments arrive on the receiver, who does the re-assembly in the case of TCP protocol ?
IP layer handles the re-assembly.

19. Is fragmentation applicable for UDP. If yes, who does the fragmentation ?
No.

20. Is fragmentation applicable for TCP. If yes, who does the fragmentation ?
Yes. The IP layer does the fragmentation.

21. What is the need for fragmentation in TCP ?
Fragmentation is done according the MTU of the device so that the data can be transmitted.

22. What determines the size for fragmentation in TCP ?
MTU determines the size for fragmentation.

23. What is the use of SYN field ?
The presence of SYN field conveys that sequence number is the initial sequence number(ISN). Only the first packet sent from either end shall have this SYN flag set .

24. What is the use of SN field ?
SN field carries the sequence number.
If SYN flag is set, it carries the initial sequence number (ISN).
If SYN flag is clear, then it is the accumulated sequence number of the first data byte of this segment for the current session.

25. What is the use of SACK field ?
SACK enables selective ACK which allows the client to inform on the range of packets received in order and the unreceived packets by which the server shall re-transmit only the packets that were not received by the client.

26. What is the use of Window field ?
Represents the size of the receive window.

27. When will the PSH flag bet set in TCP ?
This tells the receiver to push the data out immediately to the receiving application, rather than waiting for additional data to enter the buffer.

28. Is accept a blocking or non-blocking system call and what is the use of it ?
Accept is a blocking call.  It shall block until the connection request from client.

29. What is a concurrent server architecture ?
There will be one listening socket and multiple connected socket points at the server at any time.

30. What API is used for converting ipv4 address to NBO and vice versa ?
htons(), htonl(), ntohl(), ntohs()
   
31. What is the need for IP protocol, if ethernet can send data using the destination MAC address ?
IP header carries the source ip and destination IP that is required for addressing and routing.

32. What is the use of router, switch, bridge ? List differences between router, switch & bridge.
Router acts as a default gateway on the network segment if the packet has to go to another network. Router maintains table based on IP address & port. Router uses IP layer. Router overwrites the src MAC address with its own MAC address while sending it out.

Switch is a bridge configured to work like a hub in star topology. The received frames are processed & forwarded to the appropriate port using the forwarding table that is based on MAC address & port. Switch uses the data link layer. Switch does not overwrite the src MAC address.

Bridge is a layer 2 device which forwards to all other ports. It does not overwrite the src MAC address.
    
33. What is the use of TTL field ?
TTL determines the maximum number of hops that a packet can take while traveling in the network. While traversing through the network, the routers are expected to decrement the TTL value by 1 before forwarding the packet.

34. Who sets the congestion notification flag ?
The router in the network shall set the ECN flag incase of congestion in network.

35. Is it possible to have connection between multiple socket end points ?
A socket is one endpoint of a communication link between two programs running on the network. Endpoint is a combination of a port number and IP address. Every TCP connection shall be uniquely identified by two endpoints.
   
36. What are the limitations of ethernet ?
There is distance limitation on the maximum distance between devices on ethernet network. Transmission failure can happen as distance increases due to line noise or reduced signal strength or other degradation. Also, ethernet network face congestion problems as they increase in size.    

37. Is it true that data sent over ethernet is automatically broadcasted to every device in the network ?
Yes.

38. What is the difference between CSMA and CSMA/CD ? Why CSMA is not enough ?
CSMA - Broadcast and sense the collision
CSMA/CD - Operates by detecting the occurrence of a collision. Once collision is detected, CSMA CD immediately terminates the transmission so that the transmitter does not have to waste lot of time in continuing.
   
39. What is a Jam signal ? What is back-off period ?
Whenever a collision is detected, the detecting station broadcasts a collision or jam signal to alert other stations that a collision has occurred. Accordingly, every station will wait for a random amount of time.

40. What is the need for MII ?
Originally defined as a standard interface to connect fast ethernet MAC block to PHY chip. This has later been extended as GMII, RGMII, SGMII, XGMII etc..

41. What is the ethernet supported by CAT5 . What is the ethernet supported by CAT5e cable ?
CAT5 supports both traditional and fast ethernet. CAT5e supports Gigabit ethernet.

42. How can you overcome the limitations of ethernet cable ?
Hub can help in overcoming the limitations of ethernet cable.

43. What are the types of ethernet frame formats ? Are they compatible with each other ?
Ethernet II, IEEE 802.3, IEEE 802.2 LLC, IEEE 802.2 SNAP. The different frame types have different format and MTU values, but can coexist on the same physical medium.   

44. What is the role of LLC and MAC layer in ethernet ?
LLC interacts with the upper network layer. It is responsible for handling layer 3 protocols (mux/de-mux) and link services like reliability(error management mechanisms such as ARQ) and flow control. MAC layer interacts with the lower PHY layer. It is responsible for framing and media access control for broadcast media.

45. What is carrier sensing ?
This is a media access control protocol where the transmitter determines whether another transmission is in progress before initiating transmission.

46. What is CSMA-CA ?
Carrier sensing is done but nodes attempt to avoid collisions by transmitting only when the channel is sensed to be idle.
   
47. What is the use of preamble and FCS in Ethernet frame ?
The preamble of ethernet packet allows devices to synchronize the receiver clocks. FCS is a error detecting code added to a frame that helps in discarding the damaged frame in a communication protocol if the FCS number calculated by the destination node mismatches with the FCS number sent by the source node.

48. What are the types of CSMA access modes ?
The types of CSMA access nodes are Persistent, Non-persistent, P-persistent and O-persistent.

49. What is port mirroring ? where is port mirroring used ?
Port mirroring sends a copy of network packets seen on one port to a network monitoring connection on another switch port. It is used in network switch.

50. What is a iterative server ?
Iterative server processes one client request at a time in a sequential manner.