Help on sending a UDP Packet

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
18 messages Options
Reply | Threaded
Open this post in threaded view
|

Help on sending a UDP Packet

highbeg
HI everyone,
I just started working on 4 and 5 below. Any suggestions or links to
references would be much appreciated. I know little of Smalltalk, but am
coming up to speed on it. I have many years of C network programming  of
modems, switches & routers. I'll document everything as I go along.

   1. Objective is to send a UDP packet to port 49152 on my other Linux box
   192.168.1.114:49152
      - AF_INET (v4)
      - SOCK_DGRAM (connectionless)
      - IPPROTO_UDP (user datagram protocol)
      - Any egress port and IP address (no bind)
   2. Sockets documentation is not in gnu-smalltalk-doc. It's online at Sockets
   Documentation
   <https://www.gnu.org/software/smalltalk/manual-libs/gst-libs.html#Sockets-package>
   3. Socket support must be added to gnu-smalltalk 3.2.5.  st>
   PackageLoader fileInPackage: 'Sockets' .
   4. Configure socket and send it a message
   5. Observe message on Wireshark and at my other Linux box.


Many thanks everybody,
Gary Highberger
Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

stes

Hi,

I'm using a simple TCP/IP and UDP service called 'daytime' here.

This is a very old service, that is useful for small tests.

Traditionally this is a "inetd" service.

On my system, it is available as an inetd service.

Note that some Linux distributions do not install that service by default,
so you may have to check the Ubuntu packages or manpages.

I see that Ubuntu has an xinetd package, check or search for
/etc/xinetd.d/daytime xinetd in Ubuntu

Anyway assuming that you have a daytime UDP (dgram) and TCP (stream) running.

For the TCP case the following works for me:

PackageLoader fileInPackage: 'Sockets'.

s _ Sockets.Socket remote:(Sockets.SocketAddress createLoopbackHost) port:13.
(s upTo: Character cr) printNl.
s close.

$ gst daytime-stream.st
"Global garbage collection... done"
Loading package Sockets
'Thu Jan  7 16:13:44 2021'
$ svcs -a daytime:stream
STATE          STIME    FMRI
online         15:42:59 svc:/network/daytime:stream

Now for the UDP case (datagram) it is more complicated.

The following kind-a-works for me:

$ cat daytime-dgram.st
PackageLoader fileInPackage: 'Sockets'.

h _ Sockets.SocketAddress createLoopbackHost.
s _ Sockets.DatagramSocket new.
d _ Sockets.Datagram data:#'hello world' address:h port:13.
answer _ Sockets.Datagram new.
s nextPut:d.
s receive:answer.
(answer data) asString printNl.
s close.

$ gst daytime-dgram.st
"Global garbage collection... done"
Loading package Sockets
'Thu Jan  7 16:16:32 2021
'
$ svcs daytime:dgram
STATE          STIME    FMRI
online         15:42:56 svc:/network/daytime:dgram

The TCP (stream) code is neater because it uses the upTo: Character cr,
which eats the newline.

So that's a little better than in the simple UDP example.

However basically the UDP example works for me.

It sends a garbage datagram #('hello world') which is ignored by the daytime:dgram service.
But this triggers a response which we then receive in a Datagram instance 'answer'.

Regards,
David Stes

----- Op 6 jan 2021 om 21:47 schreef Gary Highberger [hidden email]:

> HI everyone,
> I just started working on 4 and 5 below. Any suggestions or links to
> references would be much appreciated. I know little of Smalltalk, but am
> coming up to speed on it. I have many years of C network programming  of
> modems, switches & routers. I'll document everything as I go along.
>
>   1. Objective is to send a UDP packet to port 49152 on my other Linux box
>   192.168.1.114:49152
>      - AF_INET (v4)
>      - SOCK_DGRAM (connectionless)
>      - IPPROTO_UDP (user datagram protocol)
>      - Any egress port and IP address (no bind)
>   2. Sockets documentation is not in gnu-smalltalk-doc. It's online at Sockets
>   Documentation
>   <https://www.gnu.org/software/smalltalk/manual-libs/gst-libs.html#Sockets-package>
>   3. Socket support must be added to gnu-smalltalk 3.2.5.  st>
>   PackageLoader fileInPackage: 'Sockets' .
>   4. Configure socket and send it a message
>   5. Observe message on Wireshark and at my other Linux box.
>
>
> Many thanks everybody,
> Gary Highberger

Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

highbeg
Good morning David,

I'm not familiar with 'daytime' but will come up to speed on it and get it
and your use cases running and report my findings for everybody to see.

Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
very short and simple.

https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0

I used my cell phone as the destination, my home WiFi as the network, and
tcpdump to see the packet.

Thank you David for the Smalltalk code fragments and introducing me to
inetd and 'daytime'.

Gary Highberger
Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

highbeg
Hello David and all,

I have a few (noob) questions about the UDP example Smalltalk program. More
questions likely to follow as I come up to speed. Your patience is much
appreciated David and everybody.

QUESTIONS:
•  Is "_" the preferred assignment operator? I've been seeing ":=" too. I
don't have a back arrow on my keyboard. I guess the PARC people used "_".

•  Does statement 1)
assign the destination IP address? Note that for my application, the source
and destination addresses will be different.

•  Does statement 3)
populate the (UDP) datagram socket with the message, port, and address? Why
a "#" symbol prefixing the message string, 'hello world'?

•  Does statement 4)
create a listening socket?

•  Does statement 5)
trigger the send?

•  Does statement 6)
block until the UDP response?

