Hi,
I am Sachin Verma.I am currently working on inter process communication in
vxWorks(RTOS)that is having TCP/IP stack and supports all the BSD calls.In
my project I need to preserve message boundaries of messages to be
transported on TCP.I have read the rfc 2126 in which TPKT header and all is
explained to convert stream based to packet based. As per rfc before sending
the message on TCP I attached 4 bytes in the starting of message as first
byte =3 (version),second byte =0,and third ,fourth byte containing the
length of the message plus header length(i.e 4)..
So by attaching the header what I am assuming is that TCP will internally
recognize this packet(stream with header) and if internally it breaks the
packet (If packet length exceeds 1.5k )it should attach header itself on
broken packets ..so that on recieving side I will read the packet length
from the header and will read that much bytes.
e.g
If my actual data to be sent is (pointer to the buffer) 'pData' and
'dataLen' is the length of the data
what I do before sending side I create new buffer
char* pBuf;
pBuf=malloc(dataLen+4);
*((char*)(pBuf+0))=0x03; /*first byte*/
*((char*)(pBuf+1))=0x00; /*second byte*/
*((int*)(pBuf+2))=dataLen+4;
for(i=0;i<dataLen;i++)
{
*((char*)(pBuf+4+i))=*((char*)(pData+i));/*copying the actual data
} after filling the header*/
So like wise that header is attached .
the I send using send call
send(sockId,pBuf,dataLen+4);
So now if dataLen=2k I send it like above procedure
on receiving side as TCP breaks it into packets
first packet I got with header having msg length=2k+4
that is what I sent.but on reading second packet's header
it comes out to be garbled value with first byte 72 second byte 10
and dataLen 27754..
So what I require is that if TCP breaks the packet it should attach header
with them itself ..Is it possible so that I can read the packet
like first as 1.5k and then as .5k .
I have tried it with nagle algorith enabled and disabled.But with nagle
algo disabled I got a new problem that I can't allocate memory (malloc)on
receiving side for receive buffer.Could u plz send me ur suggestions that if
something is prerequisite for using TP0 service(TPKT)..or IF I have not
understood it right..
Thanking u in anticipation..
Wating eagerly for ur reply
Regards,
Sachin Verma
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Message Posted at:
http://www.groupstudy.com/form/read.php?f=7&i=14147&t=14147
--------------------------------------------------
FAQ, list archives, and subscription info: http://www.groupstudy.com/list/cisco.html
Report misconduct and Nondisclosure violations to [EMAIL PROTECTED]