Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,267 Programmers. There are 1,886 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Down and Dirty With Network Cards

2 Pages V  1 2 >  
Reply to this topicStart new topic

Down and Dirty With Network Cards, What actually goes on?

scalt
post 12 Dec, 2007 - 07:12 PM
Post #1


D.I.C Head

**
Joined: 22 Nov, 2007
Posts: 60



Hi

Something I have been wondering about, but am not able to find an answer to, is what goes on at the PC end of a local network. What exactly happens when a packet comes into the network card of a PC? What part decides where the information goes and how does the network card filter out un-wanted packets? I have tried searching the 'net, but all I seem to turn up is a lot of information about how 'networks' work. The only specific information I find about the PC end is that 'it' decides what happens to the information ('it' as in the PC - most helpful...). I'm after a relatively detailed answer here if possible.

Thanks
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


LeprechauN
post 12 Dec, 2007 - 07:17 PM
Post #2


D.I.C Addict

Group Icon
Joined: 12 Mar, 2001
Posts: 857

http://en.wikipedia.org/wiki/Internet_protocol_suite

google
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

scalt
post 12 Dec, 2007 - 08:22 PM
Post #3


D.I.C Head

**
Joined: 22 Nov, 2007
Posts: 60

QUOTE(LeprechauN @ 12 Dec, 2007 - 07:17 PM) *


Thanks, but that isn't really what I am looking for. I found plenty of information like that also using Google, but I am more interested in the very basic level of one end of the connection that deals with incoming data and gives it to the appropriate processes, not the connection itself. I'm guessing that this is well below OS level but I'm not 100% sure.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Dark_Nexus
post 12 Dec, 2007 - 08:31 PM
Post #4


or something bad...real bad.

Group Icon
Joined: 2 May, 2004
Posts: 1,302

the processes themselves are controlled in user space by the operating system. the os itself will handle routing packets internally and can be controlled by user processes on behalf of the os through the use of shared libraries. a process can attach or subscribe to a particular socket and/or port and the os will forward data it receives on that port to that process. the way it identifies incoming traffic with destined processes is probably through a mix of protocol and port.

EDIT: this is still pretty basic i guess, i'm not sure how detailed you want to get.

This post has been edited by Dark_Nexus: 12 Dec, 2007 - 08:34 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

scalt
post 12 Dec, 2007 - 08:39 PM
Post #5


D.I.C Head

**
Joined: 22 Nov, 2007
Posts: 60

That's more what I was looking for. Would you know what happens when a packet turns up addressed to that computer, but is completely un-expected? I'm guessing that the OS will simply ignore it, or, if it is on a port assigned to a process, that process will deal with it it's own way.

EDIT: If you know more about exactly how the network card knows what to do with the information (ie what sort commands are issued from where in the system, is the packet simply dumped into a location in memory for something else to deal with) then some info on that would be great.

This post has been edited by scalt: 12 Dec, 2007 - 08:45 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Dark_Nexus
post 12 Dec, 2007 - 08:43 PM
Post #6


or something bad...real bad.

Group Icon
Joined: 2 May, 2004
Posts: 1,302

not all packets are to be expected, so if the port is open and being listened to by a process, the os would probably forward it to that process. of course there are things like ip tables and firewall rules that can give the os a better idea of what to do. in most cases, if the computer received something it wasn't expecting and the port it was destined to wasn't open, it would either silently drop the packet or respond with an error of some sort.

EDIT: i don't really know how it gets handled on a really low hardware level. i don't think the network card actually knows what's going on at data or application level, all it really cares about is transporting packets too and from the computer. the os and network card can speak to each other via the network card driver which offers a library to the os to configure the card to be in certain states as well as retrieve information from the card like incoming connections. anything past this level you'd probably have to look up.

This post has been edited by Dark_Nexus: 12 Dec, 2007 - 08:48 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

scalt
post 12 Dec, 2007 - 08:53 PM
Post #7


D.I.C Head

**
Joined: 22 Nov, 2007
Posts: 60

Ok, thanks for your help, you've given me a better idea of what actually goes on in there. I'll keep poking around and see what I can find out.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

born2c0de
post 12 Dec, 2007 - 10:42 PM
Post #8


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,298

I used to use a Packet Sniffer to understand how it all worked.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Programmist
post 13 Dec, 2007 - 12:30 PM
Post #9


Four-letter word

Group Icon
Joined: 2 Jan, 2006
Posts: 954

From the protocol perspective (TCP/IP) there are several points of discrimination.

At the data link level, when a NIC receives a frame from the network, it checks the CRC to see if the frame was corrupted. Often if there is corruption the frame is discarded rather than trying to flip bits. If not corruption is detected then the data link layer checks the MAC address. This will be different for differing technologies (Ethernet, FDDI, etc). If it is addressed to this node, it gets passed up to the next layer (Typically Network layer), otherwise discarded.


At the Network layer, in this case IP, the destination network address (IP address) is checked. If it matches this node, the packet is kept. Otherwise it's routed elsewhere. The IP packet header contains a protocol field that is used as a demux key that routes the packet to the proper protocol at the next layer (TCP, UDP, etc).

The Transport layer uses source and dest port numbers to demux the message to the proper application. The port number combined with the address is what is known as a socket and is the API typically used for network programming. I'm guessing you already know that part though.

Is this detailed enough, or do you want more detail?

EDIT I forgot to mention that some of the other layers do their own error checking as well. The higher layers usually do a checksum rather than CRC though.

This post has been edited by Programmist: 13 Dec, 2007 - 12:35 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

scalt
post 13 Dec, 2007 - 02:44 PM
Post #10


D.I.C Head

**
Joined: 22 Nov, 2007
Posts: 60

Thanks Programmist. I already had some knowledge of how that side of it worked, but it was pretty basic. One of my lecturers had tried to explain what you talked about but I never really got it 'til now.

I think that what I originally was after sort of lies more in the network card driver field if you know any more about that.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Programmist
post 13 Dec, 2007 - 07:57 PM
Post #11


Four-letter word

Group Icon
Joined: 2 Jan, 2006
Posts: 954

QUOTE(scalt @ 13 Dec, 2007 - 03:44 PM) *

Thanks Programmist. I already had some knowledge of how that side of it worked, but it was pretty basic. One of my lecturers had tried to explain what you talked about but I never really got it 'til now.

I think that what I originally was after sort of lies more in the network card driver field if you know any more about that.

NIC drivers - not my area. They probably vary from card to card and manufacturer to manufacturer as well.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

scalt
post 13 Dec, 2007 - 08:06 PM
Post #12


D.I.C Head

**
Joined: 22 Nov, 2007
Posts: 60

Yep I would imagine they do. When I get home tonight I'll have a look around the web for a few examples
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 10:27AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month