+---------------------------------------------------------+

UDP Smalltalk (example) program:

1) h _ Sockets.SocketAddress createLoopbackHost.

2) s _ Sockets.DatagramSocket new.

3) d _ Sockets.Datagram data:#'hello world' address:h port:13.

4) answer _ Sockets.Datagram new.

5) s nextPut:d.

6) s receive:answer.

7) (answer data) asString printNl.

8) s close.

Gary Highberger


On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <[hidden email]>
wrote:

> Good morning David,
>
> I'm not familiar with 'daytime' but will come up to speed on it and get it
> and your use cases running and report my findings for everybody to see.
>
> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
> very short and simple.
>
> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>
> I used my cell phone as the destination, my home WiFi as the network, and
> tcpdump to see the packet.
>
> Thank you David for the Smalltalk code fragments and introducing me to
> inetd and 'daytime'.
>
> Gary Highberger
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

stes

I think some Smalltalk systems (Cuis and possibly others) display _ as the left-arrow.

In "Cuis" http://cuis-smalltalk.org/  this looks like the examples in the Blue Book.

I think the original XEROX Smalltalk systems used those characters, but I've never used them,
but in Cuis the _ prints as left-arrow, very nice.

See https://www.gnu.org/software/smalltalk/manual/html_node/Syntax.html
for a discussion of := and _ in GNU smalltalk.

The Blue Book "Smalltalk-80 language and implementation" writes on page 44

"An assignment prefix is composed of the name of the variable whose
value will be changed followed by a left arrow ()"

The character that is displayed there is the left arrow.

I think perhaps the XEROX Smalltalk also used a up-arrow to return values where GNU smalltalk uses the caret ^.

This begs the question (I don't know the answer) whether with Unicode characters,
GNU smalltalk and fonts for a Linux/Unix terminal could be made to print up-arrow and left-arrow,
for GNU smalltalk ...

Is there a way to do this ?  There are fonts that have those characters, so perhaps somebody managed to do this.

Regarding other issues:

when I wrote 1) this was a quick assignment that was sufficient for me,
because I send and receive UDP packets (datagrams) on the localhost

in your case you'll have to check the classes for appropriate messages but I think they provide a method to create an address object from a dot decimal syntax ipv4 address

2) perhaps this is wrong or unnecessary  the idea was to create an Array instance
#(1 2 3) would have been better perhaps than #'hello world'

anyway for DNS or UDP requests where the Datagram that is sent, does matter, it would be necessary to investigate,
but in my case for the UDP daytime service, it just receives a UDP packet and sends back the daytime in a UDP response,
so the UDP packet that is sent, does not matter

4/3)  no I think statement 2) does that :  DatagramSocket new

5)  the nextPut:datagram puts the datagram (send) and yes, the daytime service will respond to it

6) I think it blocks yes.  I can test this by removing the nextPut: so that no responds is sent,
and the statements block, because no UDP packet comes in

If I control-c then I get the following trace which seems to show the Delay>wait in the Socket

waitUntil:then:onTimeoutDo:  where perhaps the issue of "onTimeoutDo:" block can be seen



^CObject: nil error: interrupted!!!
SystemExceptions.UserInterrupt(Exception)>>signal (ExcHandling.st:254)
SystemExceptions.UserInterrupt class(Exception class)>>signal (ExcHandling.st:151)
UndefinedObject(Object)>>userInterrupt (Object.st:1414)
optimized [] in Delay>>wait (Delay.st:285)
BlockClosure>>ensure: (BlkClosure.st:268)
Delay>>wait (Delay.st:279)
Sockets.DatagramSocket(Sockets.AbstractSocket)>>waitUntil:then:onTimeoutDo: (Sockets.star#VFS.ZipFile/Sockets.st:522)
Sockets.DatagramSocket>>receive: (Sockets.star#VFS.ZipFile/Sockets.st:756)
UndefinedObject>>executeStatements (daytime-dgram.st:7)
Object: nil error: did not understand #asString
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254



Anyway there is a UNIX / Linux utility "netcat" (or nc) which acts very similar:

$ nc localhost 13
Sun Jan 10 20:32:07 2021

$ nc -u localhost 13
123
Sun Jan 10 20:32:16 2021
^C

when using "nc" (netcat) in udp mode -u I have to send something to the service to get a reply.


----- Op 10 jan 2021 om 19:49 schreef Gary Highberger [hidden email]:

> Hello David and all,
>
> I have a few (noob) questions about the UDP example Smalltalk program. More
> questions likely to follow as I come up to speed. Your patience is much
> appreciated David and everybody.
>
> QUESTIONS:
> •  Is "_" the preferred assignment operator? I've been seeing ":=" too. I
> don't have a back arrow on my keyboard. I guess the PARC people used "_".
>
> •  Does statement 1)
> assign the destination IP address? Note that for my application, the source
> and destination addresses will be different.
>
> •  Does statement 3)
> populate the (UDP) datagram socket with the message, port, and address? Why
> a "#" symbol prefixing the message string, 'hello world'?
>
> •  Does statement 4)
> create a listening socket?
>
> •  Does statement 5)
> trigger the send?
>
> •  Does statement 6)
> block until the UDP response?
>
> +---------------------------------------------------------+
>
> UDP Smalltalk (example) program:
>
> 1) h _ Sockets.SocketAddress createLoopbackHost.
>
> 2) s _ Sockets.DatagramSocket new.
>
> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
>
> 4) answer _ Sockets.Datagram new.
>
> 5) s nextPut:d.
>
> 6) s receive:answer.
>
> 7) (answer data) asString printNl.
>
> 8) s close.
>
> Gary Highberger
>
>
> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <[hidden email]>
> wrote:
>
>> Good morning David,
>>
>> I'm not familiar with 'daytime' but will come up to speed on it and get it
>> and your use cases running and report my findings for everybody to see.
>>
>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
>> very short and simple.
>>
>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>>
>> I used my cell phone as the destination, my home WiFi as the network, and
>> tcpdump to see the packet.
>>
>> Thank you David for the Smalltalk code fragments and introducing me to
>> inetd and 'daytime'.
>>
>> Gary Highberger
>>
>>

