Skip to content

Margus Roo –

If you're inventing and pioneering, you have to be willing to be misunderstood for long periods of time

  • Cloudbreak Autoscale fix
  • Endast

Author: margusja

Internet Protocol (IP) Layers Explained

Posted on February 13, 2008 - January 22, 2009 by margusja

All IP packets have at least one header, which is known as the IP header; sometimes this header is also called a Layer 3 or network header. The IP header is simply a series of bits which have been grouped into fields of a set size. All IP headers have the same structure; the only difference will be which bits have been set to “1” to either turn on a field’s value or to represent a binary number within a field. Let’s take a closer look at the fields in an IP header:

Ver. IHL Type of service Total length
Identification Flags Fragment offset
Time to live Protocol Header checksum
Source address
Destination address
Option + Padding
Data

Here is one example packet between my computer and www.neti.ee webpage:

ip-packet

An IP packet has 14 fields; let’s go through these fields one at a time.
Version
This is a 4-bit field that indicates the IP version, written in binary. For example if you are using IPv4, the bits will be set to 0100; if you are using IPv6, the bits will be set to 0110.

IHL or header length
This 4-bit field indicates how long the IP packet header is; this value is used to distinguish which part of the IP packet is the header, and which part is the actual data. If you take a look at the picture of the IP packet, you’ll notice that it is 32 bits wide. Now take a look at the length of the packet: the data is not part of the header, the options are optional, but all other fields are required. This means that the minimum header length is five 32-bit words, or binary 0101. You’ll sometimes see these words translated into bytes; that is, five words multiplied by 4 bytes (32 bits divided by 8 bits to make a byte) equals a header length of 20 bytes. If the options are used, the header length will be at least six 32-bit words. Since this is a 4-bit field, the maximum length will be 2 to the power of 4 minus 1, or 15. This effectively limits the size of an IP header to 60 bytes (15 words multiplied by 4 bytes).

Type of Service (sometimes called TOS) flags
This field is 8 bits long; the first 3 bits are called precedence bits and the last 5 bits represent the type of service flags. These flags were originally created to prioritize which packets should be delivered and which packets could be dropped if a router became congested. Since then, other protocols have been invented to prioritize traffic and most routers ignore these flags even if they have been set.

Total length; also called packet length or datagram length
This 16-bit field represents the total length of the IP packet, meaning both the data and the header. The minimum size is 21 bytes (default header size plus one byte of data). Since this field is 16 bits long, the maximum packet size is 2 to the power of 16 minus one, or 65,535 bytes. (The minus one represents the illegal length value of 0.)

Identification
Every IP packet is given an identification number when it is created; that number is contained within this 16-bit field. It is possible for an IP packet to be separated into smaller “fragments” before it reaches its final destination; each fragment still belongs to the original IP packet, so each fragment will have the same identification number.

Flags
This field contains three flags as follows:
reserved flag: must always be 0
don’t fragment flag: if set to 0, this flag is off, meaning you can fragment the IP packet; if set to 1, this flag is on, meaning you don’t fragment this IP packet
more fragments flag: if set to 0, there are no more fragments; if set to 1, there are more fragments of this IP packet yet to arrive

Fragment offset
If an IP packet has been fragmented, each fragment will have a value in this 13-bit field indicating where this fragment’s data fits into the original IP packet. For example, let’s pretend an IP packet containing 128 bytes of data was fragmented into two fragments each containing 64 bytes of data. The fragment containing the first 64 bytes of data would have a fragment offset of 0 as its data belongs at the very beginning of the original IP packet. The fragment containing the last 64 bytes of data needs to indicate that its data starts after the first 64 bytes. Since the number in this field represents an 8-byte multiple, its fragment offset will be 8 (8 multiplied by 8 = 64 bytes).

Time to Live (often called TTL)
Whenever an IP packet passes through a router, the router will decrease the TTL by one; if the TTL ever reaches 0, the packet will be thrown away under the assumption that it must be undeliverable as it hasn’t been delivered by now. The original TTL value depends upon the operating system; your FreeBSD system uses a default TTL of 64. Since this is an 8-bit field, the maximum allowable TTL is 255 (2 to the power of 8 minus 1; the minus 1 is for the non-allowable TTL of 0).

Protocol
This 8-bit value specifies which protocol’s data is contained within the IP packet and gives a good indication of what type of information will be contained within the data portion of the packet. The protocol numbers that appear in this field are found in the “/etc/protocols” file on your FreeBSD system.

