can some one explain communication between two clients in below network? - networking

PC1 -> switch A -> switch B -> PC2.
Ip address of PC1 -192.168.2.1
Ip address of PC2 -192.168.2.2
if i ping PC2 from PC1, how will be the packet forwarded?
what will be the packets source ip address, destination ip address, source mac address and destination mac address at port connecting to PC1 and at port connecting to PC2 ?

You can omit switches between hosts, because they don't affect or modify any communication between hosts. They just store informations about what MAC address is reachable at what interface to reduce spamming network segments with useless data. Whole communication will be done in few steps:
PC1 want to send ICMP packet to PC2, but don't know his MAC address yet
network:: PC1: ARP - what is address of 192.168.2.2?
network:: PC2: ARP - address of 192.168.2.2 is aa:bb:cc:dd:ee:ff
PC1 has now L2 address, it can send packet
network:: PC1: ICMP echo-request - src-mac: 11:22:33:44:55:66, src-ip: 192.168.2.1 ... dest-mac: aa:bb:cc:dd:ee:ff, dest-ip: 192.168.2.2
PC2 recieves ICMP echo-request, and want to send echo-reply, but don't know L2 address of 192.168.2.1
network: PC2: ARP - what is address of 192.168.2.1?
network: PC1: ARP - address of 192.168.2.1 is 11:22:33:44:55:66
network: PC2: ICMP echo-reply - src-mac: aa:bb:cc:dd:ee:ff, src-ip: 192.168.2.2 ... dest-mac: 11:22:33:44:55:66, dest-ip: 192.168.2.1

Related

How a PC can ping two diferent PCs with the same ip address in different vlans?

I have a question about VLANs and how they work.
here is the scenario;
I have a VLAN named vlan10 with PC1 and PC2 in it
The IP address of PC1: 10.10.10.10
The IP address of PC2: 10.10.10.20
and a VLAN named VLAN 20 with pc3 and pc4 in it
The IP address of PC3: 10.10.10.10
The IP address of PC4: 10.10.10.20
and they are connected to a switch and a router like this
Can PC1 ping IP address 10.10.10.20 in VLAN 20 which is IP address for PC4 in VLAN 20?
or because we have the same IP address in VLAN 10, PC1 can not ping the PC4 in VLAN 20?
Each PC matches an outgoing packet's destination address to its own subnet and talks to the destination directly. Even if you tried working around that using the router, the router would reject duplicate subnet addresses across different interfaces.
Whether duplicate addresses actually exist in the VLANs is irrelevant. When the destination address belongs to the sender's local subnet that's the end of the story.
Btw: you should take care to note the subnet prefix lengths, I'm assuming you use 10.10.10.0/24 (doesn't change the answer though).

Is all traffic within a network send to all hosts?

I am studying routing tables. Say you have the following line in a routing table
Destination Gateway Genmask
192.168.1.0 * 255.255.255.0
This would mean that there is no gateway for local traffic on the network and some resoures write that all the traffic on a local network is send to all hosts on the network. This raises two question:
Isn't it a security risk that every host receives all traffic, even though it is not intended for that host.
Does it slow the network when every packet is send to all hosts over either cables or wifi even though it is intended for only 1 host?
Is all traffic within a network send to all hosts?
No. Traffic sent from a host to another host in the same network is sent via layer-2, not layer-3. That means that traffic from hosts in an IP network are sent to other hosts in the same network via the layer-2, e.g. ethernet, network.
There is a protocol called ARP (Address Resolution Protocol) that is used to resolve layer-3 (IP) to layer-2 (MAC) addresses.
A host sending something to another host will mask both the source and destination layer-3 addresses with the configured host network mask. If the results are the same, it will use ARP to address the layer-2 frame with the destination host MAC address, otherwise it will use ARP to address the frame with the layer-2 address of its configured gateway.
If there is no configured gateway, the host should drop the traffic between layer-3 and layer-2.
A host will drop any traffic not sent its MAC addresses, the broadcast address, or any multicast address for which it is not subscribed.

sharing files on different subnets on windows

I am getting internet from a WISP close to my house using an out-door wireless network adapter. so first the internet comes to a desktop PC and from there i want to share it using a wireless router between other devices. beside internet sharing, i want devices connected to my wireless router to share files between each other and PC1.
here is what I've done to get as close as possible to what i need for my network. both devices running windows 8.1.
PC1 (deskptop):
IP address: 192.168.1.1
Default gateway: 192.168.1.1
Subnet: 255.255.255.0
shared network adapter with Ethernet port on PC1. Ethernet port is connected to WAN port of the router. turned on network discovery.
PC1 Ethernet port :
IP address: 192.168.137.1
Subnet: 255.255.255.0
Router:
Set to Wireless router Mode.
Static IP address for WAN port in Router:
IP address: 192.168.137.42
Default Gateway: 192.168.137.1
Subnet: 255.255.255.0
DHCP: enabled from 192.168.1.100 to 192.168.1.224
Port forwarding option: (virtual server) :
192.168.1.100 to 192.168.137.1 (forward internal IP to External IP of router)
Forward port: 5900 to 5900
DMZ: enabled for IP address (192.168.1.100)
PC2 (Laptop):
Static IP address: 192.168.1.100
Subnet: 255.255.255.0
Default Gateway: 192.168.1.1
changed network mode to private. turned on file sharing and network discovery and shared folders.
PC1 can see PC2 using VNC viewer on 192.168.137.42:5900, Done.
PC1 and PC2 both have internet connection, Done.
PC1 (desktop) can't access files/folders on PC2 (laptop
). that's the problem.
Thanks for your help.
It may be easier to get a second Ethernet card for PC1 and hook it to one of your routers switch-ports.
OR
If your routers firmware allows it, you could override the default gateway of DHCP clients to use PC1's IP. That wouldn't require a second NIC.

