TCP si UDP, ce sunt si care sunt diferentele

Stefanescu Mihai 9 months ago iNoob

Daca acum incepi sa inveti despre retelistica sau deja te-ai jucat putin in acest domeniu sigur ai intalnit acesti termeni, TC si UDP.

TCP vine de la Transmission Control Protocol, iar UDP care vinede la User Datagram Protocol sunt parte din suita de protocoale Internet Protocol. TCP si UDP sunt 2 metode diferite de a transmite informatii in retea.

Baze ale retelisticii

Inainte sa povestim cum functioneaza cele 2, TCP si UDP ar trebui sa trecem putin in revista modul in care functioneaza internetul.

Vorbind la modul general, internetul este o retea de dispozitive conectate unul la celalalt. Fiecare dispozitiv, fie ca este un telefon sau un server, comunica cu ajutorul suitei Internet Protocol.

Suita Internet Protocol este o colectie de diverse protocoale, sau metode, folosite de dispozitive pentru a comunica intre ele.

Legenda imagine:
FTP: File Transfer Protocol
SMTP: Simple Mail Transport Protocol
HTTP: Hyper Text Transfer Protocol
PPP: Point-to-point Protocol
ARP: Adress resolution protocol
ICMP: Internet control message protocol
UDP: User datagram protocol
TCP: Transmission Control Protocol

Fiecare dispozitiv ce este conectat la internet are o adresa unica (IP). Cand 2 dispozitive comunica prin internet mai mult ca sigur folosesc fie TCP fie UDP.

Iata o imagine care explica cat se poate de succint cele 2:

Pentru mai multe detalii legat de modul in care functioneaza internet-ul am sa va recomand acest video:

 

Ce este TCP?

TCP, sau Transmission Control Protocol cred ca este cel mai comun protocol. TCP este foarte stabil si este folosit pentru a naviga pe internet (HTTP), pentru trimis mailuri (SMTP), pentru transferul de fisiere (FTP) si altele.

TCP este folosit in situatiile in care este necesar ca datele trimise de un device sa fie primite de celalalt device in mod complet.

De exemplu, cand intri pe un website, TCP este folosit pentru a garanta ca totul, cod, text, imagini, etc, ajunge la client. Fara TCP, imaginile sau textul ar putea lipsi, sau ar putea ajunge in ordinea gresita si sa strice modul in care este afisat site-ul.

TCP este connection-oriented, asta inseamna ca stabileste o conexiune intre device-uri inainte de a transfera informatiile si mentine conexiunea pe intreaga durata a procesului de transfer.

Pentru a stabili o conexiune intre device-uri TCP foloseste o metoda numita three-way handshake:

De exemplu, pentru a citi acest articol, prima data dispozitivul tau a trimis un mesaj de tip SYN (Syncronize Sequence Number) catre serverul invata-programare.
Apoi, serverul invata-programare a trimis inapoi un mesaj de acknowledgement (SYN-ACK).
Cand dispozitivul tau a primit mesajuld e tip SYN-ACK de la server a trimis inapoi un mesaj de tip ACK care a stabilit conexiunea.

O data ce o conexiune TCP a fost creata intre dispozitive, acest protocol garanteaza ca toate datele sunt transmise.

Intorcandu-ma la exemplul de mai sus, o data ce s-a terminat procesul de three-way handshake, serverul invata-programare a input sa trimita toate datele necesare ca tu sa poti citi acest articol.

Toate device-urile impart datele trimise in pachete mici inainte de a le trimite prin internet, apoi urmand sa fie "asamblate" la loc.

Asadar, cand serverul invata-programare trimite HTML, CSS, JavaScript, imagini si alte lucruri necesare afisari articolului, imparte totul in pachete mici inainte de a le trimite catre dispozitivul tau. Apoi, dispozitivul tau compune tot mesajul din packetele trimise.

