LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why is there no function for packet reception in linux loopback network interface ? (https://www.linuxquestions.org/questions/linux-newbie-8/why-is-there-no-function-for-packet-reception-in-linux-loopback-network-interface-899326/)

avee137 08-25-2011 02:37 AM

Why is there no function for packet reception in linux loopback network interface ?
 
Normally any network driver should provide a function or should implement an interrupt for the packet reception however /drivers/net/loopback.c which is the source code for linux network loopback interface does not contain any mechanism to implement packet reception.

How does it function without an exclusive reception mechanism?

smallpond 08-26-2011 01:16 PM

Quote:

Originally Posted by avee137 (Post 4452849)
Normally any network driver should provide a function or should implement an interrupt for the packet reception however /drivers/net/loopback.c which is the source code for linux network loopback interface does not contain any mechanism to implement packet reception.

How does it function without an exclusive reception mechanism?

Where would it be receiving from? The loopback driver does not have any associated hardware; send and receive are the same thing.

avee137 08-26-2011 11:37 PM

Even though it does not have any h/w ,It sends packets to itself and that has to be received and sent up the protocol stack to the application layer. When we use ping we get reply as below:
Code:

avi@linux-inng:~/cscope> ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.031 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.051 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.049 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.047 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.049 ms
64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=14 ttl=64 time=0.039 ms
^C
--- 127.0.0.1 ping statistics ---
14 packets transmitted, 14 received, 0% packet loss, time 13000ms
rtt min/avg/max/mdev = 0.031/0.044/0.051/0.006 ms


avee137 08-26-2011 11:39 PM

Even though it does not have any h/w ,It sends packets to itself and that has to be received and sent up the protocol stack to the application layer. When we use ping we get reply as below:
Code:

avi@linux-inng:~/cscope> ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.043 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.039 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.031 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.051 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.049 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=64 time=0.047 ms
64 bytes from 127.0.0.1: icmp_seq=10 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=11 ttl=64 time=0.038 ms
64 bytes from 127.0.0.1: icmp_seq=12 ttl=64 time=0.049 ms
64 bytes from 127.0.0.1: icmp_seq=13 ttl=64 time=0.048 ms
64 bytes from 127.0.0.1: icmp_seq=14 ttl=64 time=0.039 ms
^C
--- 127.0.0.1 ping statistics ---
14 packets transmitted, 14 received, 0% packet loss, time 13000ms
rtt min/avg/max/mdev = 0.031/0.044/0.051/0.006 ms

it clearly shows 14 packets transmitted, 14 received.

so there must be some exclusive mechanism at work. Which does not appear anywhere in cource code loopback.c .


All times are GMT -5. The time now is 10:04 PM.