Theory
वह Layer जिसमें आप जीते हैं
सातों OSI layers में से, application layer वह है जिसके साथ आप actually interact करते हैं। आप कभी frames या packets के बारे में नहीं सोचते, पर आप हर दिन email और web इस्तेमाल करते हैं। Application layer ये services provide करती है, email, web browsing, file transfer, सीधे आपके programs को।
यह lesson दो application-layer essentials cover करता है: email कैसे काम करता है (इसके पीछे accounts, mailboxes, और protocols), और एक URL क्या है, absolute और relative URLs के बीच difference समेत। दोनों बाद वाले end-to-end case studies को set up करते हैं।
Theory
Email कैसे काम करता है
हर email user का एक account है एक address के साथ (riya@example.com जैसा) और एक mail server पर stored एक mailbox। Sending और receiving अलग protocols इस्तेमाल करते हैं।
भेजने के लिए, आपका mail program SMTP (Simple Mail Transfer Protocol) इस्तेमाल करता है, जो message को बाहर push करता है और इसे mail servers के बीच relay करता है जब तक यह recipient के server तक न पहुँचे, जहाँ यह उनके mailbox में रखा जाता है।
Received mail पढ़ने के लिए, आपका program इसे आपके mailbox से POP3 (Post Office Protocol) या IMAP (Internet Message Access Protocol) इस्तेमाल करके pull करता है। तो सोचिए: SMTP भेजता है, POP3/IMAP retrieve करते हैं। तीनों application-layer protocols हैं।
Theory
URLs: Absolute बनाम Relative
एक URL (Uniform Resource Locator) web पर एक resource का address है। यह दो forms में आता है।
एक absolute URL complete address देता है: scheme, domain, और पूरा path, उदाहरण के लिए https://example.com/images/logo.png। यह कहीं से भी काम करता है, क्योंकि यह सब कुछ spell out करता है।
एक relative URL सिर्फ़ एक partial path देता है, उदाहरण के लिए images/logo.png, और browser बाकी current page की location के based पर fill करता है। तो https://example.com/ पर एक page पर, relative images/logo.png same absolute address में resolve होता है। Relative URLs shorter हैं और context में resolved होते हैं।
At a glance
| Aspect | Absolute URL | Relative URL |
|---|---|---|
| Contains | पूरा address (scheme + domain + path) | सिर्फ़ एक partial path |
| Example | https://example.com/images/logo.png | images/logo.png |
| कहाँ से काम करता है | कहीं से भी, यह complete है | Current page की location के against resolved |
| इसके लिए Best | दूसरी sites को link करना | same site के अंदर link करना |
Quiz
एक email system में, एक message SEND करने (और mail servers के बीच इसे relay करने) के लिए कौन सा protocol इस्तेमाल होता है?
- POP3, क्योंकि यह mail post करता है
- SMTP (Simple Mail Transfer Protocol), जो servers के बीच mail send और relay करता है
- IMAP, क्योंकि यह messages instantly send करता है
- HTTP, क्योंकि email internet पर है
Show the answer
SMTP (Simple Mail Transfer Protocol), जो servers के बीच mail send और relay करता है
SMTP (Simple Mail Transfer Protocol) email SEND करने और इसे mail servers के बीच relay करने का protocol है जब तक यह recipient के mailbox तक न पहुँचे। Option A 'Post Office' नाम के बावजूद ग़लत है: POP3 आपके mailbox से mail RETRIEVE (download) करने के लिए इस्तेमाल होता है, इसे send करने के लिए नहीं। Option C ग़लत है: IMAP, POP3 की तरह, server पर received mail RETRIEVE और manage करने के लिए है, send करने के लिए नहीं। Option D services confuse करता है: HTTP web pages transfer करता है; email अपने खुद के protocols इस्तेमाल करता है। Split याद रखिए: SMTP भेजता है (बाहर push करता है और relay करता है), जबकि POP3 और IMAP retrieve करते हैं (आपके mail program में pull करते हैं)।
Think first
हमेशा पूरा Address लिखने की बजाय Relative URLs क्यों इस्तेमाल करें?
Absolute URLs हमेशा काम करते हैं। तो web developers अक्सर एक site के अंदर relative URLs क्यों इस्तेमाल करते हैं? फिर tap कीजिए।
Show the answer
क्योंकि relative URLs एक site को PORTABLE और maintain करना आसान बनाते हैं, क्योंकि वे domain को hard-code नहीं करते। सैकड़ों internal links और images वाली एक site imagine कीजिए। अगर हर एक ABSOLUTE URL इस्तेमाल करती जैसे https://example.com/images/logo.png, तो site को एक नए domain में move करना, या launch से पहले इसे locally test करना भी, हर link को नए address में edit करने तक तोड़ देता। RELATIVE URLs के साथ जैसे images/logo.png, हर link current page की location जो भी हो उसके against resolved होता है, तो same pages live domain पर, एक staging server पर, या development के दौरान आपके laptop पर बिना changed चलते हैं, links बस सही जगह point करते हैं जहाँ भी site currently रहती है। यह site को move, rename, और maintain करना कहीं आसान बनाता है, और markup को shorter और cleaner रखता है। Trade-off यह है कि relative URLs सिर्फ़ same site के अंदर links के लिए sense रखते हैं (जहाँ 'यहाँ से relative' meaningful है); एक DIFFERENT website को link करने के लिए आपको एक absolute URL इस्तेमाल करना पड़ेगा, क्योंकि कोई shared context नहीं है। तो practical rule है: internal links के लिए relative (portable, tidy), external वालों के लिए absolute (complete, unambiguous)। Relative URLs एक site को care नहीं करने देते इसका अपना address क्या है, जो exactly वह है जो इसे move करना आसान बनाता है।
Summary
Key takeaways
- Application layer (OSI 7) सीधे user programs को network services provide करती है: email, web, file transfer।
- एक email user का एक mail server पर एक account/address और एक mailbox है।
- SMTP (Simple Mail Transfer Protocol) mail भेजता है और इसे servers के बीच relay करता है; POP3 और IMAP इसे mailbox से retrieve करते हैं।
- याद रखिए: SMTP भेजता है, POP3/IMAP retrieve करते हैं, सारे application-layer protocols।
- एक URL एक web address है; एक absolute URL पूरा address देता है (scheme + domain + path)।
- एक relative URL सिर्फ़ एक partial path देता है, current page की location के against resolved; एक site के अंदर links के लिए best।
- Memory hook: SMTP out, POP3/IMAP in; absolute = पूरा address, relative = context में resolved।