categories

Blogroll

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Subscribe Now: Feed

Showing posts with label Tips n Tricks. Show all posts
Showing posts with label Tips n Tricks. Show all posts

Tuesday, July 3, 2007

Winsock2 LSP Corruption & Fix


Figure: Winsock 2 Architecture (Source: Microsoft)
Introduction
Microsoft Windows Winsock provides network socket facility for Applications via Service Provider Interface (SPI) and is extensible via Layered Service Provider (LSP). A LSP is a Dynamic Link Library (DLL) that uses Winsock Application Programming Interfaces (APIs) to insert itself into the TCP/IP stack from where it can intercept and modify all the TCP/IP inbound/outbound internet traffic taking place between Internet and the Application accessing internet. In simple words, LSP typically handles low-level Internet-related tasks, and data is passed through a chain of these programs on its way to and from the Internet.

Winsock LSPs are available for a wide range of useful purposes, e.g. internet access control, web content filtering, traffic analysis etc. The Winsock API prvoides a mecahnism for layering providers to implement only higher level custom communication functions. The layering order of all providers is kept in the Winsock Catalog.

About LSP Corruption
One of the major issue with LSPs is that if they are removed or unregistered improperly or if the LSP is malformed (buggy), it could result in corruption of the Winsock catalog in the registry, the entire TCP/IP stack would break, potentially resulting in a loss of all network connectivity. Lot of Spyware, Adware & Malware may insert themselves as an LSP in the network stack to spy on the habits and data of the user and may forward all of the user's internet traffic to an unauthorized external site for data mining purpose. The problem can also be caused by any improperly written Layered Service Provider software, or the deletion of any LSP program's files. If you uninstall/delete these malformed programs (spyware, adware), it may happen that you won't be able to access Internet. This is due to the broken LSP chain.

LSP Corruption FIX
If you are running Windows XP (Service Pack 2), there are two new Netsh commands available (although Winsock self heals in XP SP2).
1. netsh winsock show catalog
This command displays the list of all Winsock LSPs that are installed on the computer. You can go through the list to find malformed LSPs.

2. netsh winsock reset catalog
This command resets the Winsock catalog to the default configuration. This can be useful if a malformed LSP is installed that results in loss of network connectivity. While use of this command can restore network connectivity, it should be used with care because any previously installed LSPs will need to be re-installed.

If you are runing Windows XP (Without Service Pack 2), you would need to manually repair winsock by deleting the corrupted registry keys and then reinstall/reset the TCP/IP protocol.

Step 1: Delete the corrupted registry keys
Warning: Backup your registry before you edit it. For more information about how to back up the registry, click here
1. Click Start, and then click Run.
2. In the Open box, type regedit, and then click OK.
3. In Registry Editor, locate the following keys, right-click each key, and then click Delete:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Winsock2
4. When you are prompted to confirm the deletion, click Yes.
5. Restart the computer after you delete the Winsock keys. Doing so causes the Windows XP operating system to create new shell entries for those two keys.
Note: If you do not restart the computer after you delete the Winsock keys, the next step does not work correctly.

Step 2: Reset TCP/IP Protocol Stack
1. Run the following Netsh Command
netsh int ip reset c:\resetlog.txt
2. Restart your computer.

When you run the reset command, it rewrites following pertinent registry keys that are used by the Internet Protocol (TCP/IP) stack to reach the same result as the removal and the reinstallation of the protocol.
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\
SYSTEM\CurrentControlSet\Services\DHCP\Parameters\

Other Operating Systems
If your Operating System is Windows 98, 98SE or ME, You can download the following program to fix Winsock LSP.
Winsockfix
LSP-Fix
XPTCPREP

AddThis Social Bookmark Button

Tuesday, May 29, 2007

PermGen OutOfMemory


If you are frustrated with Tomcat, JBoss, any other Java Application Server dying with an OutOfMemory Error every few times you redeploy your Java application code or if you have recently installed a new application in your Stable Java Environment and your Tomcat, JBoss is giving you hiccups by intermittently Crashing with OutOfMemory Errors , then keep on reading as I would like to share my thoughts with you as I have experienced the same issue.