Reply | Threaded
Open this post in threaded view
|

display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

It's not by the way that I'm sure I'd really like that feature for GNU smalltalk,
if it would exist at all, where a Unicode character would be used for the left-arrow.

The idea of GNU Smalltalk is to use a UNIX command-line style environment,
and use "Emacs" (editor) and so on ... it's not about emulating the more graphically oriented
development environment of older Smalltalk implementations.

So by default it is logical that GNU smalltalk limits itself to strict ASCII characters.

Using '_' is just fine as it currently is :

https://www.gnu.org/software/smalltalk/manual/html_node/Syntax.html

in the footnote it describes '_'.

----- Op 10 jan 2021 om 20:35 schreef stes [hidden email]:

> This begs the question (I don't know the answer) whether with Unicode
> characters,
> GNU smalltalk and fonts for a Linux/Unix terminal could be made to print
> up-arrow and left-arrow,
> for GNU smalltalk ...
>
> Is there a way to do this ?  There are fonts that have those characters, so
> perhaps somebody managed to do this.

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

If I understand the footnote in the GNU Smalltalk syntax on := and _ correctly, no Unicode is required anyway:

The GNU smalltalk manual says:
" In the ancient days (like the middle 70’s), the ASCII underscore character was also printed as a back-arrow, and many terminals would display it that way, thus its current usage. "

So it would be sufficient to find a font that displays _ as back-arrow,
which according to the above would exist for simple ASCII -- without Unicode extensions.

There are footnotes in the wikipedia page on ASCII

https://en.wikipedia.org/wiki/ASCII#cite_note-Haynes_2015-60

that up arrow and left arrow were in use.

It says:
"By 1967 the underscore had spread to ASCII,[5] replacing the similarly-shaped left-arrow character"

----- Op 10 jan 2021 om 20:57 schreef stes [hidden email]:

> It's not by the way that I'm sure I'd really like that feature for GNU
> smalltalk,
> if it would exist at all, where a Unicode character would be used for the
> left-arrow.
>
> The idea of GNU Smalltalk is to use a UNIX command-line style environment,
> and use "Emacs" (editor) and so on ... it's not about emulating the more
> graphically oriented
> development environment of older Smalltalk implementations.
>
> So by default it is logical that GNU smalltalk limits itself to strict ASCII
> characters.
>
> Using '_' is just fine as it currently is :
>
> https://www.gnu.org/software/smalltalk/manual/html_node/Syntax.html
>
> in the footnote it describes '_'.
>
> ----- Op 10 jan 2021 om 20:35 schreef stes [hidden email]:
>
>> This begs the question (I don't know the answer) whether with Unicode
>> characters,
>> GNU smalltalk and fonts for a Linux/Unix terminal could be made to print
>> up-arrow and left-arrow,
>> for GNU smalltalk ...
>>
>> Is there a way to do this ?  There are fonts that have those characters, so
> > perhaps somebody managed to do this.

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

Note that the VIC-20 and C-64 and older Commodore machines indeed displayed it as back-arrow:

https://en.wikipedia.org/wiki/PETSCII

PETSCII has only uppercase letters in its powerup state, an up-arrow ( ↑ ) instead of a caret ( ^ ) in position $5E and a left-arrow ( ← ) instead of an underscore ( _ ) in position $5F, these two variants are common in ASCII-1963.


So basically this comes from the ASCII-1963 usage.


Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Gnu mailing list
In reply to this post by stes

[hidden email] writes:

> If I understand the footnote in the GNU Smalltalk syntax on := and _ correctly, no Unicode is required anyway:
>
> The GNU smalltalk manual says:
> " In the ancient days (like the middle 70’s), the ASCII underscore character was also printed as a back-arrow, and many terminals would display it that way, thus its current usage. "
>
> So it would be sufficient to find a font that displays _ as back-arrow,
> which according to the above would exist for simple ASCII -- without Unicode extensions.
>
> There are footnotes in the wikipedia page on ASCII
>
> https://en.wikipedia.org/wiki/ASCII#cite_note-Haynes_2015-60
>
> that up arrow and left arrow were in use.
>
> It says:
> "By 1967 the underscore had spread to ASCII,[5] replacing the similarly-shaped left-arrow character"
With the newer smalltalk-mode from elpa, and if you enable
prettify-symbols-mode in emacs, you will get the prettified unicode
symbols. Currently there are only two that are defined:

(defvar smalltalk-prettify-symbols-alist
  '(("^" . ?↑)
    (":=" . ?←)))

Please note you cannot use the fancy symbols in source code though;
it is only emacs tricking your eyes at display.

Derek

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

I suspect Cuis is also using the Unicode characters.  I don't know.

But the idea of GNU Smalltalk is totally different, it seems GNU Smalltalk,
is about emacs, UNIX integration, command line etc. while Cuis is much more graphically oriented (I think).

In any case the smalltalk-mode could be enhanced:

> (defvar smalltalk-prettify-symbols-alist
>  '(("^" . ?↑)
>    (":=" . ?←)))

