?: Sending packets, what byte gets sent first?

uCsDNerd

Senior member
Mar 3, 2001
338
0
0
Hello All,
I'm trying to figure out what byte gets sent first when you send a packet over the internet, and haven't had much luck with google searches (wrong search phrases I guess). So hopefully you all can help me out.

My question is, when sending a packet of data over the LAN or WAN, what determines which byte gets sent first? Is it the OS? NIC driver? web browser? or something else?

Thanks for your help
 

eigen

Diamond Member
Nov 19, 2003
4,000
1
0
It is the network interface.Lan it would be eth0 and on WLAN it would be the wireless card.Remember that it is the physical link layer that encompasses all the other protocols.
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
A packet is built by the OS. This packet has differnet layers or "wrappers" that contain:
Who to send it to on the local area network (mac addresses)
Who to send it to on the wide area network (internet)
What application to send it to (tcp port numbers, like http = 80
Application data (get web page)

The first byte to get sent on eternet is the most signficant byte of the destination mac address (heavy hitters, lets forget about the pre-amble for now)

So what byte get sent first? The lower level information (layer 2) of the packet.

-edit- os, nic, all that has nothing to do with what byte is sent first. Its all the same regardless of any of that - that way you can talk to anything no matter what OS, nic, etc is being used.

And that my friend is the true beauty of a network.
 

uCsDNerd

Senior member
Mar 3, 2001
338
0
0
What I mean by 'what byte gets sent first':

Say you have struct:
struct Pkt {
char x,y,z;
int T1,T2,T3,T4;
int ARRAY[100]
}

Then I give some command: send(Pkt, IPaddr) which will send my packet to the given IP address. I'm sure that this struct is too large to send as one packet over the internet. Instead it'll be broken down into several pieces and reassembled later at the destination.

My question is, what piece of this struct will get sent out in the first piece?

Thanks again!
 

uCsDNerd

Senior member
Mar 3, 2001
338
0
0
Thanks spidey,

So from my struct example above, the byte of information located at the higher memory address would be the first to go out?

 

AFB

Lifer
Jan 10, 2004
10,718
3
0
I think it defined by the presentation layer(L6?) protocol in use.
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
packets are constructed internally from the top down the OSI model. They HAVE to be constructed this way because in each layer there is a lenght field...kinda hard to have a byte length calculated on something that you don't have yet.

Layer 7 data is constructed, tcp wrapper...well wrapped, ip layer...wrapped around packet, MAC layer wrapped around packet....

put it on the wire.

receiving host does the opposite - remove mac layer, remove ip layer, remove tcp layer, pass goodie, goodie packet contents to application.

<---bows.
 

ScottMac

Moderator<br>Networking<br>Elite member
Mar 19, 2001
5,471
2
0
AT LAST! Here I am to complicate things.....:D

It will be necessary to be more specific. So far, the assumption has been Ethernet (probably a good assumption, but ... )

For example, Token-Ring addresses are "backward" compared to Ethernet: not in terms of Source and Destination, but which bits of which bytes (look up "canonical address" and compare it to "non-canonical address" - Ethernet is canonical, Token-Ring is non-canonical).

If you are actually writing code in some flavor of C, then the existing libraries will handle the handoff to the layer(s) below, and the NIC hardware and drivers will handle the lowest level conversons from whatever framing (Ethernet, Token-Ring, HDLC, SDLC, etc) into the appropriate signaling (not always baseband pulses) on the physical medium (copper, fiber, radio waves(RF), Smoke Signals, Carrier Pigeons, whatever).

How you pass the data will depend on what level / layer you are writing to and/or from.

Packets = Layer 3, Frames = Layer 2, Bits = Layer 1 ...

Were you just curious or did you have a specific application in mind? ( or are you asking the forum to do your homework for you ?)

FWIW

Scott
 

uCsDNerd

Senior member
Mar 3, 2001
338
0
0
No this isn't part of my homework (at least not school homework). I took my networks class 2 years ago, and going over the notes now, they never mentioned the ordering.

My PM (an Electrical Engineer that's never programmed a day in his life) at work has a crazy idea of rewriting bits at the physical layer before a packet goes out. For some reason, he believes you need to know the order in which the bits of a packet get sent out so that you can: 1) count the bits that get sent out, then 2) when the bits that you're interested in are about to get sent out, WRITE over them.

So... here's the new question... Is ^THIS^ even correct thinking on how to go about doing this?
 

ScottMac

Moderator<br>Networking<br>Elite member
Mar 19, 2001
5,471
2
0
No big deal.

For Ethernet, the LSb of the LSB is put to the media first (ref: NAI Advanced Network Analysis documentation).

Regarding your PM's idea: I don't think you can. Most NICs are LSI and don't provide the low-level control of the bit stream.

You may be able to do something with a microcontroller (~Blackfin, Zilog EZ80 Acclaim! ... ) some (like the Acclaim!) have an Ethernet MAC burned into the chip, you just have to add the transceiver/ filter and some programming (they already have libraries available on their site).

Good Luck

Scott