TCP asigura ca toate aceste pachete ajung pe dispozitivul tau, iar daca vre-un pachet se pierde dispozitivul poate determina ce pachet lipseste su il poate cere din nou de la server.

O data ce toate pachetele au fost trimise pe dispozitiv, conexiunea TCP se inchide folosind o metoda similara three-way handshake, dar de aceasta data foloseste mesaje de tip FIN si ACK.

Ce este UDP?

UDP, sau User Datagram Protocol, este un alt protocol din suita Internet Protocol. UDP nu este atat de "sigur" cand vorbim de integritatea transmisiei datelor ca TCP, dar este mult mai simplu.

UDP este folosit in momentele in care pierderea unor date este acceptabila, precum live audio/video streaming, sau situatiile in care viteza este un fatcor critic, de exemplu in cazul jocurilor online.

In timp ce UDP este similar cu TCP in ceea ce priveste obiectivul, acela de a trimite date prin internet, exista cateva diferente intre ele.

In primul rand UDP este un protocol connectionless, adica nu stabileste o conexiunea inte de trimiterea datelor cum face TCP acel three-way handshake.

UDP nu garanteaza ca toate datele au fost transferate cu success. UDP trimite datele oricarui dispozitiv care asculta, dar nu tine cont daca o parte dintrre pachete s-au pierdut pe drum. De asta acest protocol mai este stiut si ca protocolul "fire-and-forget".

Concluzii

Daca vorbim de viteza, am putea spune ca UDP este mai rapid, dar acest lucru nu inseamna ca este un protocol mai bun ca TCP.
Pur si simplu sunt diferite si au intrebuintari diferite.

UDP este mult mai simplu pentru ca nu incearca sa stabileasca o conexiune inainte de a trimite datele si de asemenea, nici nu verifica integritatea datelor.

TCP, de asemenea, permite si buffering, adica browser-ul tau poate cere mai multe date pe masura ce le consumi pe cele existente (de exemplu cat timp vezi o parte din video, browser-ul cere continuarea inainte de a ajunge acolo ca sa vezi fara ca video-ul sa se opreasca).

UDP este ideal pentru live video/audo si online gaming pentru ca acolo ai nevoie de viteza.

Fin

Sper ca acest articol te-a ajutat sa intelegi mai bine aceste 2 protocoale (TCP si UDP).

 

 

 

 

Programator de ~8 ani, am lucrat la proiecte din mai multe industrstrii, de la eCommerce la telecomunicatii la automatizari. In acest timp am folosi diferite tehnologii, de la PHP, MySQL, PostgreSql, RabbitMq, Redis, Memcached si altele.


Get in touch
Pentru nelamuriri, dubii, comentarii si chestii de pe suflet ne putem auzi pe Discord, Reddit sau poti deschide o discutie noua pe forum