this could be extended to include a line

>    ("_" . ?←)))

so that the underscore is also pretty-printed as the back arrow.

Is there any interest in updating the smalltalk-mode in the GNU smalltalk package to do that ?

David Stes

----- Op 11 jan 2021 om 16:21 schreef help-smalltalk [hidden email]:

> [hidden email] writes:
>
>> If I understand the footnote in the GNU Smalltalk syntax on := and _ correctly,
>> no Unicode is required anyway:
>>
>> The GNU smalltalk manual says:
>> " In the ancient days (like the middle 70’s), the ASCII underscore character was
>> also printed as a back-arrow, and many terminals would display it that way,
>> thus its current usage. "
>>
>> So it would be sufficient to find a font that displays _ as back-arrow,
>> which according to the above would exist for simple ASCII -- without Unicode
>> extensions.
>>
>> There are footnotes in the wikipedia page on ASCII
>>
>> https://en.wikipedia.org/wiki/ASCII#cite_note-Haynes_2015-60
>>
>> that up arrow and left arrow were in use.
>>
>> It says:
>> "By 1967 the underscore had spread to ASCII,[5] replacing the similarly-shaped
>> left-arrow character"
> With the newer smalltalk-mode from elpa, and if you enable
> prettify-symbols-mode in emacs, you will get the prettified unicode
> symbols. Currently there are only two that are defined:
>
> (defvar smalltalk-prettify-symbols-alist
>  '(("^" . ?↑)
>    (":=" . ?←)))
>
> Please note you cannot use the fancy symbols in source code though;
> it is only emacs tricking your eyes at display.
>
> Derek

Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

highbeg
In reply to this post by highbeg
Hi David and everybody,

I just sent my first UDP packet with Smalltalk Sockets. It's likely just me
but there might be some instability in gst. Somehow my Datagram Socket got
wiped out. I'm going to run tests and publish my findings here.

Have GNU Smalltalk Sockets and the VM been proven in real world
applications?

Packet:
$ sudo tcpdump -i 1 -nn -n -A port 49152
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlp3s0, link-type EN10MB (Ethernet), capture size 262144 bytes
10:53:15.131345 IP 192.168.1.114.49153 > 192.168.1.249.49152: UDP, length 27
E..7..@.@..0...r.........#..  Hi sailor! New in town?

Smalltalk:
st> PackageLoader fileInPackage: 'Sockets'
"Global garbage collection... done"
Loading package Sockets
PackageLoader
st> DgS := Sockets.DatagramSocket remote: '192.168.1.249' port: 49152
local: '192.168.1.114' port: 49153
Sockets.DatagramSocket[192.168.1.114:49153]
st> DgD := Sockets.Datagram data: '  Hi sailor! New in town?  '
a Datagram
st> DgS nextPut: DgD
Sockets.DatagramSocket[192.168.1.114:49153]
Voila

Many thanks for the help everybody!

Gary

On Sun, Jan 10, 2021 at 1:49 PM Gary Highberger <[hidden email]>
wrote:

> Hello David and all,
>
> I have a few (noob) questions about the UDP example Smalltalk program.
> More questions likely to follow as I come up to speed. Your patience is
> much appreciated David and everybody.
>
> QUESTIONS:
> •  Is "_" the preferred assignment operator? I've been seeing ":=" too. I
> don't have a back arrow on my keyboard. I guess the PARC people used "_".
>
> •  Does statement 1)
> assign the destination IP address? Note that for my application, the
> source and destination addresses will be different.
>
> •  Does statement 3)
> populate the (UDP) datagram socket with the message, port, and address?
> Why a "#" symbol prefixing the message string, 'hello world'?
>
> •  Does statement 4)
> create a listening socket?
>
> •  Does statement 5)
> trigger the send?
>
> •  Does statement 6)
> block until the UDP response?
>
> +---------------------------------------------------------+
>
> UDP Smalltalk (example) program:
>
> 1) h _ Sockets.SocketAddress createLoopbackHost.
>
> 2) s _ Sockets.DatagramSocket new.
>
> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
>
> 4) answer _ Sockets.Datagram new.
>
> 5) s nextPut:d.
>
> 6) s receive:answer.
>
> 7) (answer data) asString printNl.
>
> 8) s close.
>
> Gary Highberger
>
>
> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <[hidden email]>
> wrote:
>
>> Good morning David,
>>
>> I'm not familiar with 'daytime' but will come up to speed on it and get
>> it and your use cases running and report my findings for everybody to see.
>>
>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
>> very short and simple.
>>
>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>>
>> I used my cell phone as the destination, my home WiFi as the network, and
>> tcpdump to see the packet.
>>
>> Thank you David for the Smalltalk code fragments and introducing me to
>> inetd and 'daytime'.
>>
>> Gary Highberger
>>
>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

stes

Gary,

I cannot tell whether GNU smalltalk is stable or not,
only whether the simple datagram daytime test works for me ...

Also it may be that GNU smalltalk has different strengths than socket programming,
the fact that they have on the roadmap for GNU smalltalk 3.3 a 'complete rewrite'
of the socket code, worries me to say the least ...

When I modify the script that I posted to use a different host, it works for me:

First I test from a different host a connection to host 'antar' :

bash-4.4$ nc -u antar 13
123
Tue Jan 12 19:41:27 2021
^C

