The Everyman's Guide to How Network Packets Are Routed Across the Web

转自: http://null-byte.wonderhowto.com/how-to/hacker-fundamentals-everymans-guide-network-packets-are-routed-across-web-0134491/

 

We already covered how your data travels the OSI model, layer by layer, and talks with other machines on your local network. But how does that data leave your network? How does it know where to go? What's going on here?

Much of the 'talking' on a local network are broadcasts. This computer is asking for the MAC address of another one, or asking for a local IP address, or any number of things. But doesn't that mean the Internet should be flooded with various broadcast noise all over the place? As it turns out, no. You see, the job of a router is not only to route traffic, but to stop broadcasts. To explain this concept fully, let's look into some examples.

No routers were hurt in the writing of this article.

 

A Tale of Two Packets: Internal

If you remember correctly, an IP address has two components, the network section and the host section. A subnet mask separates the IP address into those two segments (<network><host>). A subnet is expressed just like an IP address in a four octet form, the most common one being 255.255.255.0 where the '255' means those octets are describing the network and the '0' is describing the host.

Let's say you wanted to send data to another computer on your local network at home. Your internal IP address in this example is 172.10.1.20 and your destination IP address is 172.10.1.30. Also, let's assume your subnet mask is a standard 255.255.255.0.

The first thing that gets done is the computer looks at the address on the packet being sent. It then compares its address with the destination address. Notice the 172.10.1.x is the same on both, and the subnet mask has filled octets in the same locations as well ( 255.255.255.0). This tells the computer that the destination is on the same network it is on. Your computer knows it is host '20' and it needs to reach host '30' and it doesn't need to go through a router to get there.

 

Now your computer only needs to know the MAC address of host '30' to send this data on its way. If you recall the Media Access Control address is a physical layer function that addresses actual physical hardware on your computer. In a nutshell, it works like an IP address, only on your local network.

 

ARP!

To perform this feat, your computer sends out a broadcast message to everyone on the network called an ARP, or Address Resolution Protocol. It's like your PC yelling "HELLO! I am looking for the computer 172.10.1.30".

Now each device on the network receives that message and looks at its own IP address in turn. The router (172.10.1.1) sees it is not the one being looked for and drops the message. Other computers on the network do the same thing until the computer that has the IP of 172.10.1.30 gets it, checks its address, and sees they match. It then replies back to the sending computer of 172.10.1.20 saying "HEY! That's me and my MAC address is AA00:BC33:3211".

In the picture below, the MAC address is called an "Ethernet address", reflecting the fact that it's addressing for the physical layer. However, common lingo is "MAC address"

 

Now the sending computer has the internal IP and MAC address of the receiving computer and can send its data over. But what happens if the two addresses are not on the same network?

A Tale of Two Packets: External

Well, it's not as simple when we have to cross other networks, as there is a bit more going on behind the scenes, as you will see. Let's assume we are sending the same data as before and our source IP address is 172.10.1.20 and our destination IP address is 192.168.0.100. You should immediately notice by the subnet mask of 255.255.255.0 that these two addresses are on separate networks. See, we are getting there.

Just like in the first example, the sending computer looks at the destination address and compares it to its own. However, this time there is a problem—they don't match at all.

Now it knows that it can't just send out an ARP message like before, because remember what happened in the last example, when the routers address didn't match the address being asked? It simply dropped the packet. This is how routers stop broadcasts from traveling the entire Internet. In fact, without this design, the Internet would be flooded with so many broadcast messages from the millions of connected devices that it would crash and fail.

 

At this point, your computer knows an ARP just isn't going to cut it for the destination of 192.168.0.100, so it broadcasts another ARP. But this time is looks for what's called the default gateway. This is a node, or a router, that acts as an entry or exit point to another network.

Normally, when a computer cannot find a route for an IP address, it will send it along to the default gateway as a route of last resort. This is your modem/router at home. Your router will reply saying, "YO! I am the default gateway and my MAC address is xxxx:xxxx:xxxx!"

Your computer then adds the routers MAC address as the destination MAC address to the packet, and sends it over to the router for safe travels。

 

Route Me Baby!

The router takes a look at the packet and knows the source IP came from its own network. But the destination is separate altogether. Because the destination is not the same as the router's own internal IP address, it knows the packet is not for it, but needs to travel through it

The router then looks at its routing tables to find a way to get to the 192.168.0.xnetwork. It leaves the source and destination IP address information inside the packet, and changes the new source MAC address to its own address and the destination MAC address to the next node deducted from the routing table.

