004 Linux Network ProgrammingIssues, queries and suggestions related to Linux, Network, Linux Programming, Network Programming, System Programming, Sockets, Threads,
FTP based Client Server project using sockets and threads.
Ques:1- How a Network Connection and Communication establish Between machine's ?
Ans:- Let assume there are Two machine have connection through some kind of intermediate network and this network has so many network nodes which are inter-connected with each other.
Now the two machine have to communicate with each other across the network.
In other operating system the operating system is one entity and network protocol stack is another entity but in Linux it has one entity which is combination of both network protocol stack and Linux.
The network protocol stack used in Linux is a 4 layer protocol stack which are:-
Application Protocol layer
Network Protocol layer
Rooting Protocol layer
Hardware Protocol layer
In machine's 100 of processes or program run's simultaneously,Suppose one processes of first machine want's to communicate with any one of the processes of 2nd machine.
So the first machine will create a Socket(socket is like a communication point like a pipe).
In Pipe we get at one end of the pipe a write File descriptor and other end read File descriptor But in Socket at one end we get read-write file descriptor and at another end we get network Connection.
In machine or system we have Hardware ports either Ethernet or USB port & this port is supported by Device driver or some kind of network Driver.
The process will connect to the one-end of the socket through read-write file descriptor & at other end we have network Connection.
Network Connection consist of Two things:-
Network Ports
IP Addresses
In O.S there are large numbers of data tunnels and these tunnels are called logical ports and the maximum number of ports a system has is 2^16.
Now the Socket has to connect with one of these ports & then across the logical port the connection will go bottom-up through Network protocol stack and then further to the Hardware ports,the device driver and the network protocol will work together.
As the connection reaches to the Device Driver it will pick data packets from the network protocol stack and will put into the internet or any kind of network connected to the machine .
The Routing Protocol(Layer 2 Protocol) will start in Both the machine & will connect to the Hardware ports and take shortest path of connecting nodes using shortest path algorithm & will connect to the hardware of 2nd machine and hence the Connection Established between the Two machine.