There are 5 messages in this thread.
You are currently looking at messages 1 to 5.
So far in May, you have voted 0 times ou of a total of 20 votes by the community.
Please help us clean the archives from unuseful discussion threads by using the voting system! Details here.
Hi everybody. Im currently developing a code to control a device using Uip
Micro IP stack. The control protocol is UDP. Everything was going smooth,
but Im kinda stuck with UDP initializations.
The problem occured because of ports. The connection is like this;
Device: Host: (Me)
Port for Incom. Pack. fixed and 55720 Port for Inco. Pack. fixed and
55750
Port for Outg. Pack. is Variable Port for Out. Pack. doesnt matter
Devices Outgoing(Source) port is variable, and cant be fixed to constant.
The case is;
It sends me a packet, so I can parse Devices Source Port Number from
Incoming packet, but I cant parse the packet. Its because IP stack compares
incoming packets source port with uip_udp_conn->rport. Its in uip.c line
1112.
At the beginning before I parse the packet, I wont be able to know which
remote port to connect, so I tried to reinitialize udp_connection in the
main loop. But it didnt work. I got no errors, but just dont initialize
uip_udp_new in the main loop.
/***************** uip.c Line 1112 *************************/
if(uip_udp_conn->lport != 0 &&
UDPBUF->destport == uip_udp_conn->lport &&
(uip_udp_conn->rport == 0 ||
/* This is what im sayin */ UDPBUF->srcport == uip_udp_conn->rport) &&
(uip_ipaddr_cmp(uip_udp_conn->ripaddr, all_zeroes_addr)
||
uip_ipaddr_cmp(uip_udp_conn->ripaddr,
all_ones_addr) ||
uip_ipaddr_cmp(BUF->srcipaddr,
uip_udp_conn->ripaddr))) {
goto udp_found;
}
/*************************************************/
Any helps will be greatly appreciated. Thank you all...
---------------------------------------
Posted through http://www.EmbeddedRelated.com
In article <A...@giganews.com>, 29607 @embeddedrelated says... > Hi everybody. Im currently developing a code to control a device using Uip > Micro IP stack. The control protocol is UDP. Everything was going smooth, > but Im kinda stuck with UDP initializations. > > The problem occured because of ports. The connection is like this; > > Device: Host: (Me) > Port for Incom. Pack. fixed and 55720 Port for Inco. Pack. fixed and > 55750 > Port for Outg. Pack. is Variable Port for Out. Pack. doesnt matter > > > Devices Outgoing(Source) port is variable, and cant be fixed to constant. > > The case is; > > It sends me a packet, so I can parse Devices Source Port Number from > Incoming packet, but I cant parse the packet. Its because IP stack compares > incoming packets source port with uip_udp_conn->rport. Its in uip.c line > 1112. > > At the beginning before I parse the packet, I wont be able to know which > remote port to connect, so I tried to reinitialize udp_connection in the > main loop. But it didnt work. I got no errors, but just dont initialize > uip_udp_new in the main loop. > Maybe I'm missing something, but if your outgoing port is variable, then you can't guarantee that it will connect to your fixed incoming port number. Or am I confusing the Source port and Destination port designations? Can't you set the Source port and Destination port? Or is there a way to set the stack to ignore the source port? I thought it was an optional parameter anyway. With UDP you are really making a connection so much as consuming the datagram when/if it arrives.
>/*************************************************/>Maybe I'm missing something, but if your outgoing port is variable, then>you can't guarantee that it will connect to your fixed incoming port>number. Or am I confusing the Source port and Destination port>designations? Can't you set the Source port and Destination port? Or>is there a way to set the stack to ignore the source port? I thought it>was an optional parameter anyway.>With UDP you are really making a connection so much as consuming the>datagram when/if it arrives.>/*************************************************/ Thank you for your response. The certain thing is, device sents packets to my local port of 55750(devices destination port)and, I have to sent my packets to devices local port of 55720 (my destination port) Only destination ports are fixed while communiting, to be clear. My source port while sending packets doesnt matter. But somehow devices source port does matter cause UIP compares uip_udp_conn->rport with incoming packets source port. So Im thinking some better way to do this. Anyway I changed uip.c just a little for now, which i didnt want to do. Still, Im open for new ideas. Thank you... --------------------------------------- Posted through http://www.EmbeddedRelated.com
On Fri, 03 Aug 2012 12:27:00 -0500, fkaya13 wrote: >>/*************************************************/>Maybe I'm missing > something, but if your outgoing port is variable, then>you can't > guarantee that it will connect to your fixed incoming port>number. Or am > I confusing the Source port and Destination port>designations? Can't you > set the Source port and Destination port? Or>is there a way to set the > stack to ignore the source port? I thought it>was an optional parameter > anyway.>With UDP you are really making a connection so much as consuming > the>datagram when/if it > arrives.>/*************************************************/ Thank you > for your response. > The certain thing is, > device sents packets to my local port of 55750(devices destination > port)and, > > I have to sent my packets to devices local port of 55720 (my > destination > port) > > Only destination ports are fixed while communiting, to be clear. > > > My source port while sending packets doesnt matter. But somehow > devices > > source port does matter cause UIP compares uip_udp_conn->rport with > incoming > > packets source port. So Im thinking some better way to do this. Anyway > I > > changed uip.c just a little for now, which i didnt want to do. Still, Im > open > > for new ideas. Thank you... > > > --------------------------------------- Posted through > http://www.EmbeddedRelated.com Look in the documentation. All you have to do is this: struct uip_udp_*conn = uip_udp_new(NULL,0); if(conn != NULL) { uip_udp_bind(conn, HTONS(your_device_local_port_number)); } Since the remote IP is NULL and remote port is 0 look in the uip UDP demux code and you will see that it will accept the packet where the receive dest port is "your_device_local_port_number) HOWEVER - the native uip code will not keep track of the receive packet ip/source port so your app callback will have to pull that out of the datagram or you will need to patch uip. This is the only way you can flip them and send a packet back to the PC in the manner you want. -- Chisolm Republic of Texas
>> --------------------------------------- Posted through >> http://www.EmbeddedRelated.com > >Look in the documentation. All you have to do is this: >struct uip_udp_*conn = uip_udp_new(NULL,0); > if(conn != NULL) { > uip_udp_bind(conn, HTONS(your_device_local_port_number)); > } > >Since the remote IP is NULL and remote port is 0 look in the uip >UDP demux code and you will see that it will accept the packet where >the receive dest port is "your_device_local_port_number) > >HOWEVER - the native uip code will not keep track of the >receive packet ip/source port so your app callback will have to >pull that out of the datagram or you will need to patch uip. >This is the only way you can flip them and send a packet back to >the PC in the manner you want. > >-- >Chisolm >Republic of Texas /***********************************************************/ Thank you Chisolm. Remote IP is never NULL, just incoming packets source port is changing. I could manage it for now, I just added one more OR the the demux. Im sure I will figure it out soon. Thank you... --------------------------------------- Posted through http://www.EmbeddedRelated.com