Then when I do the same thing with GNU smalltalk 3.2.5 from the remote host it works:

bash-4.4$ cat daytime-dgram.st
PackageLoader fileInPackage: 'Sockets'.

h _ Sockets.SocketAddress byName:'antar'.
h printNl.
s _ Sockets.DatagramSocket new.
d _ Sockets.Datagram data:#'hello world' address:h port:13.
answer _ Sockets.Datagram new.
s nextPut:d.
s receive:answer.
(answer data) asString printNl.
s close.

bash-4.4$ gst daytime-dgram.st
Loading package ObjectDumper
Loading package Sockets
192.168.0.2
'Tue Jan 12 19:46:56 2021
'

This is of course assuming that 'antar' returns the dgram daytime service.

But that in itself is a classical simple test for datagrams.

Regards,
David Stes

----- Op 12 jan 2021 om 17:28 schreef Gary Highberger [hidden email]:

> Hi David and everybody,
>
> I just sent my first UDP packet with Smalltalk Sockets. It's likely just me
> but there might be some instability in gst. Somehow my Datagram Socket got
> wiped out. I'm going to run tests and publish my findings here.
>
> Have GNU Smalltalk Sockets and the VM been proven in real world
> applications?
>
> Packet:
> $ sudo tcpdump -i 1 -nn -n -A port 49152
> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
> listening on wlp3s0, link-type EN10MB (Ethernet), capture size 262144 bytes
> 10:53:15.131345 IP 192.168.1.114.49153 > 192.168.1.249.49152: UDP, length 27
> E..7..@.@..0...r.........#..  Hi sailor! New in town?
>
> Smalltalk:
> st> PackageLoader fileInPackage: 'Sockets'
> "Global garbage collection... done"
> Loading package Sockets
> PackageLoader
> st> DgS := Sockets.DatagramSocket remote: '192.168.1.249' port: 49152
> local: '192.168.1.114' port: 49153
> Sockets.DatagramSocket[192.168.1.114:49153]
> st> DgD := Sockets.Datagram data: '  Hi sailor! New in town?  '
> a Datagram
> st> DgS nextPut: DgD
> Sockets.DatagramSocket[192.168.1.114:49153]
> Voila
>
> Many thanks for the help everybody!
>
> Gary
>
> On Sun, Jan 10, 2021 at 1:49 PM Gary Highberger <[hidden email]>
> wrote:
>
>> Hello David and all,
>>
>> I have a few (noob) questions about the UDP example Smalltalk program.
>> More questions likely to follow as I come up to speed. Your patience is
>> much appreciated David and everybody.
>>
>> QUESTIONS:
>> •  Is "_" the preferred assignment operator? I've been seeing ":=" too. I
>> don't have a back arrow on my keyboard. I guess the PARC people used "_".
>>
>> •  Does statement 1)
>> assign the destination IP address? Note that for my application, the
>> source and destination addresses will be different.
>>
>> •  Does statement 3)
>> populate the (UDP) datagram socket with the message, port, and address?
>> Why a "#" symbol prefixing the message string, 'hello world'?
>>
>> •  Does statement 4)
>> create a listening socket?
>>
>> •  Does statement 5)
>> trigger the send?
>>
>> •  Does statement 6)
>> block until the UDP response?
>>
>> +---------------------------------------------------------+
>>
>> UDP Smalltalk (example) program:
>>
>> 1) h _ Sockets.SocketAddress createLoopbackHost.
>>
>> 2) s _ Sockets.DatagramSocket new.
>>
>> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
>>
>> 4) answer _ Sockets.Datagram new.
>>
>> 5) s nextPut:d.
>>
>> 6) s receive:answer.
>>
>> 7) (answer data) asString printNl.
>>
>> 8) s close.
>>
>> Gary Highberger
>>
>>
>> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <[hidden email]>
>> wrote:
>>
>>> Good morning David,
>>>
>>> I'm not familiar with 'daytime' but will come up to speed on it and get
>>> it and your use cases running and report my findings for everybody to see.
>>>
>>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
>>> very short and simple.
>>>
>>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>>>
>>> I used my cell phone as the destination, my home WiFi as the network, and
>>> tcpdump to see the packet.
>>>
>>> Thank you David for the Smalltalk code fragments and introducing me to
>>> inetd and 'daytime'.
>>>
>>> Gary Highberger
>>>
>>>

Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

stes

Also note that I set the remote address on the Datagram object.

I am not sure whether it matters, but I see in the code that you posted that you set the remote address on the DatagramSocket.

----- Op 12 jan 2021 om 19:50 schreef stes [hidden email]:

> Gary,
>
> I cannot tell whether GNU smalltalk is stable or not,
> only whether the simple datagram daytime test works for me ...
>
> Also it may be that GNU smalltalk has different strengths than socket
> programming,
> the fact that they have on the roadmap for GNU smalltalk 3.3 a 'complete
> rewrite'
> of the socket code, worries me to say the least ...
>
> When I modify the script that I posted to use a different host, it works for me:
>
> First I test from a different host a connection to host 'antar' :
>
> bash-4.4$ nc -u antar 13
> 123
> Tue Jan 12 19:41:27 2021
> ^C
>
> Then when I do the same thing with GNU smalltalk 3.2.5 from the remote host it
> works:
>
> bash-4.4$ cat daytime-dgram.st
> PackageLoader fileInPackage: 'Sockets'.
>
> h _ Sockets.SocketAddress byName:'antar'.
> h printNl.
> s _ Sockets.DatagramSocket new.
> d _ Sockets.Datagram data:#'hello world' address:h port:13.
> answer _ Sockets.Datagram new.
> s nextPut:d.
> s receive:answer.
> (answer data) asString printNl.
> s close.
>
> bash-4.4$ gst daytime-dgram.st
> Loading package ObjectDumper
> Loading package Sockets
> 192.168.0.2
> 'Tue Jan 12 19:46:56 2021
> '
>
> This is of course assuming that 'antar' returns the dgram daytime service.
>
> But that in itself is a classical simple test for datagrams.
>
> Regards,
> David Stes
>
> ----- Op 12 jan 2021 om 17:28 schreef Gary Highberger [hidden email]:
>
>> Hi David and everybody,
>>
>> I just sent my first UDP packet with Smalltalk Sockets. It's likely just me
>> but there might be some instability in gst. Somehow my Datagram Socket got
>> wiped out. I'm going to run tests and publish my findings here.
>>
>> Have GNU Smalltalk Sockets and the VM been proven in real world
>> applications?
>>
>> Packet:
>> $ sudo tcpdump -i 1 -nn -n -A port 49152
>> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
>> listening on wlp3s0, link-type EN10MB (Ethernet), capture size 262144 bytes
>> 10:53:15.131345 IP 192.168.1.114.49153 > 192.168.1.249.49152: UDP, length 27
>> E..7..@.@..0...r.........#..  Hi sailor! New in town?
>>
>> Smalltalk:
>> st> PackageLoader fileInPackage: 'Sockets'
>> "Global garbage collection... done"
>> Loading package Sockets
>> PackageLoader
>> st> DgS := Sockets.DatagramSocket remote: '192.168.1.249' port: 49152
>> local: '192.168.1.114' port: 49153
>> Sockets.DatagramSocket[192.168.1.114:49153]
>> st> DgD := Sockets.Datagram data: '  Hi sailor! New in town?  '
>> a Datagram
>> st> DgS nextPut: DgD
>> Sockets.DatagramSocket[192.168.1.114:49153]
>> Voila
>>
>> Many thanks for the help everybody!
>>
>> Gary
>>
>> On Sun, Jan 10, 2021 at 1:49 PM Gary Highberger <[hidden email]>
>> wrote:
>>
>>> Hello David and all,
>>>
>>> I have a few (noob) questions about the UDP example Smalltalk program.
>>> More questions likely to follow as I come up to speed. Your patience is
>>> much appreciated David and everybody.
>>>
>>> QUESTIONS:
>>> •  Is "_" the preferred assignment operator? I've been seeing ":=" too. I
>>> don't have a back arrow on my keyboard. I guess the PARC people used "_".
>>>
>>> •  Does statement 1)
>>> assign the destination IP address? Note that for my application, the
>>> source and destination addresses will be different.
>>>
>>> •  Does statement 3)
>>> populate the (UDP) datagram socket with the message, port, and address?
>>> Why a "#" symbol prefixing the message string, 'hello world'?
>>>
>>> •  Does statement 4)
>>> create a listening socket?
>>>
>>> •  Does statement 5)
>>> trigger the send?
>>>
>>> •  Does statement 6)
>>> block until the UDP response?
>>>
>>> +---------------------------------------------------------+
>>>
>>> UDP Smalltalk (example) program:
>>>
>>> 1) h _ Sockets.SocketAddress createLoopbackHost.
>>>
>>> 2) s _ Sockets.DatagramSocket new.
>>>
>>> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
>>>
>>> 4) answer _ Sockets.Datagram new.
>>>
>>> 5) s nextPut:d.
>>>
>>> 6) s receive:answer.
>>>
>>> 7) (answer data) asString printNl.
>>>
>>> 8) s close.
>>>
>>> Gary Highberger
>>>
>>>
>>> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <[hidden email]>
>>> wrote:
>>>
>>>> Good morning David,
>>>>
>>>> I'm not familiar with 'daytime' but will come up to speed on it and get
>>>> it and your use cases running and report my findings for everybody to see.
>>>>
>>>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
>>>> very short and simple.
>>>>
>>>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>>>>
>>>> I used my cell phone as the destination, my home WiFi as the network, and
>>>> tcpdump to see the packet.
>>>>
>>>> Thank you David for the Smalltalk code fragments and introducing me to
>>>> inetd and 'daytime'.
>>>>
>>>> Gary Highberger
>>>>

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Gnu mailing list
In reply to this post by stes

[hidden email] writes:

>
> In any case the smalltalk-mode could be enhanced:
>
>> (defvar smalltalk-prettify-symbols-alist
>>  '(("^" . ?↑)
>>    (":=" . ?←)))
>
> this could be extended to include a line
>
>>    ("_" . ?←)))
>
> so that the underscore is also pretty-printed as the back arrow.

Right now the underscore is not even highlighted as an operator. Treating it
as one could really screw up the parser. Do people still actively use
the underscore as the assignment operator? I thought that is a relic from
long long time ago.

Derek

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

stes

I'm using the underscore (_) as assignment operator;

As far as I can see, both Squeak and GNU smalltalk accept and support "_" as assignment;

David Stes

----- Op 12 jan 2021 om 19:54 schreef help-smalltalk [hidden email]:
>
> Right now the underscore is not even highlighted as an operator. Treating it
> as one could really screw up the parser. Do people still actively use
> the underscore as the assignment operator? I thought that is a relic from
> long long time ago.
>
> Derek

Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

stes
In reply to this post by highbeg

