YouTube2Text

What Really Happens When You Make an HTTP Request? Chai aur Computer network — Transcript

by Chai aur Code · 4,401 words · 634 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Hello everyone, welcome back to another
  2. 0:01video. And in this video, we're going
  3. 0:03to talk about what happens when you
  4. 0:05make an HTTP request. Okay? So, I'm
  5. 0:07starting this playlist with this video
  6. 0:09because I'm assuming you've built a few
  7. 0:11servers. Maybe to do applications or
  8. 0:13you've worked on a project where you
  9. 0:15have a front end and a back end
  10. 0:16involved, where you're making HTTP
  11. 0:18requests from the front end to the back
  12. 0:20end. And you know how you do that. But
  13. 0:23you have no idea what happens under the
  14. 0:25hood. Okay? So, that's what we're going
  15. 0:27to demystify in this video. What's the
  16. 0:29agenda of this video? I'm going to
  17. 0:31introduce a lot of networking concepts
  18. 0:33in this video. I mean, I won't give you
  19. 0:35an in-depth explanation. I'll just
  20. 0:37introduce you to them so that when we
  21. 0:39look at them in-depth in the playlist,
  22. 0:41or create a dedicated video for them,
  23. 0:42you'll have a reminder that when I
  24. 0:44first learned about HTTP requests, this
  25. 0:46component was in this section. Okay? So
  26. 0:48, with that said, let's jump into the
  27. 0:50video. Now, let's see what happens when
  28. 0:52you make an HTTP request. Okay? So,
  29. 0:53let's have the React front end. It's
  30. 0:57running on my local laptop at 12701 and
  31. 0:583000. We all know what this is? This is
  32. 1:01my local host. This is a looped backing
  33. 1:03IP. Okay? And 3000 is my port on which
  34. 1:05my React JS is running. Then I also
  35. 1:07have a React JS back end that I
  36. 1:09deployed on AWS EC2. And that's running
  37. 1:13on IP 10001 and port 443. Okay? It can
  38. 1:17be 8000, but I've chosen 443. Let's
  39. 1:19note, I've also hosted the backed JS
  40. 1:21server with the domain name https
  41. 1:23apix.com. What is ps? This is a
  42. 1:27protocol secured by HTTP. We'll look at
  43. 1:28this in detail in the future. There
  44. 1:30will be a dedicated video for each of
  45. 1:32these concepts I'm introducing. Okay?
  46. 1:35One disclaimer: in this video, I'll use
  47. 1:37this as my source IP. What is my source
  48. 1:39? The one initiating the request. Okay?
  49. 1:41The one initiating the request is my
  50. 1:43front end. And this will be my
  51. 1:44destination IP, 10001. But the
  52. 1:46disclaimer is, this can't be my public
  53. 1:48IP, because this is a looped back end
  54. 1:49IP. That means this IP has no
  55. 1:53significance outside of this laptop.
  56. 1:56But in this video, for simplicity, I'll
  57. 1:58consider this IP as a source IP. Just
  58. 2:01note this. But after this video, we'll
  59. 2:03cover everything in detail about IP,
  60. 2:04MAC, ports, TCP, and HTTP in a
  61. 2:07dedicated video. For simplicity, I'm
  62. 2:09using the source IP address here as
  63. 2:11localhost. And my destination IP
  64. 2:13address is 10001. Currently, 10001
  65. 2:15generally falls within a private IP
  66. 2:18range. But for simplicity, let's use
  67. 2:20this as my public IP address. I just
  68. 2:22wanted to add a disclaimer so no one
  69. 2:24can hack it. For simplicity, let's keep
  70. 2:26this as the source IP address and this
  71. 2:28as the destination IP address. So, what
  72. 2:29is an HTTP request? Whenever you
  73. 2:32execute this code, the response is
  74. 2:34equal to await fetch https apix.com.
  75. 2:38Let's use the slash profile address and
  76. 2:40send an HTTP request. So, this is how
  77. 2:42we code this HTTP request. As a
  78. 2:44developer, we write this code and
  79. 2:46forget it. But let's see what happens
  80. 2:48under the hood of this code. Now, the
  81. 2:50first thing that happens is we do a DNS
  82. 2:52query. Why? Because in Fetch, if you
  83. 2:54see this, this is my domain name. And
  84. 2:56over the internet, because this is my
  85. 2:58local laptop. This is my AWS EC2
  86. 3:00instance, which is in a different data
  87. 3:02center. So, physically, these are two
  88. 3:04different machines. Okay? So, to
  89. 3:05connect them, we have to travel over
  90. 3:07the internet. And to travel over the
  91. 3:10internet, just knowing the host name
  92. 3:12isn't enough because what is this? This
  93. 3:14is just a string. And using a string to
  94. 3:16travel over the network over the
  95. 3:18internet isn't feasible. So, what do we
  96. 3:20need? We need the IP address of my
  97. 3:22destination. When I'm writing this
  98. 3:24request in this front-end code, as a
  99. 3:26developer, I'll use the domain name.
  100. 3:28API example.com. But what does Fetch do
  101. 3:31under the hood? It will make a DNS
  102. 3:33request. What is DNS? Domain Name
  103. 3:35System. Okay? What is a Domain Name
  104. 3:37System? Simply put, there's a dedicated
  105. 3:39video on it. What does it do? It takes
  106. 3:41a host name as input and returns its
  107. 3:44relative public IP address, which in
  108. 3:47our case, we've assumed is 10001.
  109. 3:50That's it. That's the job of DNS.
  110. 3:52Obviously, we'll look at DNS in detail
  111. 3:54to see exactly what it entails. What is
  112. 3:57a recursive resolver? What are DNS
  113. 3:59resolvers, authoritative name servers?
  114. 4:01What are root servers? What are
  115. 4:02top-level domain servers? We'll explore
  116. 4:04everything in depth in the future. But
  117. 4:06for now, the first thing that happens
  118. 4:08is it runs a fetch DNS query for this
  119. 4:10domain name, which will return the
  120. 4:12public IP address that this host name
  121. 4:14holds. Meaning, whatever the public IP
  122. 4:16address of this host name is, the one I
  123. 4:18configure in my DNS settings. Whenever
  124. 4:19I deploy NoteJS, it will be returned by
  125. 4:22my DNS. Okay? So we've got the
  126. 4:24destination IP using DNS. Okay? Now
  127. 4:26let's keep note of all these criteria
  128. 4:28we've noted. So these are the criteria
  129. 4:31we've noted. What is our source IP?
  130. 4:3312701 Again, this is a loop back. But
  131. 4:35for this video, let's assume this is my
  132. 4:37public IP. Okay? Then what is the
  133. 4:39source port? It's 3000. What is the
  134. 4:41destination IP? 10001. What is the
  135. 4:43destination port? It's 443 because it's
  136. 4:46HTTPS. Where will the ReactJS front end
  137. 4:50run? The browser, that's the web app
  138. 4:51run on the browser. So, whenever the
  139. 4:53browser sees HTTPS, it will assume that
  140. 4:56your destination port will be 443. Okay
  141. 4:59? So, we've got these criteria. Now
  142. 5:01let's see what happens next. So I've
  143. 5:02already created the flow. I've created
  144. 5:04the design. Now let's see exactly what
  145. 5:07happens. This HTTP request looks
  146. 5:09something like this. Right? It will
  147. 5:11have HTTP. What is the type of request?
  148. 5:13What is the path name that is the slash
  149. 5:15profile. Right? Here we are making an
  150. 5:17API call using our slash profile. Right
  151. 5:19? Then there will be a header where we
  152. 5:20will insert our bearer token
  153. 5:21authentication token. There will be
  154. 5:23some cookies. There will be some custom
  155. 5:24headers. Right? So this is what my HTTP
  156. 5:26request looks like. And HTTP is based
  157. 5:29on TCP. That means whenever you make an
  158. 5:32HTTP call, under the hood it uses the
  159. 5:34TCP protocol. What is TCP? It is
  160. 5:36Transmission Control Protocol. In the
  161. 5:38future, there will be a dedicated
  162. 5:40module on this where there will be five
  163. 5:42or six videos in which we will
  164. 5:43demystify TCP in depth. We'll learn
  165. 5:45everything about TCP. Flow control,
  166. 5:47congestion control, everything. For now
  167. 5:49, just remember that HTTP is built on
  168. 5:51top of TCP. Okay? Right? This is an
  169. 5:53HTTP request. First thing, what happens
  170. 5:55? We convert this text, which is a kind
  171. 5:58of text, into bytes. Why? Because when
  172. 6:00data travels over the network, it's
  173. 6:02obviously going to be bits, ones and
  174. 6:04zeros. Right? So, how do we need to
  175. 6:06convert our text, which is a string,
  176. 6:08into bytes? So, when we make the
  177. 6:10request, this HTTP request is converted
  178. 6:13into bytes using some text encoder.
  179. 6:15That's enough for now. In the future,
  180. 6:17we'll look at these details when we
  181. 6:19look at HTTP to see exactly what its
  182. 6:20structure is. Okay? Now, we've got the
  183. 6:22bytes of this HTTP request. I've
  184. 6:24represented them in hexadecimal form.
  185. 6:27So, I've got a big stream of bytes.
  186. 6:30Once this is done, my browser says, "
  187. 6:33I've prepared the data that I need to
  188. 6:36send to this back end. Please send this
  189. 6:39data over the internet." Who does it
  190. 6:41say this to? My operating system. This
  191. 6:43object. The browser's job is simply to
  192. 6:45understand the request. Run DNS queries
  193. 6:48, get the IP address, get the public IP
  194. 6:50address, and get the port address.
  195. 6:51Right? Once that's done, the whole
  196. 6:53thing is ready. Now, to actually send
  197. 6:55it physically, it has to take help from
  198. 6:57the underlying operating system. Right?
  199. 7:00So, the browser tells me to send this
  200. 7:01data over the network. Now, my OS's TCP
  201. 7:03/IP stack comes into the picture. What
  202. 7:06is an OS's TCP/IP stack? My underlying
  203. 7:09OS, whether it's Mac OS, Windows, or
  204. 7:11Linux, has its own implementation for
  205. 7:13all these things, including networking.
  206. 7:16That's TCP, UDP, ICMP, and IP, which
  207. 7:18we'll obviously see in detail in the
  208. 7:20future. All these things are dealt with
  209. 7:23at the OS level. Because at the end,
  210. 7:25whatever your request is physically
  211. 7:26transferred through the network card,
  212. 7:28the network interface card, is
  213. 7:29controlled by the OS. The browser can't
  214. 7:31handle it. The browser can't control it
  215. 7:33. So, once the browser is ready with
  216. 7:36the bytes of my actual HTTP request, it
  217. 7:38delegates the actual networking work to
  218. 7:41my OS's TCP/IP stack. That's nothing
  219. 7:43but your OS's IP/TP stack. Okay? So, it
  220. 7:45says send the data over the network.
  221. 7:47Now, what does the OS's TCP/IP stack
  222. 7:49say before sending this data to my back
  223. 7:52end? Because HTTP is based on TCP, and
  224. 7:55TCP is a connection-oriented protocol.
  225. 7:58We'll see this in detail in the future.
  226. 7:59Why is that? What do you mean by
  227. 8:01connection-oriented protocol? Before we
  228. 8:03can actually send this data between our
  229. 8:06source and destination, we need to
  230. 8:08establish a TCP connection. Keep in
  231. 8:11mind that I have a client, which is my
  232. 8:13front end, and a server, which is my
  233. 8:15back end. To send any data to the
  234. 8:17server, my client needs a pipe through
  235. 8:20which it will send data. To create that
  236. 8:23pipe, TCP uses something called a TCP
  237. 8:26three-way handshake. We'll cover this
  238. 8:28in detail in a dedicated video. What
  239. 8:30exactly is this? But what does it do at
  240. 8:31a higher level? This will create a TCP
  241. 8:34connection between my front end and
  242. 8:36back end, through which all this data
  243. 8:38will flow. Okay? So, what's the first
  244. 8:41thing the OS does? As soon as the
  245. 8:42browser tells it to send this data over
  246. 8:44the network, it first creates a TCP
  247. 8:45connection. This is the starting point.
  248. 8:47Once the connection is established, it
  249. 8:49takes this entire block and breaks it
  250. 8:52into chunks. Okay? This is the
  251. 8:53essential part. Because this data can
  252. 8:55be very large. Right now, my HTTP
  253. 8:57request might be 500 bytes or 600 bytes
  254. 9:00. But there's a chance I might have a
  255. 9:021GB PDF file. So, this is a lot of data
  256. 9:04. Right? So, this data can be big. What
  257. 9:06does TCP say? Instead of sending this
  258. 9:08whole data at a time, I'll break it
  259. 9:10into smaller chunks. This chunking has
  260. 9:14an algorithm. It also depends on your
  261. 9:17MTU (Maximum Transmission Unit) and MSS
  262. 9:20(Maximum Segment Size). We'll have a
  263. 9:22dedicated video on MTU and MSS in the
  264. 9:24future. Okay? So, don't worry, you'll
  265. 9:26understand all this in detail. So,
  266. 9:28based on MSS and MTU, the size of this
  267. 9:31chunking is defined: whether it's a
  268. 9:33two-byte chunk or maybe a 10-byte chunk
  269. 9:36. Right? This depends on multiple
  270. 9:38factors. Okay? Now, let's assume it
  271. 9:40created two-byte chunks. So, this is
  272. 9:42one byte of FE12. Okay? Which I've
  273. 9:44entered here in this diagram. Then this
  274. 9:46byte of 00 appears. This is the
  275. 9:48hexadecimal representation of my HTTP
  276. 9:50request. It's not actual. I've entered
  277. 9:52this hexadecimal format at random. But
  278. 9:54let's assume that this hexadecimal
  279. 9:56format is the HTTP request itself. So,
  280. 9:58we're breaking the hexadecimal format
  281. 10:00of this HTTP request into smaller
  282. 10:02chunks. This chunking is also done by
  283. 10:05the TCP/IP stack of OC OS. Let's assume
  284. 10:08it created these 20 chunks. Okay?
  285. 10:10That's a total of 20 chunks. There are
  286. 10:11a few chunks in between as well. Once
  287. 10:12the connection is established, I'm
  288. 10:14converting all the data into chunks.
  289. 10:16Along with converting this into chunks,
  290. 10:18this means that after converting the
  291. 10:20actual data into chunks, it will attach
  292. 10:22a source port and a destination port.
  293. 10:24This is the important part. TCP deals
  294. 10:26with port numbers. What is a port?
  295. 10:29React JS running on 3000? 3000 is a
  296. 10:31port. FastAPR running on 8000? 8000 is
  297. 10:33a port. Okay? So, my port tells me
  298. 10:36which of the 1000 processes running on
  299. 10:38that one physical machine I want to
  300. 10:41forward the data to. In this case, my
  301. 10:43source port will be 3000, which is the
  302. 10:46port of my React.js front end. So, my
  303. 10:48source port tells me where this segment
  304. 10:51comes from. This is the instance part.
  305. 10:53And what is the destination port? It's
  306. 10:54the port of my EC2 instance's React.js
  307. 10:56back end. If you see 443, why? Because
  308. 10:58my HTTP is running on PS. So the
  309. 11:00browser assumes it's running on port
  310. 11:02443. Right? So, 4443 is the point when
  311. 11:04this segment is seen and it reaches my
  312. 11:07EC2 instance. What is an EC2 instance?
  313. 11:09It's a standalone machine. There could
  314. 11:10be 1000 processes running on it. Maybe
  315. 11:12I just ran Python's instance on it.
  316. 11:14Maybe I also ran Django on it, which
  317. 11:16runs on different ports. So the
  318. 11:18destination port indicates, in this
  319. 11:20case, 443, that this segment is
  320. 11:23destined for my JS backend. Whenever
  321. 11:25this segment reaches this backend,
  322. 11:27we'll see in the future how it will
  323. 11:29arrive. As soon as it reaches, based on
  324. 11:32the destination port, the data from
  325. 11:34that segment, the data in between, is
  326. 11:36forwarded to this new backend. Okay? So
  327. 11:38that's the meaning of port numbers. Now
  328. 11:41, in this TCP segment, along with my
  329. 11:43data, FPE 12, this is part of my data.
  330. 11:45What I've created by breaking up the
  331. 11:46actual HTTP request is a chunk. The
  332. 11:48source port is the source port, and the
  333. 11:50destination port is the JS port. Along
  334. 11:52with this, there are many other things
  335. 11:54that we'll see in the future. In a
  336. 11:55separate video, we'll look at the
  337. 11:57anatomy of a TCP segment. Okay? But
  338. 11:59along with this, we also have a
  339. 12:00sequence number in it. What is a
  340. 12:02sequence number? These chunks that I
  341. 12:04created, I will send them independently
  342. 12:05through the network to the destination.
  343. 12:07Okay? Here, let's say, is my
  344. 12:08destination. This is my data that I've
  345. 12:10broken up in order. That means F12
  346. 12:12comes first. 0A comes second, then this
  347. 12:14, then this. Okay? There's a chance
  348. 12:16when I send this independently? There's
  349. 12:18a chance that this chunk of mine will
  350. 12:20arrive first, and then this chunk will
  351. 12:21arrive. So, this is how TCP ensures
  352. 12:23that the data I've sent reaches the
  353. 12:25destination in the same order it's
  354. 12:27broken up. So, it has something called
  355. 12:30a sequence number. Okay? We'll look at
  356. 12:33this in detail in a dedicated video.
  357. 12:35We'll see exactly what it is and how
  358. 12:36it's calculated. So, based on sequence
  359. 12:38numbers, TCP can actually reorder these
  360. 12:41chunks so that your data reaches its
  361. 12:43destination in the same order you send
  362. 12:45it. Okay? So, we'll look at this in
  363. 12:47detail in future videos. Okay? Once the
  364. 12:49TCP segment is ready, we'll encapsulate
  365. 12:50the TCP segment further. First, we took
  366. 12:55the data and broke it down and
  367. 12:55encapsulated it with port numbers. Now,
  368. 13:02we'll take that TCP segment and
  369. 13:02encapsulate it inside an IP packet.
  370. 13:04What is my IP packet? Where I
  371. 13:05encapsulate the TCP segment into a
  372. 13:07source IP and a destination IP. This is
  373. 13:10the important part. Now, it also looks
  374. 13:12at my OS's TCP/IP stack. What will it
  375. 13:14do? What is my source IP? 12701. Again,
  376. 13:16a big disclaimer. This is the loop back
  377. 13:19IP. This is not a public IP, but for
  378. 13:21simplicity, I've used this IP in this
  379. 13:22video. Let's consider it as the public
  380. 13:25IP where my React JS is running.
  381. 13:27Similarly, this is my AWS destination
  382. 13:29IP, 10001. No need to worry about this
  383. 13:32loop backg, it is. Ignore it. Just
  384. 13:34consider it as the public IP. So, my
  385. 13:36source IP is 1701. My destination IP is
  386. 13:3910001. Using that, I encapsulated this
  387. 13:41TCP segment. That's it. That's your IP
  388. 13:44packet. Obviously, IP packets contain
  389. 13:45other things in headers. We'll cover
  390. 13:47that in detail in a future dedicated
  391. 13:49video when we look at the anatomy of an
  392. 13:50IP packet. Okay? But for now,
  393. 13:52understand that the DCB segment
  394. 13:53encapsulates an IP packet with its
  395. 13:55source IP and destination IP. Why do we
  396. 13:56need a source IP and a destination IP?
  397. 13:58Obviously, what is a source IP? The IP
  398. 13:59of the machine from which I'm sending
  399. 14:01the request—in this case, that's just
  400. 14:02React's front end. What is a
  401. 14:03destination IP? The IP of the machine
  402. 14:05to which I want to send the data. Now,
  403. 14:08this destination IP helps routers
  404. 14:10decide how to reach this machine. Okay?
  405. 14:14So, as soon as React JS sends this IP
  406. 14:16packet, it goes to my first router. The
  407. 14:18router sees the destination IP. We'll
  408. 14:20see how this happens in detail. But I'm
  409. 14:22giving you a high-level explanation
  410. 14:23here. It sees the destination IP, then
  411. 14:25it will decide if it knows where this
  412. 14:27IP is. Okay? There's a chance it might
  413. 14:29know where this IP is. But since it's
  414. 14:31my AWS EC2 instance, technically my
  415. 14:33home router doesn't know it. Based on
  416. 14:35this, it will decide which router to
  417. 14:37send it to next, which may also know
  418. 14:39the destination IP. Okay? It's not even
  419. 14:41sure it knows the router. But it makes
  420. 14:44a decision and decides, "I should send
  421. 14:46this packet to this router, which also
  422. 14:47knows where this IP address is." So,
  423. 14:49through these hops, we'll reach AWS EC2
  424. 14:52. Right? So, in this journey we're
  425. 14:54making, hop after hop, the destination
  426. 14:56IP address is used at each hop to
  427. 14:58determine whether this IP address is
  428. 15:00known to us by the routers. Right? So,
  429. 15:03that's the meaning of the destination
  430. 15:04IP. What's the meaning of the source IP
  431. 15:06address? The first thing is, where did
  432. 15:07this data come from? As soon as this
  433. 15:09data reaches the back end, it will know
  434. 15:10, "Yes, this data came from here.
  435. 15:12That's this. Again, 12701 is my public
  436. 15:14IP." Right? It came from here. So, as
  437. 15:16soon as my back end receives this
  438. 15:18request, it will have a response ready.
  439. 15:20That's the profile it fetched from the
  440. 15:22DB. It created a JSON. First name,
  441. 15:24username, email, phone number,
  442. 15:25everything related to the profile. Now
  443. 15:27it needs to return a response to this
  444. 15:29request. Where should it return it?
  445. 15:30Then it will see the source IP address
  446. 15:32that came in the request. Right? So
  447. 15:34this is how the source IP address and
  448. 15:35destination IP address are used. Now,
  449. 15:37once this IP packet is ready, further
  450. 15:39encapsulation occurs. Which is kind of
  451. 15:41a final step where we encapsulate this
  452. 15:44IP packet with the source and
  453. 15:45destination MAC addresses. What is a
  454. 15:48MAC address? A media access control
  455. 15:50address, like my destination IP address
  456. 15:54, tells me how to reach this EC2
  457. 15:56instance as we travel across the
  458. 15:59internet. But once we reach the network
  459. 16:01of that EC2 instance, that means that
  460. 16:03EC2 instance will be connected to a
  461. 16:05router, right? So, as I travel through
  462. 16:07the internet, I'll first reach that
  463. 16:10router. Once I reach that router, once
  464. 16:13I reach that local network, the MAC
  465. 16:15address is required for that router to
  466. 16:18send data to that AC2 instance. So, the
  467. 16:20MAC is a type of physical address for
  468. 16:22that device. The IP is a type of
  469. 16:24virtual address for that device. The IP
  470. 16:26indicates the location of that device
  471. 16:28on the Internet. And once we reach the
  472. 16:30local network of that device, we need
  473. 16:33the MAC address. We'll learn about this
  474. 16:35in detail when we learn about MAC
  475. 16:37addresses and when we look at routing.
  476. 16:39In routing, you'll learn what MAC
  477. 16:41addresses and IP addresses mean. Okay?
  478. 16:43That's enough for now. IP is a type of
  479. 16:45virtual addressing. MAC is a type of
  480. 16:47physical address for that device. The
  481. 16:49actual physical address of that device.
  482. 16:51Now, what will my source IP be? It will
  483. 16:53be the MAC address of my local laptop's
  484. 16:54network interface card. What is the
  485. 16:56network interface card? It's a device.
  486. 16:58It's a physical device with a kind of
  487. 17:00antenna on it that can transmit or
  488. 17:03receive data in the form of signals.
  489. 17:05That's your network interface card.
  490. 17:07We'll look at this in detail when we
  491. 17:09learn about the structure of a MAC
  492. 17:10address. But we have a nic network
  493. 17:12interface card, which has a MAC address
  494. 17:14. That's mine as a source address
  495. 17:16attached in this frame. The destination
  496. 17:18MAC should technically be the MAC
  497. 17:20address of my NJS backend. But I don't
  498. 17:23know the MAC address of my NJS backend.
  499. 17:25Because this isn't in my local network.
  500. 17:28What is my local network? It's my
  501. 17:29machine. My router is connected. My
  502. 17:31mobile is connected, and my printer is
  503. 17:33connected. All these devices are part
  504. 17:35of a local area network. That means my
  505. 17:37laptop is aware of the router, mobile,
  506. 17:40and the printer. Beyond that, it
  507. 17:42doesn't have direct access to all the
  508. 17:44devices on the internet worldwide. It
  509. 17:46can only access them through the router
  510. 17:48. Okay? So, technically, my note is
  511. 17:50just running on an EC2 instance, which
  512. 17:52is also a physical machine. It will
  513. 17:54also have a network interface card
  514. 17:55through which it receives and transmits
  515. 17:57signals. Its MAC address will not be
  516. 17:59known to my React JS front end. So, on
  517. 18:01a higher level, what happens? Whenever
  518. 18:03I don't know the destination MAC
  519. 18:05directly, I will add a fallback MAC
  520. 18:07address which is of my default gateway.
  521. 18:10We will understand what a default
  522. 18:12gateway is. Now you will say that I
  523. 18:13added this fallback MAC address to my
  524. 18:15default gateway. What is my default
  525. 18:16gateway? My router. Now you will say,
  526. 18:18how do I know this MAC address? Because
  527. 18:20the router is a different machine. So,
  528. 18:22there is something called @AR. That is
  529. 18:24Address Resolution Protocol. What is
  530. 18:26this? It is a kind of DNS in which it
  531. 18:28takes in an IP address. It goes into
  532. 18:31the ARC and it will spit out the MAC
  533. 18:33address of the device that is holding
  534. 18:36that IP. That means my laptop, where I
  535. 18:38have my React JS front end running,
  536. 18:41will send a kind of request, an RRP
  537. 18:44request, to every device on that
  538. 18:46network. That means my laptop will send
  539. 18:49an RRP request to my mobile, to my
  540. 18:51printer, to my router, asking, "Who has
  541. 18:53this IP?" Let's say my router, this is
  542. 18:56my router, its IP is 192.168.1. So my
  543. 19:01laptop will ask, "Who has IP 192.168.1?
  544. 19:03" This request, an RRP request, will
  545. 19:08literally go to my mobile, my router,
  546. 19:11and my printer, but only the person
  547. 19:13with this IP will reply to it. So my
  548. 19:16mobile and my printer will ignore it,
  549. 19:19my router will catch it, and the router
  550. 19:21will then reply to me, "The MAC of the
  551. 19:24device holding 192.168.1 is this." Okay
  552. 19:27? We'll obviously cover this structure
  553. 19:28in a future dedicated video. This is
  554. 19:30how it's used. Okay? So, the source MAC
  555. 19:32is my machine's. The destination MAC is
  556. 19:35, as I told you, because I don't know
  557. 19:36the MAC address of my EC2 instance.
  558. 19:37I'll fall back to the MAC address of my
  559. 19:39default gateway. In my case, my default
  560. 19:41gateway is my router. I'm also going to
  561. 19:43create a dedicated video on the default
  562. 19:45gateway. It's the device through which
  563. 19:47I access the internet. In my case, it's
  564. 19:48my router. So, here's where my router's
  565. 19:50MAC address will be. How? I'll create
  566. 19:52an RAPP Request Address Resolution
  567. 19:53Protocol. I'll also create a dedicated
  568. 19:55video on this, explaining how the app
  569. 19:57works in detail. So, this is how my
  570. 19:59frame is ready. Once this frame is
  571. 20:02ready, we'll transmit it as bits over
  572. 20:05the wire or over the air. Right now, my
  573. 20:08network interface card (NIC) has an
  574. 20:10antenna. Okay, what will it do? It will
  575. 20:12transmit this frame using radio signals
  576. 20:14(if I'm using Wi-Fi), electrical
  577. 20:16signals (if I'm using Ethernet), and
  578. 20:18light signals (if I'm using fiber
  579. 20:19optics). As soon as it's transmitted,
  580. 20:22it's happening in this part of my
  581. 20:24request. That means my request, my data
  582. 20:27, this entire data that I've broken
  583. 20:29down and sent hasn't even reached my
  584. 20:32back end. This instance is still in
  585. 20:34this part of my flow. What you see is
  586. 20:37where the request is actually being
  587. 20:39transmitted from the front end. That's
  588. 20:41where we're transmitting that request
  589. 20:43to the back end. It hasn't reached
  590. 20:44there yet. So, you can see the entire
  591. 20:46flow where we just write this code and
  592. 20:48receive the response. There are so many
  593. 20:51things in that 1/4 part, and I've taken
  594. 20:53this at a high level because I want to
  595. 20:55introduce these concepts to you so that
  596. 20:57we can carry forward those concepts and
  597. 21:00understand them in dedicated videos. So
  598. 21:03that was the high-level overview of
  599. 21:05what happens whenever you send a single
  600. 21:08HTTP request. We saw about DNS. We
  601. 21:11introduced DNS. We introduced IP
  602. 21:13addresses, ports, destination IP, and
  603. 21:15destination port. Okay? We introduced
  604. 21:17STTP, then we introduced what a TCP
  605. 21:19connection is, then we introduced the
  606. 21:21TCP three-way handshake, then we
  607. 21:22introduced chunking within TCP, then we
  608. 21:24looked at a higher level what a
  609. 21:26sequence number is, then we introduced
  610. 21:28how a TCP segment is formed, then we
  611. 21:30introduced how an IP packet is formed,
  612. 21:32then how a frame is formed and how it's
  613. 21:34transmitted over the network in the
  614. 21:35form of bits, then we saw what MAC
  615. 21:37addresses are, then we saw a small
  616. 21:39introduction to exactly what R is. So,
  617. 21:41my agenda of including all these things
  618. 21:44in this video is to tell you about them
  619. 21:47. Okay? Everything here was a
  620. 21:49high-level overview of each concept.
  621. 21:52We'll explore each concept in detail in
  622. 21:54the future. That's why I introduced you
  623. 21:56to these concepts in this video. So
  624. 21:58please rewatch this video. Just
  625. 22:00understand the flow. Don't worry if you
  626. 22:03don't understand, we are definitely
  627. 22:05going to demystify every concept in
  628. 22:07depth in this entire playlist. So
  629. 22:09that's it for this video. I hope you
  630. 22:11gain some knowledge. If you did, please
  631. 22:12like the video. If you have any doubts
  632. 22:14or suggestions, please leave them in
  633. 22:15the comments. I hope to see you in the
  634. 22:17next one.

About this transcript

This page contains the full transcript of What Really Happens When You Make an HTTP Request? Chai aur Computer network by Chai aur Code, generated from the public captions YouTube serves with the video. The transcript has 4,401 words across 634 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.