From: Karan on
Hey,

I am trying to make a simple simulink model for testing purpose and if it works then use it in a project. I need to send data to remote machine but on the same gateway (192.168.1.1, I am using a router). I tried to send data on the same machine say 192.168.1.101:30000 and receive on the same machine with the same port and ip, it works fine.

But when I try sending data to 30000 and go to other machine with ip 192.168.1.102 and in TCP/IP receive block I set receive data from 192.168.1.101:30000, it gives me an ERROR. :S

So is it possible to send data to remote machine? (UDP or TCP/IP, doesn't matter !)

Note: My simulation was running the whole time... (it was set on inf). I tried first running it on the one comp and then run it on the comp that receives it but no luck.

Please help ! ! !:) :)
Thank you !
From: Walter Roberson on
Karan wrote:

> But when I try sending data to 30000 and go to other machine with ip
> 192.168.1.102 and in TCP/IP receive block I set receive data from
> 192.168.1.101:30000, it gives me an ERROR. :S

Matlab cannot act as a TCP server -- that is, it cannot be the
destination that a TCP connection is initiated to.

> So is it possible to send data to remote machine? (UDP or TCP/IP,
> doesn't matter !)

You have to use UDP and you have to specifically bind the local port so
that the other machine knows the right place to send to.
From: Karan on
Walter Roberson <roberson(a)hushmail.com> wrote in message <m7BSn.39325$7d5.23122(a)newsfe17.iad>...
> Karan wrote:
>
> > But when I try sending data to 30000 and go to other machine with ip
> > 192.168.1.102 and in TCP/IP receive block I set receive data from
> > 192.168.1.101:30000, it gives me an ERROR. :S
>
> Matlab cannot act as a TCP server -- that is, it cannot be the
> destination that a TCP connection is initiated to.
>
> > So is it possible to send data to remote machine? (UDP or TCP/IP,
> > doesn't matter !)
>
> You have to use UDP and you have to specifically bind the local port so
> that the other machine knows the right place to send to.

Thank you for the quick reply. :)

Can you guide on how to bind the specific local port ?

Once the local port is set, I should enter IP address of the machine I want to send:192.168.1.102, UDP port and local port in send block and then in the receive block same info., am I correct?

Thank you ! :)
From: Karan on
"Karan " <karan7789(a)gmail.com> wrote in message <hvg9d5$b4f$1(a)fred.mathworks.com>...
> Walter Roberson <roberson(a)hushmail.com> wrote in message <m7BSn.39325$7d5.23122(a)newsfe17.iad>...
> > Karan wrote:
> >
> > > But when I try sending data to 30000 and go to other machine with ip
> > > 192.168.1.102 and in TCP/IP receive block I set receive data from
> > > 192.168.1.101:30000, it gives me an ERROR. :S
> >
> > Matlab cannot act as a TCP server -- that is, it cannot be the
> > destination that a TCP connection is initiated to.
> >
> > > So is it possible to send data to remote machine? (UDP or TCP/IP,
> > > doesn't matter !)
> >
> > You have to use UDP and you have to specifically bind the local port so
> > that the other machine knows the right place to send to.
>
> Thank you for the quick reply. :)
>
> Can you guide on how to bind the specific local port ?
>
> Once the local port is set, I should enter IP address of the machine I want to send:192.168.1.102, UDP port and local port in send block and then in the receive block same info., am I correct?
>
> Thank you ! :)

Hey..
I figured it out how to do it...but thanks for guiding me right direction.

For anyone else....
Following instruction will help you:
1) UDP Send Block
Example:
IP:192.168.1.102 (IP of the remote machine you want to send the data to - Host IP)
Port:35353
Local port:4444 (It is very important to define local port, Thanks to Walter ...why see above posts)

2)UDP Receive Block
IP:192.168.1.101 (IP of the machine you are going to receive data from - Server IP)
Port: 4444 (Same as local port of Server....NO IDEA WHY)
Local port: 35353 (Same as port of Server...NO IDEA WHY Again )

Make sure ports are available, do the port verification !
Done, Run the sumulation and waallahh !!
From: Walter Roberson on
Karan wrote:

> For anyone else....
> Following instruction will help you:
> 1) UDP Send Block
> Example:
> IP:192.168.1.102 (IP of the remote machine you want to send the data to
> - Host IP)
> Port:35353
> Local port:4444 (It is very important to define local port, Thanks to
> Walter ...why see above posts)
>
> 2)UDP Receive Block
> IP:192.168.1.101 (IP of the machine you are going to receive data from -
> Server IP)
> Port: 4444 (Same as local port of Server....NO IDEA WHY)
> Local port: 35353 (Same as port of Server...NO IDEA WHY Again )

Think of it like mailing letters to each other; when you send out a letter
then you have to put the address of the other person in the destination area,
and you have to put your own address in the return address area; when the
other person gets your letter, they address their reply by reading your
address out of the return area and writing that in as the destination for the
letter, and they put in their address in the return address of the outgoing
message.

It is true that the IP address contains some of this kind of information, but
think of an IP address as giving the address of an apartment building: you
need to know the room number as well in order to get to the right location.