Gary,

Here's a tcpdump in my case of the UDP test on port 13 between two different systems
(192.168.0.1 and 192.168.0.2) :

# tcpdump -i net1 -nn -n -A port 13
dropped privs to nobody
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on net1, link-type EN10MB (Ethernet), capture size 262144 bytes
20:15:17.760479 IP 192.168.0.1.49167 > 192.168.0.2.13: UDP, length 11
E..'.W.....................xhello world
20:15:17.767964 IP 192.168.0.2.13 > 192.168.0.1.49167: UDP, length 26
E..6....<..b............."..Tue Jan 12 20:15:16 2021

^C
2 packets captured

The host 192.168.0.1 is running GNU smalltalk.
The host 192.168.0.2 is the one running the datagram daytime service.

Regards,
David Stes

----- Op 12 jan 2021 om 17:28 schreef Gary Highberger [hidden email]:

> Hi David and everybody,
>
> I just sent my first UDP packet with Smalltalk Sockets. It's likely just me
> but there might be some instability in gst. Somehow my Datagram Socket got
> wiped out. I'm going to run tests and publish my findings here.
>
> Have GNU Smalltalk Sockets and the VM been proven in real world
> applications?
>
> Packet:
> $ sudo tcpdump -i 1 -nn -n -A port 49152
> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
> listening on wlp3s0, link-type EN10MB (Ethernet), capture size 262144 bytes
> 10:53:15.131345 IP 192.168.1.114.49153 > 192.168.1.249.49152: UDP, length 27
> E..7..@.@..0...r.........#..  Hi sailor! New in town?
>
> Smalltalk:
> st> PackageLoader fileInPackage: 'Sockets'
> "Global garbage collection... done"
> Loading package Sockets
> PackageLoader
> st> DgS := Sockets.DatagramSocket remote: '192.168.1.249' port: 49152
> local: '192.168.1.114' port: 49153
> Sockets.DatagramSocket[192.168.1.114:49153]
> st> DgD := Sockets.Datagram data: '  Hi sailor! New in town?  '
> a Datagram
> st> DgS nextPut: DgD
> Sockets.DatagramSocket[192.168.1.114:49153]
> Voila
>
> Many thanks for the help everybody!
>
> Gary
>
> On Sun, Jan 10, 2021 at 1:49 PM Gary Highberger <[hidden email]>
> wrote:
>
>> Hello David and all,
>>
>> I have a few (noob) questions about the UDP example Smalltalk program.
>> More questions likely to follow as I come up to speed. Your patience is
>> much appreciated David and everybody.
>>
>> QUESTIONS:
>> •  Is "_" the preferred assignment operator? I've been seeing ":=" too. I
>> don't have a back arrow on my keyboard. I guess the PARC people used "_".
>>
>> •  Does statement 1)
>> assign the destination IP address? Note that for my application, the
>> source and destination addresses will be different.
>>
>> •  Does statement 3)
>> populate the (UDP) datagram socket with the message, port, and address?
>> Why a "#" symbol prefixing the message string, 'hello world'?
>>
>> •  Does statement 4)
>> create a listening socket?
>>
>> •  Does statement 5)
>> trigger the send?
>>
>> •  Does statement 6)
>> block until the UDP response?
>>
>> +---------------------------------------------------------+
>>
>> UDP Smalltalk (example) program:
>>
>> 1) h _ Sockets.SocketAddress createLoopbackHost.
>>
>> 2) s _ Sockets.DatagramSocket new.
>>
>> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
>>
>> 4) answer _ Sockets.Datagram new.
>>
>> 5) s nextPut:d.
>>
>> 6) s receive:answer.
>>
>> 7) (answer data) asString printNl.
>>
>> 8) s close.
>>
>> Gary Highberger
>>
>>
>> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <[hidden email]>
>> wrote:
>>
>>> Good morning David,
>>>
>>> I'm not familiar with 'daytime' but will come up to speed on it and get
>>> it and your use cases running and report my findings for everybody to see.
>>>
>>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
>>> very short and simple.
>>>
>>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
>>>
>>> I used my cell phone as the destination, my home WiFi as the network, and
>>> tcpdump to see the packet.
>>>
>>> Thank you David for the Smalltalk code fragments and introducing me to
>>> inetd and 'daytime'.
>>>
>>> Gary Highberger
>>>
>>>

Reply | Threaded
Open this post in threaded view
|

Re: display _ as left arrow (was Re: Help on sending a UDP Packet)

Gnu mailing list
In reply to this post by stes

[hidden email] writes:

> I'm using the underscore (_) as assignment operator;
>
> As far as I can see, both Squeak and GNU smalltalk accept and support "_" as assignment;
>
Accept, but not encourage. None of the GNU smalltak and Squeak's official
example code use it. ":=" at least is a cognate from Pascal, what else is
using "_" ?

As a language GNU smalltalk has to be compatible; as a editor package
smalltalk-mode needs to promote best practices. The problem with
underscore is it is white space sensitive, and that can throw many
people off:

a_-1
a _-1

Both are valid smalltalk expressions.

Derek




Reply | Threaded
Open this post in threaded view
|

Re: Help on sending a UDP Packet

highbeg
In reply to this post by stes
David,

I haven't had a chance to dig into daytime yet. My needs are still pretty
minimum and I can still get by with tcpdump. Thanks for introducing me to
daytime nonetheless.

I can't reproduce the "Socket wiping out behavior" I mentioned previously.
I'm letting it go for now. If it reappears and is repeatable, I'll start a
new thread to document it.

