Seach in Techno Google

Thursday, February 14, 2008

Interview questions for computer science students

About TCP/IP

What is TCP?

TCP (Transmission Control Protocol) is the main transport protocol utilized in IP networks.
The TCP protocol exists on the Transport Layer of the OSI Model.
The TCP protocol is a connection-oriented protocol which provides end-to-end reliability.
By connection-oriented, we mean that before two network nodes can communicate using TCP, they must first complete a handshaking protocol to create a connection.
When we say that TCP provides end-to-end reliability, we mean that TCP includes mechanisms for error detection and error correction between the source and the destination.
These properties of TCP are in contrast to UDP, which is connectionless and unreliable.
Higher layer protocols which utilize TCP include HTTP, SMTP, NNTP, FTP, telnet, SSH, and LDAP.

Diagram of the TCP Header

TCP Header Format
-----------------

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

UDP

(User Datagram Protocol) is one of the two main transport protocols utilized in IP networks.
The UDP protocol exists on the Transport Layer of the OSI Model.
The UDP protocol is an unreliable connectionless protocol.
When we say that UDP is unreliable, we mean that UDP does not provide mechanisms for error detection and error correction between the source and the destination. Because of this, UDP utilized bandwidth more efficiently than TCP. Applications which utilize UDP and which require reliable transport must provide their own error detection and correction mechanisms.
By connectionless, we mean that a network node can communicate with another network node using UDP without first negotiating any kind of handshaking or creating a connection. Because of this, UDP is very efficient for protocols that send small amounts of data at irregular intervals.
These properties of UDP are in contrast to TCP, which is connection-oriented and provides end-to-end reliability.
Higher layer protocols which utilize UDP include DNS, BOOTP, DHCP, SNMP, and RADIUS.

Diagram of the UDP Header

UDP Header Format
-----------------

0 7 8 15 16 23 24 31
+--------+--------+--------+--------+
| Source | Destination |
| Port | Port |
+--------+--------+--------+--------+
| | |
| Length | Checksum |
+--------+--------+--------+--------+
| +
| data octets ... +
+-----------------------------------+

What are TCP/IP ports?

TCP and IP are two seperate protocols. IP (Internet Protocol) is a network layer protocol, while TCP (Transmission Control Protocol) is a transport layer protocol.
Every computer and network device attached to the Internet has at least one IP address. For example, the IP address of this web server is 66.37.153.81.
Then, within each of those IP addresses, each computer and network device will have a number of TCP ports. For example, the web server software on this web server responds on TCP port 80 and the mail server software on the same computer responds on TCP port 25.
In a non-technical sense, you can think of an IP address as the address of an office building and the TCP ports are individual offices within that building.

TCP Ports

TCP ports either originate connections or they receive connections. Any TCP port can originate a connection, and the port numbers for those are not important. TCP ports which receive connections, on the other hand, have to be assigned specific port numbers so that people and applications know where to look for them. For example, DNS answers on TCP port 53 and HTTP answers on TCP port 80.
Port numbers that are statically assigned are known as well known port numbers are are usually below 1,024. To see a list of well known TCP ports, read What port number is XXX on?.








What are the types of network hardware

The label network hardware is generally given to any piece of equipment with the task of moving data.
Common categories of network hardware include:
• Routers
• Switches
• Network Interface Cards

Routers
A router is a network device with interfaces in multiple networks whose task is to copy packets from one network to another.
Routers operate at Layer 3 of the OSI Model, the Network Layer.
A router will utilize one or more routing protocols to create a routing table.
The router will then use the information in its routing table to make intelligent decisions about what packets to copy to which interface.
This process is known as routing.
Routers are available with many interface types, such as Ethernet and DSL. Wireless routers support wireless interfaces, such as 802.11 (Wi-Fi).
Not all routers clearly fall into the category of network hardware. Routing software makes it possible to build a fully functional router out of a normal computer