For example, the protocol number 1 represents the ICMP protocol. This means that this IP packet does not contain any data from an application; instead, it contains a small amount of ICMP data. We’ll be taking an in-depth look at ICMP and how it affects your firewall in a separate article.

A protocol number of 6 indicates the TCP protocol. You may remember from earlier articles that TCP is a connection-oriented transport. This IP packet will have an additional header known as a TCP header that will be located just after the IP header and before the beginning of the actual data that is being delivered.

A protocol number of 17 indicates the UDP protocol, which is the connectionless transport. This IP packet will have a UDP header located just after the IP header and before the beginning of the data that is being delivered.

Header Checksum
Whenever an IP header is created or modified, a CRC (cyclic redundancy check) is run on the bits contained within the IP header. Basically, some math (the CRC algorithm) is done which results in an answer known as the checksum. When the IP packet is received, the same CRC is repeated on the header; if this results in the same answer (checksum), all of the bits of the IP header must have arrived in the correct order. If the CRC results in a different checksum, some of the bits in the header didn’t arrive, meaning the IP packet was somehow damaged during transit.

Source Address
This will be the IP address of the host that sent the IP packet.

Destination Address
This will be the IP address of the host that is to receive the data contained within the IP packet.

Options and Padding
This is the only field in an IP packet which is optional, as all other fields are mandatory. This field is used to provide special delivery instructions not covered by the other fields in an IP header. It can allow for up to 40 bytes worth of extra instructions; these instructions must be in 32-bit words. If an instruction doesn’t quite fill up a 32-bit word, the missing bits will be filled in with “padding” bits.

Data
The last field in an IP packet is called the data field. This will be the actual data that is being sent from one host to another. The data field may start with a Layer 4 header, which will give additional instructions to the application that will be receiving the data; alternately, it may be an ICMP header and not contain any user data at all.

Posted in LinuxLeave a comment

Ajax

Posted on February 4, 2008 - February 4, 2008 by margusja

Et ei saaks ütelda et ma pole kursis 🙂

Minu esimene ajax 🙂 klikka siia

Posted in Linux, WindowsLeave a comment

Tripp Lõuna-Eestis ja Põhja-Saldejumpsis

Posted on February 4, 2008 by margusja

Meenutusi paaripäevasest tripist. Tegelikult oli point minna otsima kunagi järve kõrkjatesse uppunud langevarjuri mälestusmärki. Sellega oli siiski raskem kui me ette kujutasime. Alguses sai otsitud Viljandi järve äärest. Selleks isegi ööbisime Viljandis. Siis kõne Dillingerile ja selgus, et deem, vale järv. Õige järv on oopis Võrtsjärv. Kimasime siis Võrtsjärve äärde. Müttasime metsas ja uurisime kohalikelt ja ilmselt leidsime peaaegu ka õige koha kuid jah suht märg on meie talv ja jalas ei olnud päris selleks ettevõtmiseks sobivad jalanõud. Selleks korraks sai hukkunud langevarjur meist rahu kuid nii see ei jää.

paar lahedamat pici asjast.

Möödasõit:

Möödasõit

Setumaa piiril:

Setumaa piiril

Võõpsu City

Võõpsu City

Kõik on ässad

Kõik on ässad

Seeriast lahedad tanklad

Lahe tankla 1

Geopeituri varustus

Geopeituri varustus

Saldejumps

Saldejumps

Tankla 2

Tankla 2

Siin läheduses peab puhkama langevarjur.

Paat

Posted in FunLeave a comment

dsniff

Posted on February 1, 2008 by margusja

Väga väärtuslik tool, juhul kui on vaja leida mõni kadunud parool.

Posted in Linux, TurvalisusLeave a comment

Mailman

Posted on January 31, 2008 by margusja

mailman.x86_64 3:2.1.9-5.1

Fedora release 7 (Moonshine)

Antud versioonidega on jama selles, et weebiliidese kaudu listi tegemine on katki, teadmiseks endale siis. Muidu punnin jälle 2 tundi, enne kui aru saan, et .db faile ei genereerita. Aga katki ei ole, newlist käsurealt toimub mõnusalt.

Posted in LinuxLeave a comment

E39 katuseluuk

Posted on December 30, 2007 - August 4, 2014 by margusja

katuseluuk.png

Posted in BMWLeave a comment

Kuidas peita mysql connection data

Posted on December 20, 2007 by margusja

<VirtualHost www.firma.ee>
<Location /scriptdir/>
php_value mysql.default_host localhost
php_value mysql.default_user example
php_value mysql.default_password secretpassword
</Location>

</VirtualHost>
# Koodis
$dbconn = mysql_connect();

