Introduction to Network Security

why do we need network security ? . becoz we often share confidential information, we often do many money/business transactions etc. we don't want some one to interpret our data that is sent thru internet.

according to statistics the number of hacking incidents reported in 2003,2004 are high . the intruder knowledge has become very skillful. 

Lets discuss about the security attacks: 
Security attacks are of 2 types 1)passive attack 2)active attack.  . 

the security threat could be a hacker or a virus/worm that gets executed automatically

The Passive Attack:
the passive attack is nothing but the hacker just interprets the data sent through the network. but there will be no modification of data. detecting these kinds of attack is tricky. 

if peer A is sending data to peer B, if the hacker just observes the data being passed between these 2 peers, then the attack is said to be passive attack. 

observing traffic pattern,is 2nd type of passive attack. the intruder observes the traffic flow in  network.

Suppose that we had a way of masking the contents of messages or other information traffic so that opponents, even if they captured the message, could not extract  the information from the message. 

The common technique for masking contents is encryption. If we had encryption protection in place, an opponent might still be able to observe the pattern of these messages. The opponent could determine the location and identity of communicating hosts and could observe the frequency and length of messages being exchanged. This information might be useful in guessing the nature of the communication that was taking place.
Passive attacks are very difficult to detect because they do not involve any alteration of the data. Typically, the message traffic is sent and received in an apparently normal fashion and neither the sender nor receiver is aware that a third party has read the messages or observed the traffic pattern. However, it is feasible to prevent the success of these attacks, usually by means of encryption. 

Thus, the emphasis in dealing with passive attacks is on prevention rather than detection.

the 2nd type of security attacks is Active Attack:

the active attack involves modification of data or creation of false data sent thru network by hacker . there are 4 types in this 
a)masquerade 2)replay of messages 3)modification of messages 4) denial of service. 

lets discuss about these attacks.

masquerade: in this, the hacker pretends to be a different entity.one entity tries to behave as different entity. suppose peer A sends confidential data to peer B, then the hacker pretends to be a peer B and gets the confidential data from peer A .


For example, authentication sequences can be captured and replayed after a valid authentication sequence
has taken place, thus enabling an authorized entity with few privileges to obtain extra privileges by impersonating an entity that has those privileges.


replay of messages:  in this attack, the hacker gets the passive information from sender and observes them, later replays the messages to receiver.

modificiation of message:  In this the intruder modifies the message that has been sent thru network from host A to host B. when host A sends message "Give Admin rights to steves" to host B, the intruder can capture this and modifies as "Give Admin rights to parker" and sends to receiver host B.

denial of service:  the denial of service prevents or inhibits the normal use or management of communication facilites. example may include , the inrtuder attacks the network hosts by degrading its performance by sending overwhelming requests.  

TCP protocol

Introduction:

 First, TCP provides connections between clients and servers. A TCP client establishes a connection with a given server, exchanges data with that server across the connection, and then terminates the connection.
TCP also provides reliability. When TCP sends data to the other end, it requires an acknowledgment in return. If an acknowledgment is not received, TCP automatically retransmits the data and waits a longer amount of time. After some number of retransmissions, TCP will give up, with the total amount of time spent trying to send data typically between 4 and 10 minutes (depending on the implementation).

TCP Connection establishment:

TCP has a three way hand shake for connection establishment .

1) a client will send connection request to server. this is called (synchronize) SYN segment
2) server responds to SYN segment with Acknowledgement . this is called SYN + ACK segment.
3) when client receives ACK from server, it establishes connection.

to implement tcp 3 way handshake 

1) a server should bind to the port and should  listen for incoming connections. this is done by using socket,bind,listen calls from socket library
2) client calls connect()n which sends SYN segment to server.which tells the server the client's initial sequence number for the data that the client will send on the connection
3)The server must acknowledge (ACK) the client's SYN and the server must also send its own SYN containing the initial sequence number for the data that the server will send on the connection. The server sends its SYN and the ACK of the client's SYN in a single segment.
4)The client must acknowledge the server's SYN.

Picture of 3 way handshake: click to enlarge.




Note that TCP does not guarantee that the data will be received by the other endpoint, as this is impossible. It delivers data to the other endpoint if possible, and notifies the user (by giving up on retransmissions and breaking the connection) if it is not possible. Therefore, TCP cannot be described as a 100% reliable protocol; it provides reliable delivery of data or reliable notification of failure.
TCP contains algorithms to estimate the round-trip time (RTT) between a client and server dynamically so that it knows how long to wait for an acknowledgment. For example, the RTT on a LAN can be milliseconds while across a WAN, it can be seconds. Furthermore, TCP continuously estimates the RTT of a given connection, because the RTT is affected by variations in the network traffic.
TCP also sequences the data by associating a sequence number with every byte that it sends. For example, assume an application writes 2,048 bytes to a TCP socket, causing TCP to send two segments, the first containing the data with sequence numbers 1–1,024 and the second containing the data with sequence numbers 1,025–2,048. (A segment is the unit of data that TCP passes to IP.) If the segments arrive out of order, the receiving TCP will reorder the two segments based on their sequence numbers before passing the data to the receiving application. If TCP receives duplicate data from its peer (say the peer thought a segment was lost and retransmitted it, when it wasn't really lost, the network was just overloaded), it can detect that the data has been duplicated (from the sequence numbers), and discard the duplicate. 
TCP provides flow control. TCP always tells its peer exactly how many bytes of data it is willing to accept from the peer at any one time. This is called the advertised window. At any time, the window is the amount of room currently available in the receive buffer, guaranteeing that the sender cannot overflow the receive buffer. The window changes dynamically over time: As data is received from the sender, the window size decreases, but as the receiving application reads data from the buffer, the window size increases. It is possible for the window to reach 0: when TCP's receive buffer for a socket is full and it must wait for the application to read data from the buffer before it can take any more data from the peer.

TCP Connection termination:
when it comes for termination. TCP has 4 steps .
step 1) when application calls close(), the tcp peer will send the FIN segment. it means it has finished sending data .this is called active close
step 2) The other end that receives the FIN performs the passive close. The received FIN is acknowledged by TCP. The receipt of the FIN is also passed to the application as an end-of-file (after any data that may have already been queued for the application to receive), since the receipt of the FIN means the application will not receive any additional data on the connection.
step 3)sometime later, the application that received the end-of-file will close its socket. This causes its TCP to send a FIN.
step 4) The TCP on the system that receives this final FIN (the end that did the active close) acknowledges the FIN.


Network Programming

would like to blog network programming topics.

when I say network programming, i would like to blog about TCP & UDP protocols.


Tcp Protocol:

http://techie-builder.blogspot.com/2010/11/tcp-protocol.html


UDP Protocol:

link to be given here