Well. the reason why TCP/IP is very important is because that's the most common protocols now.

Let's take a look at the difference btw TCP and IP

Firstly IP is in a network layer, what's the purpose of this? it's a communication btw a computer and a computer
the answer why we use IP is because MAC cannot see other networks, that's why people need to make one
address that is able to look at other network's computers. THat's why IP came out.

In transport layer(Layer 4), there is one protocol named TCP.
TCP has some features as below.
  1) a communication btw apps and apps
  2) how do we know about app #? : using port number
  3) End to End, communication protocol... : it means using port, applications will reach to each other.

What's the roles of TCP?
   1) TCP is in Transport layer( #4 layer)
   2) Reliable data transmission
   3) End-to-end protocol
   4) Stream interface -> but the unit is a segment?
         -> What's stream? -> transmission by byte to byte.. when application will send a packet, it does not go to
             TCP segment directly, it goes to TCP buffer... the thing is TCP is variable that's why we do not know
             what size of data is coming. APP -> TCP buffer -> TCP -> Segment <-- converting
   5) connected oriented protocol : three ways hand shaking (very important, will be mentioned later)
   6) Full-duplex communication : it has both "direction" and "동시성(I don't know how to say)

End to End service : easily, it means an application of a host A is communicating with an application of host B
                             Connection -> Data sending -> Disconnecting.. think like a telephone
                             but TCP is just a virtual mechanism

How to be capsulated for TCP?

Frame(Ethernet) header + Datagram(IP) header + Segment(TCP)

TCP segment header 

1)     Source port(16bit) : 송신자의port넘버를 알기 위해서 정의된 field이다.

2)     Destination port(16bit) : 수신자의port 넘버를 알기 위해서 정의된 field이다.

3)     Sequence number : 2가지 역할을 하는데 SYN field값에 따라 다르다

a.      SYN == 1? : 이는initial sequence number로써, 처음 data byte Ack number 사용되어 진다. 이후 값들이 sequence 따라 1 증가하게 된다.

b.      SYN == 0?: 첫번째data byte  축적된 sequence number 의미한다.

4)     Acknowledgment number(32bit) : 만약 ackflagset 이라면, 값은 다음sequence number 의미한다. 상대방으롭터 다음 전송 때에 받기를 기대하는 첫째 바이트 번호이다.

5)     Data offset(4bit) : TCP header 크기를 구제화 시키는 field이다. Words(4byte) 단위로 구성되며 최대 20~60 byte까지 구성될 있다.

6)     Reserved (6bit): 미래에 사용될 것을 대비해서 착안됐으며, 0으로 set되어야 한다.

7)     Fags(6bit) : 6bits 구성되어 있으며,1bitflag 가지고 있다. 종류는 아래와 같다.

a.      URG flag : 긴급 상황이 발생했을 경우 사용된다.

b.     ACK flag : 전송된 값이 valid(유효함) 알리는데 사용된다.

c.      PSH flag : 버퍼가 차지 않았더라도, flag set이라면 바로 데이터를 전송한다.

d.     RST : 재설정(re-setting) 요구하는 flag이다.

e.     SYN : 3-way handshaking(Syn -> ack -> Syn 순서) 제의하는 flag이다.

f.       FIN : Session 종료하고자 사용한다.

g.      Window Size(16bit) : 현재 상태의 최대 버퍼크기를 말하는field이다.

h.     CheckSum : 데이터가 유효한 것인지, 이상이 없는지 확인하는field이다

i.        Urgent Pointer : 긴급한 데이터를 사용해야 데이터가 존재하는 곳을 가르키는 포인터 값이다.



 
  

'Programming > Network Programming' 카테고리의 다른 글

.. no regret..  (0) 2011.10.26
The example of one server that sends a client ID  (0) 2011.10.15
get client IPadrress in server side  (0) 2011.10.10
Reference for unix socket api  (0) 2011.09.29
The concept of TCP/IP part 1.  (2) 2011.09.07
Posted by 박세범