This process continues over and over with each router that picks up the packets looking at the addresses, seeing it's not for their network and passing it along until it reaches the final destination of 192.168.0.100.

That router will strip of the source and destination MAC addresses that allowed the packets to travel, and replace the source with its own. It then ARPs to find the MAC address of the server being looked for and uses the reply to add the final MAC address of that machine, then sends it along.

 

转载于:https://www.cnblogs.com/morningdew/p/6034834.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/469947.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

oracle忽略除数为0,ora-01476除数为0的解决办法,oracle中decode()的使用

执行报表查询&#xff0c;固定的一个时间点没有数据&#xff0c;应该是有数据的&#xff0c;把前一个时间节点往前调是有的&#xff0c;往后调也有bebug报错把sql放到数据库中&#xff0c;发现提示如截图解决办法&#xff0c;oracle中的decode()select decode(b,0,0,a/b*100) …

Confluent Platform 3.0支持使用Kafka Streams实现实时的数据处理(最新版已经是3.1了,支持kafka0.10了)...

来自 Confluent 的 Confluent Platform 3.0 消息系统支持使用 Kafka Streams 实现实时的数据处理&#xff0c;这家公司也是在背后支撑 Apache Kafka 消息框架的公司&#xff0c;它近日宣布 最新的开源平台已经达到了通用发布&#xff08;general availability&#xff09;版本。…

oracle串连接,Oracle中串连接符||的使用心得(个人见解)