Posted in LinuxLeave a comment

Mysql ja charset

Posted on December 19, 2007 - February 27, 2008 by margusja

Ütlen asualt erinevad charsetid on saatanast.

Oli mul leht kus on selge sõnaga charset=iso-8859-1.

Mysql:

character_set_client  -latin1
character_set_connection – latin1
character_set_database  – latin1
character_set_filesystem  – binary
character_set_results  – latin1
character_set_server – latin1

Peaks vastama iso-le.
Samas brauseris vaadates tee mis tahad brauser arvab et utf-8.

Lõpuks aitas kui koodis esimeseks mysqlpäringuks sai: mysql_query(“SET NAMES ‘utf8′”);

Lisaks kogu sellele jamale on veel selline asi olemas nagu AddDefaultCharset “utf-8” Apache confis, mis saadab alati ose oma charseti olenemata mis brauseris on.

Lisaks saab php confis anda ette default_charset=utf-8 mis on siis sama effektiga.

Posted in LinuxLeave a comment

Ldap

Posted on December 12, 2007 - October 16, 2014 by margusja

Kuna ma olen ldap-i kohapealt ikka ilge koba siis panen siia mõne rea endale spikriks.

Kui centoses on pakist paigaltatud

Siis /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{2\}bdb.ldif vajalikud muudatused

parooli saab slappasswd käsuga genereerida

openldap ja slapd käivitatud, siis peaks:

ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts

andma:

# extended LDIF

#

# LDAPv3

# base <> with scope baseObject

# filter: (objectclass=*)

# requesting: namingContexts

#

#

dn:

namingContexts: dc=vivalte,dc=com

# search result

search: 2

result: 0 Success

# numResponses: 2

# numEntries: 1

 

 

Loome base entry – näiteks faili nimega base.ldif sisuga:

# Organization for Example Corporation

dn: dc=example,dc=com

objectClass: dcObject

objectClass: organization

dc: example

o: Example

description: Example

# Organizational Role for Directory Manager

dn: cn=Manager,dc=example,dc=com

objectClass: organizationalRole

cn: Manager

description: Directory Manager

Lisame baasi kirje:

ldapadd -f base.ldif -x -D “cn=Manager,dc=example,dc=com” -w secret

slapcat peaks andma tagasi ka lisatud kirje

 

ldapsearch -h localhost -D “cn=Manager,dc=example,dc=com” -b “dc=example,dc=com” -w secret “(uid=mina)”

Posted in LinuxLeave a comment

Sitapead

Posted on December 6, 2007 by margusja

