Showing posts with label UDP. Show all posts
Showing posts with label UDP. Show all posts

Tuesday, December 30, 2008

Transport Layer:

It takes application layer data and. It enables more than one application to communicate simultaneously through the network and the data doesn’t get mixed. It segments data into segments so that if data lost then only that segment needs to be retransmitted. It controls data speed, if data is lost frequently then it slows down the communication. It assigns each application a port number and it is attached the segment so that the transport layer at the other end can determine which application will get the data.

The used port numbers are
Well known processes: like http, ftp etc that runs on server, 0-1023
Registered Ports: The applications that each host uses, 1024-49151
Dynamic or Private: The port number when using for initial connection, 49152-65535

When the destination device receives data at transport layer, it sees the sequence number and reassembles several segments, sees the port number and gives the data to the appropriate application layer apps.

The two common protocols are
TCP: uses sequence number, acknowledgments, flow control etc. so has large overhead usually used in application where data lost has severe effect like web pages, file transfers
UDP: connectionless, no acknowledgement, just stand and deliver. It has very low overhead so it’s best effort connection. Usually used in VOIP, or video chat.

Three way handshake:
It uses three way handshake when initializing a new connection.
Firstly, the sender sends a segment with SYN flag=1 with initial seq. number (ISN). Secondly, when the receiver gets it, it sends the transmitter a segment with ACK no= ISN+1; SYN flag=1, ACK flag=1.
Thirdly, the transmitter acknowledges a segment with SEQ=ack+1; ACK flag=1, SYN=0.

Network Layer:

The network layer gets transport layer segment, adds ip address of source and destination and creates a PDU called packet. The ip address is used to forward data at routers and distribute it among the users.
Network layer is connectionless, so it has no headache to see data is delivered or not. That’s the responsibility of the transport layer.

Two common protocols of network layer are
IPv4: Now used with 32bit ip address
IPv6: Limited usage, with 128 bit ip, it provides better security and supports more users than IPv4

Apart from ip address, some other information are added to network layer packet. They are TTL (time to live)= how many routers the packet can pass before they are dropped
TOS (Type of service)=the info that routers use to give priority to packets like VIPs
Transport layer Protocols: TCP: 06, UDP: 17
MF (More fragment): Several fragments need to be added to form the packet
DF (Don’t Fragment): Delicate packet, don’t make pieces.

A router is a layer 3 (network) device. When several networks are connected through routers, the routers exchanges information by routing protocol. So each router knows which network is connected to which router or the shortest path to a distant network. When a router gets a frame (layer 2 PDU) it decapsulates the frame and then checks the ip address in the packet and finds the network address by binary ANDing the ip address and the subnet mask. If the destined network is connected to the router it delivers the packet. Otherwise it encapsulates the packet again and resends the packet to another router which is the next hop for the desired network.