The Sockets Package is working well and I'm happy with it so far. I was
able to get UDP packet receive working on my own and am SLOWLY coming up
to speed on Sockets and Smalltalk.

Thanks for the terrific support!

Gary Highberger

On Tue, Jan 12, 2021, 2:17 PM [hidden email] <[hidden email]> wrote:

>
> Gary,
>
> Here's a tcpdump in my case of the UDP test on port 13 between two
> different systems
> (192.168.0.1 and 192.168.0.2) :
>
> # tcpdump -i net1 -nn -n -A port 13
> dropped privs to nobody
> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
> listening on net1, link-type EN10MB (Ethernet), capture size 262144 bytes
> 20:15:17.760479 IP 192.168.0.1.49167 > 192.168.0.2.13: UDP, length 11
> E..'.W.....................xhello world
> 20:15:17.767964 IP 192.168.0.2.13 > 192.168.0.1.49167: UDP, length 26
> E..6....<..b............."..Tue Jan 12 20:15:16 2021
>
> ^C
> 2 packets captured
>
> The host 192.168.0.1 is running GNU smalltalk.
> The host 192.168.0.2 is the one running the datagram daytime service.
>
> Regards,
> David Stes
>
> ----- Op 12 jan 2021 om 17:28 schreef Gary Highberger
> [hidden email]:
>
> > Hi David and everybody,
> >
> > I just sent my first UDP packet with Smalltalk Sockets. It's likely just
> me
> > but there might be some instability in gst. Somehow my Datagram Socket
> got
> > wiped out. I'm going to run tests and publish my findings here.
> >
> > Have GNU Smalltalk Sockets and the VM been proven in real world
> > applications?
> >
> > Packet:
> > $ sudo tcpdump -i 1 -nn -n -A port 49152
> > tcpdump: verbose output suppressed, use -v or -vv for full protocol
> decode
> > listening on wlp3s0, link-type EN10MB (Ethernet), capture size 262144
> bytes
> > 10:53:15.131345 IP 192.168.1.114.49153 > 192.168.1.249.49152: UDP,
> length 27
> > E..7..@.@..0...r.........#..  Hi sailor! New in town?
> >
> > Smalltalk:
> > st> PackageLoader fileInPackage: 'Sockets'
> > "Global garbage collection... done"
> > Loading package Sockets
> > PackageLoader
> > st> DgS := Sockets.DatagramSocket remote: '192.168.1.249' port: 49152
> > local: '192.168.1.114' port: 49153
> > Sockets.DatagramSocket[192.168.1.114:49153]
> > st> DgD := Sockets.Datagram data: '  Hi sailor! New in town?  '
> > a Datagram
> > st> DgS nextPut: DgD
> > Sockets.DatagramSocket[192.168.1.114:49153]
> > Voila
> >
> > Many thanks for the help everybody!
> >
> > Gary
> >
> > On Sun, Jan 10, 2021 at 1:49 PM Gary Highberger <
> [hidden email]>
> > wrote:
> >
> >> Hello David and all,
> >>
> >> I have a few (noob) questions about the UDP example Smalltalk program.
> >> More questions likely to follow as I come up to speed. Your patience is
> >> much appreciated David and everybody.
> >>
> >> QUESTIONS:
> >> •  Is "_" the preferred assignment operator? I've been seeing ":=" too.
> I
> >> don't have a back arrow on my keyboard. I guess the PARC people used
> "_".
> >>
> >> •  Does statement 1)
> >> assign the destination IP address? Note that for my application, the
> >> source and destination addresses will be different.
> >>
> >> •  Does statement 3)
> >> populate the (UDP) datagram socket with the message, port, and address?
> >> Why a "#" symbol prefixing the message string, 'hello world'?
> >>
> >> •  Does statement 4)
> >> create a listening socket?
> >>
> >> •  Does statement 5)
> >> trigger the send?
> >>
> >> •  Does statement 6)
> >> block until the UDP response?
> >>
> >> +---------------------------------------------------------+
> >>
> >> UDP Smalltalk (example) program:
> >>
> >> 1) h _ Sockets.SocketAddress createLoopbackHost.
> >>
> >> 2) s _ Sockets.DatagramSocket new.
> >>
> >> 3) d _ Sockets.Datagram data:#'hello world' address:h port:13.
> >>
> >> 4) answer _ Sockets.Datagram new.
> >>
> >> 5) s nextPut:d.
> >>
> >> 6) s receive:answer.
> >>
> >> 7) (answer data) asString printNl.
> >>
> >> 8) s close.
> >>
> >> Gary Highberger
> >>
> >>
> >> On Sun, Jan 10, 2021, 8:48 AM Gary Highberger <
> [hidden email]>
> >> wrote:
> >>
> >>> Good morning David,
> >>>
> >>> I'm not familiar with 'daytime' but will come up to speed on it and get
> >>> it and your use cases running and report my findings for everybody to
> see.
> >>>
> >>> Hopefully netTest.c explains what I'm trying to do with Smalltalk. It's
> >>> very short and simple.
> >>>
> >>> https://www.dropbox.com/s/xc23wj6r5aqh153/netTest.c?dl=0
> >>>
> >>> I used my cell phone as the destination, my home WiFi as the network,
> and
> >>> tcpdump to see the packet.
> >>>
> >>> Thank you David for the Smalltalk code fragments and introducing me to
> >>> inetd and 'daytime'.
> >>>
> >>> Gary Highberger
> >>>
> >>>
>