Switches
A switch is a network device with multiple ports in one network whose task is to copy frames from one port to another.
Switches operate at Layer 2 of the OSI Model, the Data-Link Layer.
A switch stores the MAC Address of every device which is connected to it.
The switch will then evaluate every frame that passes through it. The switch will examine the destination MAC Address in each frame.
Based upon the destination MAC Address, the switch will then decide which port to copy the frame to.
If the switch does not recognize the MAC Address, it will not know which port to copy the frame to. When that happens, the switch will broadcast the frame to all of its ports.
Before switches became available, devices called hubs were used. Hubs were less intelligent netword devices that always copied all frames to all ports. By only copying frames to the destination ports, switches utilize network bandwidth much more effectively than hubs did.
Another piece of network hardware related to the switch is the Bridge. A Bridge is effectively a two-port switch. Because few users need a two-port switch, they are no longer manufactured.

Network Interface Cards
A network interface card is an expansion card which installs into a computer and enables that computer to physically connect to a local area network.
The most common form of network interface card in current use is the Ethernet card. Other types of network interface cards include wireless network interface cards and Token Ring network interface cards.
Other terms for network interface card include network adapter, network card and NIC.
Network interface cards are becoming rare, as most motherboards now include built-in network interfaces.

About OSI Model

OSI Model
The seven layers of the OSI model are:
Layer Name
7 Application
6 Presentation
5 Session
4 Transport
3 Network
2 Data Link
1 Physical

The easiest way to remember the layers of the OSI model is to use the handy mnemonic "All People Seem To Need Data Processing":
Layer Name Mnemonic
7 Application All6 Presentation People
5 Session Seem
4 Transport To
3 Network Need
2 Data Link Data
1 Physical Processing

The functions of the seven layers of the OSI model are:
Layer Seven of the OSI Model
The Application Layer of the OSI model is responsible for providing end-user services, such as file transfers, electronic messaging, e-mail, virtual terminal access, and network management. This is the layer with which the user interacts.
Layer Six of the OSI Model
The Presentation Layer of the OSI model is responsible for defining the syntax which two network hosts use to communicate. Encryption and compression should be Presentation Layer functions.
Layer Five of the OSI Model
The Session Layer of the OSI model is responsible for establishing process-to-process commnunication between networked hosts.
Layer Four of the OSI Model
The Transport Layer of the OSI model is responsible for delivering messages between networked hosts. The Transport Layer should be responsible for fragmentation and reassembly.
ayer Three of the OSI Model
The Network Layer of the OSI model is responsible for establishing paths for data transfer through the network. Routers operate at the Network Layer.
Layer Two of the OSI Model
The Data Link Layer of the OSI model is responsible for communications between adjacent network nodes. Hubs and switches operate at the Data Link Layer.
Layer One of the OSI Model
The Physical Layer of the OSI model is responsible for bit-level transmission between network nodes. The Physical Layer defines items such as: connector types, cable types, voltages, and pin-outs.

The OSI Model vs. The Real World

The most major difficulty with the OSI model is that is does not map well to the real world!
The OSI was created after many of todays protocols were already in production use. These existing protocols, such as TCP/IP, were designed and built around the needs of real users with real problems to solve. The OSI model was created by academicians for academic purposes.
The OSI model is a very poor standard, but it's the only well-recognized standard we have which describes networked applications.
The easiest way to deal with the OSI model is to map the real-world protocols to the model, as well as they can be mapped.
Layer Name Common Protocols
7 Application SSH, telnet, FTP
6 Presentation HTTP, SMTP, SNMP
5 Session RPC, Named Pipes, NETBIOS
4 Transport TCP, UDP
3 Network IP
2 Data Link Ethernet
1 Physical Cat-5

The difficulty with this approach is that there is no general agreement as to which layer of the OSI model to map any specific protocol. You could argue forever about what OSI model layer SSH maps to.
A much more accurate model of real-world networking is the TCP/IP model:
TCP/IP Model
Application Layer
Transport Layer
Internet Layer
Network Interface Layer
The most significant downside with the TCP/IP model is that if you reference it, fewer people will know what you are talking about!