You have checked that your Server has lot of Physical RAM, even JVM Heap Memory has been allocated a significant amount of Physical Memory, your Garbage Collection (GC) is tuned properly but you are still getting OutOfMemory error. I am not going to discuss about Java Virtual Machine (JVM) Memory model and Garbage Collection (GC) as this is out of the scope of this article. But you can read the details here

Introduction
SUN Java has a Generational garbage collector. Permanent Generation holds reflective data (meta-data) of the JVM itself, such as class and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized independently from the other generations.[Ref: SUN Java website ]

The Error
SUN Java website says that the default size of PermGen (64 MB for Server) is adequate in most cases but programs that load many classes may need a larger permanent generation. When you hot deploy/redeploy your web application, the WAR file is unpacked and its class definition are loaded into the JVM. These classes are never unloaded and they end up in the Permanent Generation. Now, if you hot deploy your application few times or install a new web application with large code base that loads up lot of class files, the default PermGen space get quickly filled and is never Garbage Collected (by standard GC) causing java.lang.OutOfMemoryError: PermGen.

But I have large JVM Heap
It doesn't matter how high is your overall -Xmx heap setting and how much memory you have on the machine. PermGen size i.e. PermSize is additional to the -Xmx value on the JVM Options.

The FIX
There is no garbage collection by standard garbage collection in Permanent Generation. Although concurrent garbage collector can collect in PermGen but this is beyond the scope of this article. I would be rather focussing on increasing the PermGen size.
  1. Make sure your Server has enough Physical RAM (considering the allocation to JVM Heap -Xmx).
  2. Use larger PermGen size using the Options -XX:PermSize= and -XX:MaxPermSize=
  3. e.g. Set the maximum permanent generation size using -XX:MaxPermSize=164m Option.
MaxPermSize allows for the JVM to be able to grow the PermSize to the amount specified. Initially when the JVM is loaded, the MaxPermSize will still be the default value (64mb for Server) but will not actually take up that amount until it is needed. But, if you want to Set a new initial perm size on Sun JVM, you can use -XX:PermSize=164m Option when starting the JVM.

Conclusion
  • The PermGen default size can be a bottleneck in your Web Applications that dynamically generate and load many classes.
  • The PermGen parameters discussed above when applied to the JVM that runs your application server, considerably reduces the chances of running into a PermGen OutOfMemoryError.


AddThis Social Bookmark Button

Saturday, May 26, 2007

Download YouTube Video

Everyday, thousands of Videos are uploaded to Youtube Website, which allows you to view saved videos on their servers but doesn't allow you to download them. What if you like a YouTube Video and want to save or download it to your computer or What if you could never get the online video player working.

If you are using Firefox Web Browser (Get it here), then you can download the VideoDownloader Firefox Plugin by Javi Moya . VideoDownloader add a small icon on the status bar at the bottom of your firefox window, and a toolbar button. Just click that and download the video you are watching.

If you are using any other Browser or don't want to install firefox add on, then there are many websites which allows you to download Videos from Youtube and other Video websites. You have to simply paste the URL of the YouTube Video you want to download into a form on their website. The websites like YOUTUBEX KEEPVID and VIDEODL allows you to download Videos from YouTube, Google, IFilm, Metacafe and various other Video Websites.


After you have downloaded/saved a YouTube Video on your hard drive, Make sure that the extension of the downloaded file is .flv (flash Video). If not, you must change the file extension to .flv (flash Video) format. The .flv is not a common multimedia file and you would need a software called FLV Player to play it. Downlaod and Install FLV Player or VLC Player into your computer to open the flash video file.

If you want to convert/decode the FLV videos to other formats like MPEG/MP4 so that you can store them onto your IPod or PSP then you can either download a free software called Riva FLV Converter or you can visit the Vixy website which offers an online FLV Converter.

Happy YouTubing!!

AddThis Social Bookmark Button

Wednesday, May 23, 2007

Windows RUN Command

I am very fond of the powerful Run command and find it very useful. I hate using the mouse to point and click a shortcut on the start menu. You can open the RUN command via Start Menu or simply press WIN+R i.e Windows key & R. Here is a list of the RUN commands I use on a very frequent basis.

