Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!


TCP/IP Basics

Recommended Posts


os créditos não são meus, apesar de obviamente postar por endender o assunto e achar que está fixe e não seria preciso criar um ou traduzir (não busco créditos, apenas que a info seja passada  :D )

The TCP/IP Basics

Chapter 1 -- A glance at TCP/IP or (Uh, what's a packet?)

In this series we will explore the wonders of the protocol that made the internet what it is today. It will start from the basics and theory and lead to practical applications of this knowledge. Some of the things discussed later may *NOT* be legal in your locale, please check your local computer crime laws. (Or do them at home.)

Starting at the beginning we can understand TCP/IP by understanding the parts that make it up. The following Diagram will show the building blocks of networking and how they fit together.

--------- --------- ---------

| SNMP | | Telnet| | FTP | <--- Application Layer

--------- --------- ---------

--------- ---------

| UDP | | TCP | <--- Transport Layer

--------- ---------

--------- ---------

| ICMP | | IP | <--- Network Layer

--------- ---------

--------- --------- --------- ---------

| ARP | | RARP | | Ether | | PPP | <--- Link Layer

--------- --------- --------- ---------

As you can see, with one block on top of another, there is more than just TCP/IP networking. As our focus is on TCP/IP though the following explanation will focus solely on the anatomy of a TCP/IP packet. The link layer adds the source and destination mac addresses to the packet. The network layer adds the source and destination IP addresses. The transport layer adds the source and destination port numbers. At this point there is a pseudo layer called the session layer that adds the data to the packet, although one might argue this is also a function of the transport layer as well. The application layer is exactly that, the application that is passing the packets. The following diagram may help pull this together.



*(Link Layer) *

* =============================================================*

* =(Network Layer) =*

* = ++++++++++++++++++++++++++++++++++++++++++++++++++++=*

* = +(Transport Layer) +=*

*Source =Source + Source ----------------------------------------- +=*

*Mac =IP + Port - Data - +=*

*Dest =Dest + Dest - - +=*

*Mac =IP + Port ----------------------------------------- +=*

* = + +=*

* = ++++++++++++++++++++++++++++++++++++++++++++++++++++=*

* = =*

* =============================================================*

* *


Tearing this down further brings us to the TCP portion of this text. The TCP header is broken down into ten sections, they are as follows: source port number, destination port number, sequence number, acknowledgement number, header length, reserved, flags, windows size, TCP checksum and urgent pointer. Let's look first at flags. Flags are set based on what the packet is trying to accomplish. The six flags are as follows:

URG <-- Urgent Flag

ACK <-- Acknowledgment number is valid

PSH <-- Push this data on as soon as possible

RST <-- Reset the connection

SYN <-- Synchronize sequence numbers to establish a connection

FIN <-- Sender is finished sending data

This brings us to the TCP three way handshake for making connections. This is the way all TCP connections are made.

--------- ---------

|HOST A | 1. Syn |HOST B |

| | ---------------------> | |

| | | |

| | 2. Syn/Ack | |

| | <-------------------- | |

| | | |

| | 3. Ack | |

| | ---------------------> | |

| | | |

--------- ---------

1. Host A initiates a connection to Host B and says, (SYN)chronize your TCP sequence with me.

2. Host B responds back and says, I've (ACK)nowleged your request, (SYN)chronize your TCP sequence with me.

3. Host A responds, I (ACK)nowledge your request, let's start talking.

With this basic understanding you can learn why some denial of service attacks work, what use they might have, the TCP sequence prediction vulnerabilities, and port scanning.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.