Assuming there is no ARP cache in any nodes, and switch table is empty and IP addresses of source and destination are known (using DNS). Also all nodes are considered to be in same subnet. If n1 wants to send a packet to particular node say n2, it requires MAC address of n2.
I think in this case an ARP request will be send to get the corresponding MAC address. But my friend said that n1, will broadcast the main frame, and all nodes will extract the frame till network layer to know if the packet was for them or not.
Whether first method is implemented of the second will change the way table in switch is updated. So, can someone clarify my confusion?
The way it happens is that a host needing to resolve the layer-3 address to a layer-2 address will broadcast an ARP request. The host with that layer-3 address will respond with a unicast ARP reply to the requesting host.
A switch will see the layer-2 source address of any frame entering the switch, and it will build its MAC address table with the source MAC address and the interface where the frame entered the switch. Any unicast frame with a destination address which isn't in the MAC address table will be flooded to all other switch interfaces.
In the case you discuss, the first host will broadcast an ARP request, so the ARP request will go to all the hosts on the same VLAN. At the same time, the switch will add the MAC address of the requesting host to its MAC address table.
The target host will respond with a unicast frame to the requesting host. The switch, knowing on which interface the destination host is, by looking in its MAC address table, will send the frame directly to the destination host. It will also see the source address of the second host, and it will add that MAC address and interface to its MAC address table.
Then the original host can send its frames to the destination host, using the destination MAC address, and the switch will switch the frames directly to the destination host because it has the MAC address and interface in its MAC address table.