CONTROL PANEL RELATED
1. control - Control Panel
2. appwiz.cpl - Add/Remove Programs
3. hdwwiz.cpl - Add Hardware Wizard
4. wuaucpl.cpl - Automatic Updates
5. fsquirt - Bluetooth Transfer Wizard
6. Fonts - control fonts
7. inetcpl - Internet Properties
8. ncpa.cpl - Network Connections
9. odbccp32.cpl - ODBC Data Source Administrator
10. sysdm.cpl - System Properties
11. nusrmgr.cpl - User Account Management
12. firewall.cpl - Windows Firewall
13. nusrmgr.cpl - User Account Management
14. control admintools - Administrative Tools
15. control schedtasks - Scheduled Tasks
16. control desktop - Display Properties
17. control keyboard - Keyboard Properties
18. control mouse - Mouse Properties
19. control printers - Printers and Faxes
20. control netconnections Network connections
21. control fonts - Fonts
22. control folders - Folder Properties

APPLICATIONS RELATED
1. calc - Calculator
2. cmd - Command Prompt
3. clipbrd - Clipboard Viewer
4. firefox - Firefox Browser
5. fonts - Fonts Folder
6. hypertrm - HyperTerminal
7. iexpress - iexpress wizard
8. iexplore - Internet Explorer
9. mrt - Malicious Software Removal Tool
10. mspaint - Microsoft Paint
11. notepad - Notepad Application
12. packager - Object Packager
13. msimn - Outlook Express
14. mstsc - Remote Desktop
15. regedit - Registry Editor (Also regedit32)
16. msconfig - System Configuration Utility
17. telnet - Telnet Client
18. explorer - Windows Explorer
10. write - Wordpad
11. wupdmgr - Windows Update Manager
12. msmsgs - Windows messanger
13. wmplayer - Windows media player
14. explorer - Windows Explorer
15. winword - Microsoft Word (if installed)
16. excel - Microsoft excel (if installed)
17. powerpnt - Microsoft powerpoint (if installed)

MISCELLANEOUS
1. verifier - Driver Verifier Utility
2. sigverif - File Signature Verification Tool
3. helpctr - Help and Support
4. icwconn1 - Internet Connection Wizard
5. msinfo32 - System Information
6. taskmgr - Task Manager
7. dxdiag - Direct X Troubleshooter
8. winver - Windows Version
9. diskpart - Disk Partition Manager
10.dcomcnfg - Component Services
11.logoff - Logs You Out Of Windows

AddThis Social Bookmark Button

Tuesday, May 22, 2007

Microsoft Mangement Console (MMC)

A lot of system administration tools that come with Windows 2000, 2003 & XP are already in a console form having an extension of ".msc". They can be used alone by typing the name in the RUN command or as snap-ins to a Microsoft Management console (MMC). My prefered and fast way is to type them in the RUN Window. The following is the list of some of the frequently used Console commands.

1. certmgr.msc - Certificate Manager
2. compmgmt.msc - Computer Management
3. devmgmt.msc - Device Manager
4. dfrg.msc - Disk Defragment
5. diskmgmt.msc - Disk Management
6. eventvwr.msc - Event Viewer
7. gpedit.msc - Group Policy Editor
8. secpol.msc - Local Security Settings
9. ciadv.msc - Indexing Service
10. lusrmgr.msc - Local Users and Groups
11. perfmon.msc - Performance Monitor
12. inetmgr.msc - IIS Manager
13. services.msc - Services
14. rsop.msc - Resultant Set of Policies
15. ntmsmgr.msc - Removable Storage

So, if you have administrator privileges and want to stop and start a service on another server without logging into that server, simply type services.msc command in RUN and press enter, right click on services(Local) in left pane and click "connect to another computer.." and type the server name and bingo! You are connected to the services console of another machine and then you can stop and start the service you like. Similarly, this can be done for event viewer, performance monitoring (perfmon), IIS etc.

I make an extensive use of Microsoft Management Console (MMC) and administer servers most of the time without even logging into the server.

In my next Blog, I will discuss the frequently used RUN commands.

AddThis Social Bookmark Button