Vikram Shenoy writes:
> I am trying to set IP TOS byte when sending packet in sendmsg() in a TCP 
> socket opened with 3XNET ( -lxnet)  library. 

I don't think I understand that question in a TCP environment.  When
you call "sendmsg" on a TCP socket, you're not sending a packet.
You're just offering TCP a set of bytes to transmit.

TCP is a byte-stream protocol.  That means that record markers
(groupings of bytes presented to a system call by an application) have
no significance, and are not maintained end-to-end.

The bytes you send in one "message" may well be thrown into a buffer
with bytes from other "messages," and all sent in a single TCP segment
(as an IP packet).  Or they may be broken up arbitrarily into multiple
segments.

> I was able set the TOS byte using setsockopt(s, IPPROTO_IP, IP_TOS, &tos, 
> sizeof(tos)). But this meant all the packets bear the same TOS byte. I tried 
> setting values in the msghdr.msg_control, it did not let me do it. I do not 
> want to use the raw socket; I want to stay with TCP socket.  What would be 
> the mechanism for setting TOS bits on a per packet basis on a socket? 

On a non-TCP socket, I'd like to see it handled by ancillary data, but
I don't think it is.  (IPv6 does seem to do this for IPV6_TCLASS ... I
don't know why it'd be there for one protocol, and not another.)

On a TCP socket, we don't have a way to do anything on a per-packet
basis.  The sockets API doesn't normally provide a way for TCP users
to specify anything at all about packets.

> Also I need to find out how to receive the TOS bits along with the packet 
> data received in a  recvmsg(). 

Similar issues exist there.  When you receive a "message" from TCP, it
may well be composed of data from multiple segments on the wire, and
may include a fragment of one or two segments.  You can't receive
individual packets using the sockets API, because TCP is a byte-stream
protocol.

It should be possible to receive the TOS value for non-TCP sockets,
but see CR 6444107.  We don't have that feature yet.

-- 
James Carlson, Solaris Networking              <[EMAIL PROTECTED]>
Sun Microsystems / 35 Network Drive        71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to