Ükskord istusin oma laua taga, kui mulle meenus telefonikõne, mille olin unustanud teha. Ma leidsin numbri ja valisin selle. Meeshääl vastas:
“Hallo!” Ma ütlesin viisakalt: “Mina olen Tiit. Kas ma saaksin rääkida Marek Piegusega?!” Vastuseks karjus meeshääl mulle kõrva: “Hangi omale õige number, ****!” ja lõi telefonitoru hargile. Ma ei suutnud uskuda, et keegi saab olla nii häbematu.
Kui ma valisin Mareki korrektset numbrit, et talle helistada, avastasin, et olin kogemata kaks viimast numbrit segamini ajanud.
Peale temaga kõne lõpetamist otsustasin uuesti helistada valele numbrile.
Kui sama tüüp telefonile vastas, karjusin ma: “Sa oled sitapea!” ja panin toru ära. Ma kirjutasin ta numbri üles ja kirjutasin sinna kõrvale sitapea.
Ja kleepisin selle lauaplaadile. Iga paari nädala tagant, kui ma maksin arveid, või mul oli eriti s*** päev, helistasin ma talle ja karjusin: “Sa oled sitapea!”
Kui hakati pakkuma “numbrinäidu” teenust, mõtlesin, et mu teraapiline sitapeale helistamine peab saama lõpu, sest võin vahele jääda. Igaks juhuks otsustasin kontrollida, kas jobu sellest teab. Ma helistasin tema numbrile ja ütlesin: “Tere! Mina olen Toomas Tool Elionist. Helistan, et teada sada, kas te olete juba tuttav meie uue “numbrinäidu” teenusega?” Ta karjus: “EI!” ja lõi telefoni hargile. Ma helistasin talle kiiresti tagasi ja ütlesin: “See on sellepärast, et sa oled sitapea!” ja katkestasin kõne.
Ühel päeval kui olin Selveri juures ja valmistusin parkima, lõikas mingi tüüp musta BMW-ga mul tee ära ja parkis end kohale, mida ma kannatlikult oodanud olin. Ma tuututasin signaaliga ja vehkisin kätega – tema lihtsalt näitas mulle keskmist sõrme. Aga tema auto küljeaknal ilutses silt: MÜÜA, koos tema telefoninumbriga. Ma kirjutasin selle üles…
Paar päeva hiljem, kohe peale seda, kui olin esimesele sitapeale helistanud (mul oli ta number kiirvalimise all) ja ta korralikult läbi sõimanud, arvasin, et ma helistan sellele BMW sitapeale ka. Ma küsisin: “Kas teie olete see, kellel on must BMW müüa??” Ta vastas: “Jah, olen küll!” Ma küsisin: “Kas ma saaksin seda ka näha?” Ta ütles: “Jah, ma elan Vanapapli 14, Veskimöldres. See on helebee? majake ja autod on kohe ette pargitud.”
Siis küsisin: “Mis su nimi on?” Ta ütles: “Mu nimi on Madis Muul.” “Millal on hea aeg, sind leida, Madis?” “Ma olen kodus igal õhtul, peale kella 17”
“Kuule Madis, kas ma saan sulle midagi öelda?” “Jah?” “Madis, sa oled sitapea!” Siis panin ma toru ära ja salvestasin ka tema numbri kiirvalikusse.
Edaspidi, kui mul oli probleeme, oli mul kaks sitapead, kellele helistada.
Ühel päeval olin kogu maailma peale tige ja otsisin oma vihale väljundit.
Siis tuli mul idee. Helistan esimesele sitapeale. Ta ütles: “Hallo” Ma
ütlesin: “Sa oled sitapea!” kuid ei pannud toru ära. Ta küsis: “Oled sa veel seal?” Ma vastasin: “Jah” Ta karjus: “Lõpeta mulle helistamine!” Ma
ütlesin: “Eks sunni mind!” Ta küsis: “Kes sa oled?” Ma vastasin: “Mu nimi on Madis Muul” Ta ütles: “Jah?? Kus sa elad?” Ma vastasin: “Sitapea, ma elan Vanapapli 14, Veskimöldres, bee?is majakeses. Mul on must bemm maja ette pargitud, et sa teaksid.” Ta ütles: “Ma tulen kohe sinna, Madis-poiss. Ja sul on parem juba testament ära teha!” Ma ütlesin: “Jah, ma juba tõsiselt kardan, sitapea!” ja panin toru ära.
Siis helistasin ma teisele sitapeale. Ta ütles: “Hallo?” Ma ütlesin: “Hallo, sitapea!” Ta karjus: “Kui ma peaksin teada saama, kes sa oled…” Ma
ütlesin: “Mis siis saab?” Ta ütles: “Ma kütan su **** kuumaks!” Ma
vastasin: “Sul on see võimalus, sitapea! Ma tulen kohe sinu juurde!” Siis panin ma toru ära ja helistasin politseisse. Ütlesin, et elan Vanapapli 14, Veskimöldres ja et ma olen teel koju, et tappa oma elukaaslasest pedesõber.
Siis helistasin ma Kanal 2 Reporterisse, et kohe läheb lahti mölluks lahti aadressil Vanapapli 14. Vennad lubasid kärmelt kaameratega kohale kimada.
Seejärel läksin oma autosse ja sõitsin Veskimöldre poole.
Ma jõudsin sinna täpselt õigel ajal, et näha kuidas kaks sitapead just kohale jõudnud politseiauto ees teineteist tümitasid. Ning loomulikult ei puudunud ka telemehed oma kaameratega…
Kohe tundsin ennast PALJU paremini. Viha taltsutamine toimib tõepoolest, tuleb ta lihtsalt enda seest välja lasta!

Posted in Fun1 Comment

Posts navigation

Older posts
Newer posts

The Master

Categories

  • Apache
  • Apple
  • Assembler
  • Audi
  • BigData
  • BMW
  • C
  • Elektroonika
  • Fun
  • Hadoop
  • help
  • Infotehnoloogia koolis
  • IOT
  • IT
  • IT eetilised
  • Java
  • Langevarjundus
  • Lapsed
  • lastekodu
  • Linux
  • M-401
  • Mac
  • Machine Learning
  • Matemaatika
  • Math
  • MSP430
  • Muusika
  • neo4j
  • openCL
  • Õpetaja identiteet ja tegevusvõimekus
  • oracle
  • PHP
  • PostgreSql
  • ProM
  • R
  • Turvalisus
  • Varia
  • Windows
Proudly powered by WordPress | Theme: micro, developed by DevriX.