How does ARP reads destination IP address as its Layer 2 protocol

By searching on internet I got information that Address Resolution Protocol (ARP) is Link Layer (L2) protocol. As per ARP functionality it broadcasts to entire network to check to whom this specific IP belongs to get its MAC address.. but as ARP is L2 protocol, how does it knows destination IP address as IP's are encapsulated in L3 and L2 protocol can't read it
Layer 3 and above are located in the "Payload" part of an ethernet header.
As you can see here the ARP packet also contains IP addresses from its sender and receiver:
ARP packet contain source HW address and src IP address as well as destination HW address and destination IP also .
when ARP resolution happens, means when ARP send request and get response from same destination,ARP update the destination IP in arp_entry .
I would like to elaborate on the previous questions.
first, here it is the case where you can't really apply the model. ARP is sometimes layer 2 and sometimes layer 3 (the similar functionality in IPv6 is done with neighbor discovery protocol, which is carried in ICMP packets)
ARP packets do not carry IP payload. They only carry ARP packets. See other answers for the format
ARP is executed by two end-hosts, which both have to implement both layer 2 and layer 3
ARP is initiated by layer 3, when layer 3 tries to send packet to an IP address on the local network.
ARP is processed by a host, which implements both layer 2 and layer 3. A host without layer 3 cannot have an IP address.
Intermediate layer 2 systems generally cannot process ARP requests, past forwarding ethernet packets with broadcast destination MAC

hop to hop communication

If we are in the same network, then hop to hop communication takes place by layer-2 devices such as switches, bridges, etc. that work at the MAC layer.
But if we have to send packets to a destination in some other network then hop to hop communication takes place through routers.
Is this correct?
Your statements are conceptually correct, though the details are not quite right.
A layer 3 protocol like IP can route a packet from its source to its destination across the entire Internet, but a layer 2 protocol like ethernet can only route packets for a single hop. When a device transmits a packet on a TCP/IP network, it must know the ethernet (layer 2) address of the next hop and the IP (layer 3) address of the packet's final destination.
Let's look at the two cases you describe, using a scenario where a user on Device A knows the IP address of Device B and wants to send it a packet.
Devices on the same (unswitched) subnet
The user on Device A issues the command ping 10.1.1.23.
Device A broadcasts an ARP (layer 2) request, asking which device on its network can route a packet to IP address 10.1.1.23.
Device B recognizes the IP address as its own and answers the request by returning a packet with its IP and ethernet addresses as the source, and Device A's IP and ethernet addresses as the destination.
Now Device A has everything it needs to communicate with Device B. Every packet it transmits to Device B will have the proper ethernet and IP addresses as the destination.
Devices on the same (switched) subnet
The user on Device A issues the command ping 10.1.1.23.
Device A broadcasts an ARP (layer 2) request, asking which device on its network can route a packet to IP address 10.1.1.23.
A switch receives the packet on one of its ports and retransmits the same packet on whichever port is connected to Device B. This is the only significant difference between switched and unswitched subnets.
Device B recognizes the IP address as its own and answers the request by returning a packet with its IP and ethernet addresses as the source, and Device A's IP and ethernet addresses as the destination.
Now Device A has everything it needs to communicate with Device B. Every packet it transmits to Device B will have the proper ethernet and IP addresses as the destination.
Devices on different subnets
The user on Device A issues the command ping 8.8.8.8.
Device A broadcasts an ARP (layer 2) request, asking which device on its network can route a packet to IP address 8.8.8.8.
The address 8.8.8.8 is on a different network, so no local device recognizes the address as its own. However, a router sees the packet, checks its routing tables, and sees that it knows how to forward packets to the 8.8.8.x network. So the router replies by returning a packet that has its own ethernet address as the source.
Now Device A can communicate with Device B by sending packets that have a destination IP address of 8.8.8.8, but the router's ethernet address as their destination.
The router receives the packets because they are destined for its ethernet (layer 2) address, but it notices that their destination IP (layer 3) addresses are different from its own, and so it forwards them to whatever address is stored in its routing table.
Yes, you are correct. To access other networks (networks on a different subnet) a client will route the traffic to its default gateway, which will encapsulate the traffic and route appropriately. For communicating on the same network only a layer 2 switch is required.

Resources