Oracle中可以用串连接符||将若干个串连在一起(Oracle中也可以使用concat函数&#xff0c;但是它只最多连接两个串。而MySQL中concat可以连接多个串。在SQL Server中则使用进行串连接)。当然&#xff0c;这两个串可以是列名或字面值。例如&#xff1a;select province || city f…

HDU5971【瞎搞】

题意&#xff1a;略&#xff08;忙着准备文化课。。。明天期中考啊。。。。 思路&#xff1a; 正解就是染色&#xff0c;2-sat搞&#xff1b; AC代码&#xff08;虽然是错误的。。。数据水&#xff08;过踏马的也行啊&#xff0c;起码打脸他啊&#xff01;&#xff09; 4 3 1 0…

性能测试oracle瓶颈定位,性能测试中如何定位性能瓶颈

性能测试的概念是什么&#xff0c;基本目的是什么&#xff0c;我想大家都基本清楚&#xff0c;不作详述&#xff0c;总之&#xff0c;性能测试只是测试过程中的一种方式&#xff0c;帮助我们的功能更好的运行&#xff0c;如果功能测试是可用&#xff0c;易用&#xff0c;满足需…

Java GridBagLayout 简单使用

这里只介绍了很基础布局构建及使用&#xff0c;主要是关于 GridBagLayout. 首先整套流程大概是&#xff0c; 声明一个 GridBagLayout 对象 private GridBagLayout gridBagLayoutFrame new GridBagLayout(); 然后把当前类的容器布局管理器设置为 GridBagLayout this.setLayout(…

oracle数据库存储ip地址,oracle – 以十进制形式存储的IP地址 – PL / SQL以虚线四边形显示...

这是您需要的功能&#xff1a;create or replacefunction inttoip(ip_address integer) return varchar2deterministicisbeginreturn to_char(mod(trunc(ip_address/256/256/256),256))||.||to_char(mod(trunc(ip_address/256/256),256))||.||to_char(mod(trunc(ip_address/256…

Angular之简单的登录注册

使用Angular实现了一个简单的登录注册的功能........ 涉及到的Angular知识点很少 主要是这个功能的实现...(*^__^*) 嘻嘻…… 里面涉及到的知识点记录: 1.本地存储的操作 localStorage 获取本地存储的值 window.localStorage.getItem(key)-->value (得到的数据是字符串&qu…

Linux命令行调用动态库,Linux动态链接库的使用

动态链接库与普通的程序相比而言&#xff0c;没有main函数&#xff0c;是一系列函数的实现。通过shared和fPIC编译参数生产so动态链接库文件。程序在调用库函数时&#xff0c;只需要连接上这个库即可。例如下面实现一个简单的整数四则运输的动态链接库&#xff0c;定义的cacula…

Linux用户、用户组、文件权限设置

最近打算更仔细学习一下linux操作系统。先是恶补了一下用户、用户组、文件权限这三样比较重要的知识。(我也正在学Linux&#xff0c;所以就找到这篇日志了&#xff0c;有些设置修改后需要重启系统后才能生效。)学习这几样东西&#xff0c;得先掌握linux的权限系统相关知识。lin…

linux系统ip访问53端口,linux – 使用公共IP地址无法访问本地端口

我有一个linux服务器,它有公共IP和私有IP.因此,当我使用公共IP登录时,终端直接显示私有IP.例&#xff1a;$ssh root55.27.XX.XXroots password:root10.1.4.20:~$hostname -I10.1.4.20root10.1.4.20:~$wget -qO- http://ipecho.net/plain ; echo55.27.xx.xx现在,我安装了Nginx,我…

微信扫码下载iosAPP

1.首先在应用宝上传你的安卓APP应用&#xff0c;AppStore已经有了APP 2.进入应用宝app应用管理中心&#xff0c;点击“微下载”&#xff0c;然后里面的微下载链接地址就可以用了&#xff0c;可以看到ios可以通过应用宝再跳到AppStore就可以实现下载了转载于:https://www.cnblog…

linux当前时间到1970年秒数,计算从1970年到当前时间所经历过的秒数

这个算法来自LINUX的源码&#xff0c;下面带有大神的解析&#xff0c;自己在RTC实验中也使用了&#xff0c;不用月份表&#xff0c;润平年的处理&#xff0c;几行就可得出结果&#xff0c;以下是程序和大神的解析Linux源码中的mktime算法解析我们知道&#xff0c;从CMOS中读出来…

脱水缩合(大搜索)

脱水缩合 (merge.c/cpp/pas) 【题目描述】 fqk 退役后开始补习文化课啦&#xff0c; 于是他打开了生物必修一开始复习蛋白质&#xff0c;他回想起了氨基酸通过脱水缩合生成肽键&#xff0c;具体来说&#xff0c;一个氨基和一个羧基会脱去一个水变成一个肽键。于是他脑洞大开&am…

ubuntu16.04下安装NS-2.35以及对simple例的理解

本人是在VMWare上安装的ubuntu16.04版本&#xff0c;然后安装NS2.35. 1.下载ns2的安装包&#xff0c;这里我选择的是ns-allinone-2.35.tar.gz压缩格式的all in one安装包&#xff0c;all in one 安装包包含所有的组件&#xff0c;比较方便&#xff0c;另附下载地址&#xff1a;…

linux查看登录服务器的ip历史记录,通过登陆IP记录Linux所有用户登录所操作日志的方法...

对于Linux用户操作记录一般通过命令history来查看历史记录&#xff0c;但是如果在由于误操作而删除了重要的数据的情况下&#xff0c;history命令就不会有什么作用了。那么依然要存有历史操作记录应该如何来实现呢&#xff1f;其实我们可以通过登陆IP地址来记录所有用户登录所操…

linux 向程序发送信号,Linux下的信号处理

Linux下的信号处理发布时间:2006-01-02 09:34:14来源:红联作者:reing前言&#xff1a;这一章我们讨论一下Linux下的信号处理函数。Linux下的信号处理函数&#xff1a;信号的产生信号的处理其它信号函数一个实例1.信号的产生Linux下的信号可以类比于DOS下的INT或者是Windows下的…

思科模拟器:[1]安装及汉化详解

思科模拟器是网络工程师经常使用的网络实验模拟软件&#xff0c;它可以很快捷的模拟网络中的各种设备(交换机、路由器、台式电脑、笔记本电脑、服务器、网络云)&#xff0c;搭建各种网络环境&#xff0c;模拟网络拓扑结构等。下面天使图文教程&#xff0c;告诉大家怎么安装这个…

linux中的加法函数,上下文管理练习(为加法函数计时)

上下文管理(为加法函数计时)为加法函数计时使用装饰器显示该函数的执行时长使用上下文管理显示该函数的执行时长装饰器实现import timeimport datetimefrom functools import wrapsdef logger(fn):wraps(fn) # wraps(fn)(wrapper)def wrapper(*args, **kw):start datetime.dat…

07数组与接口

1、运行TextInherists.java 示例&#xff0c;观察输出&#xff0c;注意总结父类与子类之间构造方法的的调用关系&#xff0c;修改parent构造方法的代码&#xff0c;显式调用grandparent另一个构造函数。 源代码&#xff1a; class GrandParent{ public GrandParent(){ System.o…