VOGONS


First post, by mike_canada

User metadata
Rank Member
Rank
Member

I have a computer running linux that can download the google homepage in like a couple of seconds using an ordinary web browser. I have slightly modified the steps I took in the DOSBOX networking how-to to achieve internet in DOSBOX. My script to start DOSBOX with networking enabled is below:

#!/bin/bash
#turn on IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
#force-close apps in case dosbox got terminated prematurely
kill -9 $(pidof socat) > /dev/null
kill -9 $(pidof slattach) > /dev/null
kill -9 $(pidof dosbox) > /dev/null
killall socat > /dev/null
killall slattach > /dev/null
killall dosbox > /dev/null
#make a line
socat -4 PTY,link="/tmp/dbnet",raw,echo=0 TCP4-LISTEN:8001 &
sleep 1
slattach -vdL -s 9600 -p slip "/tmp/dbnet" &
sleep 1
ifconfig sl0 192.168.7.1 dstaddr 192.168.7.2 netmask 255.255.255.252 mtu 576 txqueuelen 576 up
#empty IPtables. My PC is not a real server.
iptables -t nat -F
#last param here = local ip address to my internet router
iptables -t nat -A POSTROUTING -s 192.168.7.0/30 -j SNAT --to-source 192.168.0.102
dosbox
sleep 1
kill -9 $(pidof slattach) > /dev/null
kill -9 $(pidof socat) > /dev/null

I attached my DOSBOX config file relevant to the problem.

The attachment dosbox-0.74.conf is no longer available

So DosBox runs fine. Host PC reports:

slattach: tty_open: looking for lock
slattach: tty_open: trying to open /tmp/dbnet
slattach: tty_open: /tmp/dbnet (fd=4)
slattach: tty_set_speed: 9600
slattach: tty_set_databits: 8
slattach: tty_set_stopbits: 1
slattach: tty_set_parity: N
slip started on /tmp/dbnet interface sl0
DOSBox version 0.74
Copyright 2002-2010 DOSBox Team, published under GNU GPL.
---
CONFIG:Loading primary settings from config file /root/.dosbox/dosbox-0.74.conf
MIXER:Got different values from SDL: freq 22050, blocksize 705
MIDI:Opened device:oss
Serial2: Connected to 127.0.0.1
DOS keyboard layout loaded with main language code US for layout us
MAPPER: Loading mapper settings from /root/.dosbox/mapper-0.74.map

And client reports:

The attachment screen.png is no longer available

But when I try to use the internet (with mTCP's HTGET) in DOSBOX, ping works fine but trying to download a webpage takes forever at best. Here's another screenshot:

The attachment screen2.png is no longer available

So it takes 1 second to load the first part (what you see), then about 30 seconds for the rest of the content to appear, then another 20 seconds to supposedly close the connection. then I get:

"NULL assignment detected"

and the program closes.

Why would the internet take so long in DOSBOX?

I tried maximum priority settings, and even played with CPU cycles. and the only difference I noticed with CPU cycles is the timings from mTCP's ping utility. When I make the cycles down to the low hundreds, ping reported higher response times in the 100 mS instead of 60mS.

This is mTCP for dos here: http://www.brutman.com/mTCP/

and I am using the latest version.

Reply 1 of 4, by mbbrutman

User metadata
Rank Member
Rank
Member

That mTCP is 6 years old already. The newest version was released in March 2020, and there were significant fixes to htget.

On your speed problem ... I'm not sure how DOSBox models the serial port, but if it is actually doing it in a timing accurate manner then 9600 bps is going to be pretty slow. That works out to about 1 character per millisecond. The ping packets take about 60 bytes, so 60ms will be the lower bound for those. With MTU at 576 each packet is going to take half a second to transmit or receive. Even without the TCP/IP overhead you are limited to no more than 1KB/sec for transfers.

If DOSBox is not modeling the speed of the serial port then it is not an issue. But you should try moving to a faster speed, such as 115,200 if you are using virtual hardware. If that improves things then we will know if DOSBox was modeling the speed of the serial port accurately.

Reply 2 of 4, by mike_canada

User metadata
Rank Member
Rank
Member
mbbrutman wrote on 2021-06-09, 21:26:

That mTCP is 6 years old already. The newest version was released in March 2020, and there were significant fixes to htget.

Ok so I tried the newer HTGET with same setup and this time I had to wait about 10 seconds for any output, then half the data appeared all at once, then I had to wait another 10 seconds, and I receive the rest of the data along with "null assignment detected".

But it seems that the speed setting helped but I don't know why the dosbox manuals for networking only advocated for 9600bps.

I didn't modify the MTU and that's because I'm trying to write my own DOS internet application. And so far with it, things are good when I connect to a server for the first time, but on subsequent connects, the server thinks I'm using an existing connection but I'm not. In fact, in some cases, the packet driver (for dosbox) receives NOTHING despite tcpdump in linux showcasing that data is being sent to the dosbox NIC (of sl0). The only ways out in my case since the server ignores the TCP reset command is for me to either flood the connection with resets while setting the ACK to every value (That would be 4 million sends), or wait for a long time until the remote server makes a reset, or I could close and restart DOSBOX and all the networking and pray that works.

When I researched my issue online, I came across https://unix.stackexchange.com/questions/3960 … kets-with-delay and someone indicated that I should use source-based routing, and someone else indicated that by using NAT (which what dosbox manual recommends), something funny happens with TCP which is probably why half the time packets aren't being passed through to DOSBOX. I see a bit of info here: https://stackoverflow.com/questions/32464675/ … ld-in-its-table

Maybe SNAT is the wrong approach to DOSBOX networking. any thoughts?

So in summary, for SNAT if I run my own TCP networking program to make a connection to a server for the very first time, the data is returned and I send a FIN packet. Apparently it gets ignored (not by DOSBOX and not by my iptables). When I execute my program again, i find that the packet driver (ethersl) doesn't receive any data. I tried mTCP tools right after and even it can't receive data. However if I don't execute my program at all, mTCP tools run fine.

This is why I think there has to be another approach to virtual DOSBOX networking besides using SNAT.

I did consider the DOSBOX megabuild but internet archive website has a copy (don't know if a linux version is available) but that site has a disclaimer stating it hasn't been tested for viruses.

Reply 3 of 4, by mbbrutman

User metadata
Rank Member
Rank
Member

It's hard to follow through all of that.

If you are developing a program using the mTCP TCP/IP code, then I would use a virtual machine that emulates a real Ethernet card. I love DOSBox, but it's lack of Ethernet emulation means that you have to futz with the SLIP or PPP configuration, and that is more fragile than the Ethernet path.