Category Archives: Technology

Troubleshoot a Slow Network – The entire Network is Slow

The Entire Network is Slow

If the entire network or a part of the network is slow, this could be a strong suggestion for a faulty switch or a miss-configuration.

Poor network equipment
Usage of hubs is not recommended, (hubs are prone to collisions by design)
Cheap switches that cannot handle the total needed bandwidth. The switch’s chip can handle 100Mb/s for 12 ports, but the switch has 24 ports and all are connected. For low network usage this is not a problem, but if your network usage spikes, your switch will not be able to handle the bandwidth. The quick fix in such situation is to power off the switch for a few minutes and then power it back on.

Loopback
A loopback is a network cable that has both ends connected to the same switch. If it’s a managed switch activating loop protection on all the ports could fix the problem. You can look on the switch’s log file for excessive broadcasts and isolate the two ports that are in loop. If you don’t have managed switches you can use a packet sniffer to determine if there’s a loop. A wrongly configured Spanning tree could cause a loopback.
FIX: Check all the patch-cord connections in the faulty switch. Check for patch-cords that have both ens into the same switch. Check for more than one patch-cord connecting the same two switches.
If you have cascaded switches it is normal to be slower for the devices in the cascaded switch but is not normal for the devices that are not cascaded. Check if any cascaded device is not connected on two ports on the wall, (usually the ports on the wall go to the network room). Your cascaded switch makes a loop into the upper level switch.

Bad Network Configuration
DNS issues
can cause a lot of slowdowns.
One common error is to use your ISP’s DNS server inside your Active Directory network. Your Active Directory computer members will try to resolve internal names by querying your ISP’s DNS. Those records don’t exist outside of your network.
Fix: For all of your Active Directory network clients remove any entries for your ISP’s and use only internal DNS servers. Configure your ISP’s DNS server as a forwarder on your AD DNS servers.

Network switching equipment wrongly connected is the reason of slow network for many small networks. Typically this happens when a small switch is connected to the router. When the switch becomes too small for a growing network, the first impulse is to connect the computers into the router directly.
Fix
: Install a switch that will accommodate all of the computers in the network. Disconnect any computers connected directly into the router.
Note: It is normal for the wireless connected computers to have slower transfer rate than the wired ones. Most of the wireless routers and adapters function at 54Mb per second. If your router is a modern router, (100 Mb or faster), and you still don’t get the expected transfer rates, you should revise your configuration as above.

Broadcast storm
You can efficiently detect a broadcast storm using a packet sniffer or a managed switch. With a packet sniffer you need to look for large numbers of broadcast/multicast (more than 20% of the total traffic it is an alarm signal). Locate the retransmission packets and search for the source MAC address. Disconnect the problem host.
If you suspect a broadcast storm in your network and you don’t have a managed switch or a packet sniffer, you can run download and upload tests by systematically disconnecting all of your computers in the network one by one. This is only practical in small network environment.

Virus Attack
A lot of connections originating from the same MAC address, to the same destination port, but for different destination address, and in short intervals.
Fix: Determine the source address of these connections and disconnect the suspect hosts. Run an antivirus scan on the computer before plugging it back. There are a few ways to determine the source of a virus. Use a packet sniffer, look on your managed switch for the ports with the most traffic and confirm it on the suspected computer by issuing the command “netstat -a -b”, (on a Windows machine). The command will show you which ports are active and which program, (executable), is using the ports.

This article is part of a five posts series regarding Network Troubleshooting.

How to send emails from a batch file in Windows

Automatic emails from command line in Windows

Did you ever want to send automatic emails, whether the sending was triggered by an event or just wanted to send the email at a certain time of the day or month?
I am not talking about Email Marketing Software, although that sounds interesting too. I am talking about sending emails from a batch file. You make a backup of a file and need to know when the task was finished or you want to send some files to a group of users, let’s say some weekly reports, logs, the contents of an html form, etc… How do you do that? Here is a real example.

Many people look for an outlook command line to send email, however that is less powerful than my method. At the end of the article you can see a limited way to do that. Before looking at the Outlook solution though, check my solution to send email from command line. It’s powerful, elegant and fast.

How did I Start to Send Emails from Command Line?

I was recently asked to find a solution for sending some huge Excel reports to a list of users. Previously, the application was automatically producing and then sending the reports using Outlook. The application didn’t compress the files and that worked fine until a huge report was requested by the Management. The huge report couldn’t be sent anymore by email because the servers will deny big attachments.
Using third party automatic email attachment compression software, (like Winzip Courier), didn’t work because works with an Outlook message, but this wasn’t the case.
We then decided to let the application do only the report generation and we were going to compress and email the files using other software.

First of all there are several applications of the type “Automatic Email Senders“. The “Automatic Email Senders” software applications are very complex, take space on the hard-drive and cost money. Our solution is a free solution for the regular small business network administrator, who doesn’t always have the money to spend.

The Technical Details to Send Emails from Command Line?

Our solution used 7zip as a compression utility and Blat as the emailing utility.

