Thursday, March 20, 2014

/porc file system

/proc is a virtual filesystem because it does not include 'real file'. But there are runtime system information
including about sys memory, device mounted, and hardware configuration, etc.
Moreover It's referred to as a process infromation pseudo-file system.
Therefore we may assume /proc as a control and information center for Kernel.
Inside the /proc directory, you’ll see two types of content — numbered directories, and system information files.
/proc is not a real file system, it is a virtual file system. For example, if you do ls -l /proc/stat, you’ll notice that it has a size of 0 bytes, but if you do “cat /proc/stat”, you’ll see some content inside the file.
Several Linux commands access the information from /proc, and displays in a certain format.

1. /proc Directories with names as numbers

Do a ls -l /proc, and you’ll see lot of directories with just numbers. These numbers represents the process ids, the files inside this numbered directory corresponds to the process with that particular PID.
Following are the important files located under each numbered directory (for each process):
  • cmdline – command line of the command.
  • environ – environment variables.
  • fd – Contains the file descriptors which is linked to the appropriate files.
  • limits – Contains the information about the specific limits to the process.
  • mounts – mount related information
Following are the important links under each numbered directory (for each process):
  • cwd – Link to current working directory of the process.
  • exe – Link to executable of the process.
  • root – Link to the root directory of the process.

2. /proc Files about the system information

Following are some files which are available under /proc, that contains system information such as cpuinfo, meminfo, loadavg.
  • /proc/cpuinfo – information about CPU,
  • /proc/meminfo – information about memory,
  • /proc/loadvg – load average,
  • /proc/partitions – partition related information,
  • /proc/version – linux version
Some Linux commands read the information from this /proc files and displays it. For example, free command, reads the memory information from /proc/meminfo file, formats it, and displays it.
To learn more about the individual /proc files, do “man 5 FILENAME”.
  • /proc/cmdline – Kernel command line
  • /proc/cpuinfo – Information about the processors.
  • /proc/devices – List of device drivers configured into the currently running kernel.
  • /proc/dma – Shows which DMA channels are being used at the moment.
  • /proc/fb – Frame Buffer devices.
  • /proc/filesystems – File systems supported by the kernel.
  • /proc/interrupts – Number of interrupts per IRQ on architecture.
  • /proc/iomem – This file shows the current map of the system’s memory for its various devices
  • /proc/ioports – provides a list of currently registered port regions used for input or output communication with a device
  • /proc/loadavg – Contains load average of the system
    The first three columns measure CPU utilization of the last 1, 5, and 10 minute periods.
    The fourth column shows the number of currently running processes and the total number of processes.
    The last column displays the last process ID used.
  • /proc/locks – Displays the files currently locked by the kernel
    Sample line:
    1: POSIX ADVISORY WRITE 14375 08:03:114727 0 EOF
  • /proc/meminfo – Current utilization of primary memory on the system
  • /proc/misc – This file lists miscellaneous drivers registered on the miscellaneous major device, which is number 10
  • /proc/modules – Displays a list of all modules that have been loaded by the system
  • /proc/mounts – This file provides a quick list of all mounts in use by the system
  • /proc/partitions – Very detailed information on the various partitions currently available to the system
  • /proc/pci – Full listing of every PCI device on your system
  • /proc/stat – Keeps track of a variety of different statistics about the system since it was last restarted
  • /proc/swap – Measures swap space and its utilization
  • /proc/uptime – Contains information about uptime of the system
  • /proc/version – Version of the Linux kernel, gcc, name of the Linux flavor installed.




Packet This term is considred by many to correctly refer to a message sent by protocols operating at the network layer of the OSI Reference Model. So you will commonly see people refer to [i/IP Packets[/i]. However, this term is commonly also used to refer generically to any type of message.
Datagram This term is basically synonymous with packet and is also used to refer to network layer technologie. It is also often used to refer to a message that is sent at a higher level of the OSI Reference Model (more often than packet is).
Frame This term is most commonly associated with messages that travel at low levels of the OSI Reference Model. In particular, it is most commonly seen used in reference to data link layer messages. It is occasionally also used to refer to physical layer messages, when message formatting is performed by a layer 1 technology. A frame gets its name from the fact that it is created by taking higher-level packets or datagrams and "framing" them with additional header information needed at the lower level.

DIFFERENCE BETWEEN PACKET AND FRAME
                 A frame is a PDU in data link layer. A packet is the PDU at the network layer. A data link header and footer are added to packet to create a frame .
A frame is therefore said to encapsulate a packet.

wikipedia says:
"Reliable packets vs. unreliable datagrams..."
It means that packets are connected with TCP and datagrams with UDP.

 Transmission Control Protocol 
TCP is connection-oriented. It establishes a virtual path between the source and destination. All of the segments belonging to a message are then sent over this virtual path. You may wonder how TCP, which uses the services of IP, a connectionless protocol, can be connection-oriented. The point is that a TCP connection is virtual, not physical. TCP operates at a higher level. TCP uses the services of IP to deliver individual segments to the receiver, but it controls the connection itself. If a segment is lost or corrupted, it is retransmitted.

Before discussing TCP in more detail, let us discuss the TCP packets themselves. A packet in TCP is called a segment.



 How Connection Establish by TCP
A SYN segment cannot carry data, but it consumes one sequence number.
A SYN + ACK segment cannot carry data, but does consume one
sequence number.
An ACK segment, if carrying no data, consumes no sequence number.

The following pic is Data Transfer by TCP.