Rpmkdh # 1 month ago buy fenofibrate 160mg online cheap <a href="https://fenoficor.com/">order tricor 160mg sale</a> fenofibrate 200mg oral
¿dónde comprar ansitec de forma segura? # 1 month ago Hi! I'm at work surfing around your blog from my new apple iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Carry on the outstanding work!
Obtén perlutex en España # 1 month ago I was wondering if you ever thought of changing the layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or two pictures. Maybe you could space it out better?
acheter du theophylline # 1 month ago Keep on writing, great job!
Rjthho # 1 month ago ketotifen price <a href="https://flixitorp.shop/">zaditor pill</a> buy tofranil pills
Raesjx # 4 weeks ago buy aspirin 75 mg pill <a href="https://levquinon.shop/">buy hydroquinone cream for sale</a> zovirax creams
Vtcibc # 4 weeks ago brand precose <a href="https://micronide.shop/">purchase repaglinide generic</a> fulvicin cost
Chong # 3 weeks ago Hi! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a extraordinary job!
¿Dónde puedo conseguir trihexyphenidyl en Venezuela? # 3 weeks ago Hello, i think that i saw you visited my website thus i came to “return the favor”.I'm trying to find things to improve my web site!I suppose its ok to use a few of your ideas!!
Felicia # 3 weeks ago What i don't realize is if truth be told how you're no longer really much more well-preferred than you may be now. You're very intelligent. You recognize therefore significantly on the subject of this subject, made me individually imagine it from so many varied angles. Its like men and women are not fascinated except it is one thing to accomplish with Girl gaga! Your individual stuffs excellent. Always deal with it up!
Nsfjxg # 3 weeks ago florinef 100mcg uk <a href="https://acipolax.shop/">purchase dulcolax for sale</a> brand imodium 2 mg
Priscilla # 2 weeks ago Excellent blog right here! Also your website loads up very fast! What host are you the use of? Can I get your associate hyperlink on your host? I desire my site loaded up as fast as yours lol
Wniule # 2 weeks ago order monograph sale <a href="https://colotazol.shop/">buy cheap generic pletal</a> order pletal 100mg for sale
Xrlorq # 2 weeks ago order prasugrel 10mg for sale <a href="https://thoramine.com/">chlorpromazine 100mg cost</a> detrol where to buy
Zthtcd # 2 weeks ago ferrous 100mg brand <a href="https://fertonel.com/">buy generic ferrous</a> sotalol 40mg us
Vhgmss # 2 weeks ago order mestinon <a href="https://mestien.shop/">purchase piroxicam for sale</a> purchase rizatriptan pills
Smsdel # 1 week ago cost vasotec 10mg <a href="https://betaotec.shop/">buy vasotec sale</a> lactulose buy online
Ptxtkx # 1 week ago latanoprost order <a href="https://aexeloda.shop/">where can i buy rivastigmine</a> buy exelon generic
clenbuterol 40 mcg disponible en pharmacie # 1 week ago Good day! Do you use Twitter? I'd like to follow you if that would be ok. I'm undoubtedly enjoying your blog and look forward to new updates.
prix du medroxyprogesterone au Canada # 1 week ago Wow, wonderful weblog structure! How long have you ever been running a blog for? you made running a blog glance easy. The overall glance of your website is excellent, as smartly as the content material!
Ysnagm # 6 days ago telmisartan us <a href="https://atizordis.shop/">purchase telmisartan for sale</a> buy generic molnunat 200mg
clotrimazole a precio competitivo en Colombia # 4 days ago Have you ever considered publishing an e-book or guest authoring on other blogs? I have a blog based on the same information you discuss and would love to have you share some stories/information. I know my audience would value your work. If you are even remotely interested, feel free to shoot me an email.
liskonum 300 mg ohne ärztliche Verschreibung in Berlin # 4 days ago Hi there I am so thrilled I found your web site, I really found you by mistake, while I was searching on Askjeeve for something else, Anyways I am here now and would just like to say thank you for a tremendous post and a all round thrilling blog (I also love the theme/design), I don’t have time to read through it all at the minute but I have bookmarked it and also added your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the fantastic jo.
Uxusvn # 4 days ago buy cenforce online <a href="https://chlodinir.com/">aralen pills</a> chloroquine online
markspencer # 1 day ago Thanks for such a fantastic blog. Where else could anyone get that kind of info written in such a perfect way? I have a presentation that I am presently writhing on, and I have been on <a href="https://www.assignmentuk.co.uk/write-my-assignment">do my assignment</a> the look out for such great information.
Club-ul este dedicat membrilor si ofera access la mai multe zone ale website-ului.
Login Register

🔖 Bookmarks
✨ Pentru a sustine aceasta comunitate am sa te rog sa te autentifici sau sa te inregistrezi!

🌪️ Discord
Back to top
Folosim cookie-uri pentru a oferi functionalitatile critice ale aplicatiei Invata-Programare. Folosim cookie-uri si pentru a analiza traficul, pentru care e nevoie de consimtamantul dvs. explicit.