7zip is an open-source file archiver. It has a graphical interface but we only used the command line. You can download 7zip here: http://www.7-zip.org/.
Blat is a free, small application, without a graphical interface, that can send email message from the command line. You can download Blat here: http://www.blat.net/.
Following is a batch file example to help you start your own.

:: courtesy of http://dorianblog.info

:: The paths to the report files and the Output folder for the archived file.
Set InputPath=\\192.168.168.168\shared\Reports
Set OutputPath=\\192.168.168.168\shared\Reports\Output

:: Insert the date into a variable to use it as a file name
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B 
For /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set date=%%a%%b%%c)

Set Filetosend=Real-file-Name

:: The recipient list
Set RecipientList=user.one@some-domain.com,user.two@some-domain.com,user.three@some-domain.com

cd C:\Base-Folder\

:: Delete any previously created file
del /q /f "C:\Base-Folder\%Filetosend%.zip"

:: We check if we are connected to the share. ctrl.txt is a dummy file created only for this.
:: It is wise to use a specially created user that only has access to the share. The password of this user is stored on this batch file.
:: We need this in order to make sure the scheduled task runs successfully even if we are not logged in.
if exist "%InputPath%\ctrl.txt" goto auto
net use "%InputPath%" /user:shareUser share-password

:auto
:: First compress the file to send using maximum compression. -mx can be lower for reducing the compression time.
C:\Base-Folder\7za a -y -tzip -mx=9 -r %OutputPath%\%date%-%Filetosend%.zip %InputPath%\%Filetosend%.xls

:: If you have winzip installed and you have the command line you can use this.
"C:\Program Files\WinZip\WZZIP.EXE" -a "%OutputPath%\%date%-%Filetosend%.zip" "%InputPath%\%Filetosend%.xls"

:: We send the file now using blat. We use the submit port on our SMTP server and authentication. 
:: The authenticated user is "emailuseraccount" with the password "email-password".
:: The variable %RecipientList% contains all of your recipients separated by comas.
blat -server "mail.some-domain.com" -port 587 -u emailUseraccount -pw email-password -f sender@some-domain.com -noh -to %RecipientList% -subject "Reports %Filetosend%" -body "Attached you will find your Jet Report" -attach "%OutputPath%\%date%-%Filetosend%.zip"

:: We disconnect the network 
net use /delete %InputPath%

:: Remove all the variables
Set Base-Folder=
Set InputPath=
Set OutputPath=
Set RecipientList=

If you found this article useful, post a link to this page or make a comment. You can also comment with improvements of the batch.

If you are looking at a way to automatically send emails through Outlook, there is a limited function of this. The function is limited to composing emails only and they cannot be automatically sent using command line switches. The following command:
“C:\Program Files\Microsoft Office\Office11\Outlook.exe” /m “user@test.com” /a “c:\Somefile.zip”
will create a message addressed to user@test.com with the somefile.zip as an attachment. The message will have to be manually sent by an operator. An alternative for a fully automated solution is to use a key stroke simulator such as SendKeys to emulate CTRL+S, (send). Another solution to automatically send emails from Outlook is to use TASK SCHEDULER to call a VBS script. The VBS script does the sending through Outlook. There are a few ways to do this using the Outlook Object Model, or MAPI Mail, or CDO mail. But this is out of the scope of this article and I see very little advantage in developing a VBS script for Outlook.

How to Run Network Cables?

The best time to run your cables for a Computer Network is at the construction/renovation time. At this time it is the easiest to run cables and drill all the passage holes. If the building is already done and it doesn’t need any renovation you can still run your cables.

Fishing and Running Network Cables

For a new building, it is wise to run the cables through designated conduits and to calibrate your conduit so additional cables can be added at a later time if needed. Plan junction boxes at each floor or major node.

For an old building, installing conduits might not be possible. In this case you need to tie your cables in a bunch and secure the bunch to walls, ceiling, etc… You need to use a fish tape to fish your cables in the wall cavity. You might need to use a stud finder to avoid obstructing framing. Adjust your outlet’s position accordingly. Very often the help of a second person is needed when fishing cables, especially when you fish the cables from ceiling to the outlet, behind the wall. In this case on person feeds the fish tape down, or up depending on the case, the other person tries to catch the fish tape with another fish tape or something similar. Once the fish tape is on the position, passed through the drywall hole, attach your cables to the fish tape using duct tape. Run a pull line as well, it will be very useful in the future, in the case you want to add additional cables or replace the defective ones.

Rules for running Network Cables
Make sure before drilling any holes into joists, that you follow the building codes.
Take care of the network cable integrity:

  • do not drop objects on the cables
  • do not step on the cables,
  • do over-bend or over-twist the network cable

When you pull your cable through holes do not pull too hard as this could stretch the cable and modify its electrical qualities. Using a pull-string will provide additional firmness.
Try to avoid electric cables and other electromagnetic sources.

Cable Length and Routes

On an Ethernet type network, typically, we use a star network topology. This means that all of the devices connect into a central point, which is usually a network switch. The network switch receives and distributes all the network packets to network devices.

You need to plan your network so that the longest path from any two network devices is less than 100m, (328ft). If this is not possible plan using additional repeaters or switches. Position your network room, to obtain the least cable lengths.